LLVM  7.0.0svn
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 
35 void InfoStreamBuilder::setAge(uint32_t A) { Age = A; }
36 
37 void InfoStreamBuilder::setSignature(uint32_t S) { Signature = S; }
38 
40 
42  Features.push_back(Sig);
43 }
44 
46  uint32_t Length = sizeof(InfoStreamHeader) +
47  NamedStreams.calculateSerializedLength() +
48  (Features.size() + 1) * sizeof(uint32_t);
49  if (auto EC = Msf.setStreamSize(StreamPDB, Length))
50  return EC;
51  return Error::success();
52 }
53 
55  WritableBinaryStreamRef Buffer) const {
56  auto InfoS = WritableMappedBlockStream::createIndexedStream(
57  Layout, Buffer, StreamPDB, Msf.getAllocator());
58  BinaryStreamWriter Writer(*InfoS);
59 
61  // Leave the build id fields 0 so they can be set as the last step before
62  // committing the file to disk.
63  ::memset(&H, 0, sizeof(H));
64  H.Version = Ver;
65  if (auto EC = Writer.writeObject(H))
66  return EC;
67 
68  if (auto EC = NamedStreams.commit(Writer))
69  return EC;
70  if (auto EC = Writer.writeInteger(0))
71  return EC;
72  for (auto E : Features) {
73  if (auto EC = Writer.writeEnum(E))
74  return EC;
75  }
76  assert(Writer.bytesRemaining() == 0);
77  return Error::success();
78 }
uint32_t calculateSerializedLength() const
Compute iterated dominance frontiers using a linear time algorithm.
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< 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:321
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:156
void addFeature(PdbRaw_FeatureSig Sig)
BumpPtrAllocator & getAllocator()
Definition: MSFBuilder.h:119