LLVM  9.0.0svn
InfoStreamBuilder.cpp
Go to the documentation of this file.
1 //===- InfoStreamBuilder.cpp - PDB Info Stream Creation ---------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
19 
20 using namespace llvm;
21 using namespace llvm::codeview;
22 using namespace llvm::msf;
23 using namespace llvm::pdb;
24 
25 InfoStreamBuilder::InfoStreamBuilder(msf::MSFBuilder &Msf,
26  NamedStreamMap &NamedStreams)
27  : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Age(0),
28  NamedStreams(NamedStreams) {
29  ::memset(&Guid, 0, sizeof(Guid));
30 }
31 
33 
35  Features.push_back(Sig);
36 }
37 
39  HashPDBContentsToGUID = B;
40 }
41 
42 void InfoStreamBuilder::setAge(uint32_t A) { Age = A; }
43 
44 void InfoStreamBuilder::setSignature(uint32_t S) { Signature = S; }
45 
47 
48 
50  uint32_t Length = sizeof(InfoStreamHeader) +
51  NamedStreams.calculateSerializedLength() +
52  (Features.size() + 1) * sizeof(uint32_t);
53  if (auto EC = Msf.setStreamSize(StreamPDB, Length))
54  return EC;
55  return Error::success();
56 }
57 
59  WritableBinaryStreamRef Buffer) const {
60  auto InfoS = WritableMappedBlockStream::createIndexedStream(
61  Layout, Buffer, StreamPDB, Msf.getAllocator());
62  BinaryStreamWriter Writer(*InfoS);
63 
65  // Leave the build id fields 0 so they can be set as the last step before
66  // committing the file to disk.
67  ::memset(&H, 0, sizeof(H));
68  H.Version = Ver;
69  if (auto EC = Writer.writeObject(H))
70  return EC;
71 
72  if (auto EC = NamedStreams.commit(Writer))
73  return EC;
74  if (auto EC = Writer.writeInteger(0))
75  return EC;
76  for (auto E : Features) {
77  if (auto EC = Writer.writeEnum(E))
78  return EC;
79  }
80  assert(Writer.bytesRemaining() == 0);
81  return Error::success();
82 }
uint32_t calculateSerializedLength() const
This class represents lattice values for constants.
Definition: AllocatorList.h:23
support::ulittle32_t Version
Definition: RawTypes.h:305
void setGuid(codeview::GUID G)
This represents the 'GUID' type from windows.h.
Definition: GUID.h:21
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:191
Error commit(BinaryStreamWriter &Writer) const
static ErrorSuccess success()
Create a success value.
Definition: Error.h:326
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
The header preceding the global PDB Stream (Stream 1)
Definition: RawTypes.h:304
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:157
void addFeature(PdbRaw_FeatureSig Sig)
BumpPtrAllocator & getAllocator()
Definition: MSFBuilder.h:118