LLVM  8.0.1
InfoStreamBuilder.cpp
Go to the documentation of this file.
1 //===- InfoStreamBuilder.cpp - PDB Info Stream Creation ---------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
11 
20 
21 using namespace llvm;
22 using namespace llvm::codeview;
23 using namespace llvm::msf;
24 using namespace llvm::pdb;
25 
26 InfoStreamBuilder::InfoStreamBuilder(msf::MSFBuilder &Msf,
27  NamedStreamMap &NamedStreams)
28  : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Age(0),
29  NamedStreams(NamedStreams) {
30  ::memset(&Guid, 0, sizeof(Guid));
31 }
32 
34 
36  Features.push_back(Sig);
37 }
38 
40  HashPDBContentsToGUID = B;
41 }
42 
43 void InfoStreamBuilder::setAge(uint32_t A) { Age = A; }
44 
45 void InfoStreamBuilder::setSignature(uint32_t S) { Signature = S; }
46 
48 
49 
51  uint32_t Length = sizeof(InfoStreamHeader) +
52  NamedStreams.calculateSerializedLength() +
53  (Features.size() + 1) * sizeof(uint32_t);
54  if (auto EC = Msf.setStreamSize(StreamPDB, Length))
55  return EC;
56  return Error::success();
57 }
58 
60  WritableBinaryStreamRef Buffer) const {
61  auto InfoS = WritableMappedBlockStream::createIndexedStream(
62  Layout, Buffer, StreamPDB, Msf.getAllocator());
63  BinaryStreamWriter Writer(*InfoS);
64 
66  // Leave the build id fields 0 so they can be set as the last step before
67  // committing the file to disk.
68  ::memset(&H, 0, sizeof(H));
69  H.Version = Ver;
70  if (auto EC = Writer.writeObject(H))
71  return EC;
72 
73  if (auto EC = NamedStreams.commit(Writer))
74  return EC;
75  if (auto EC = Writer.writeInteger(0))
76  return EC;
77  for (auto E : Features) {
78  if (auto EC = Writer.writeEnum(E))
79  return EC;
80  }
81  assert(Writer.bytesRemaining() == 0);
82  return Error::success();
83 }
uint32_t calculateSerializedLength() const
This class represents lattice values for constants.
Definition: AllocatorList.h:24
support::ulittle32_t Version
Definition: RawTypes.h:306
void setGuid(codeview::GUID G)
This represents the 'GUID' type from windows.h.
Definition: GUID.h:22
void setVersion(PdbRaw_ImplVer V)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define H(x, y, z)
Definition: MD5.cpp:57
Provides write only access to a subclass of WritableBinaryStream.
Error setStreamSize(uint32_t Idx, uint32_t Size)
Update the size of an existing stream.
Definition: MSFBuilder.cpp:192
Error commit(BinaryStreamWriter &Writer) const
static ErrorSuccess success()
Create a success value.
Definition: Error.h:327
const DataFlowGraph & G
Definition: RDFGraph.cpp:211
The header preceeding the global PDB Stream (Stream 1)
Definition: RawTypes.h:305
Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
void addFeature(PdbRaw_FeatureSig Sig)
BumpPtrAllocator & getAllocator()
Definition: MSFBuilder.h:119