LLVM  14.0.0git
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 
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 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::BinaryStreamWriter::writeInteger
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
Definition: BinaryStreamWriter.h:64
llvm::BinaryStreamWriter::writeEnum
Error writeEnum(T Num)
Similar to writeInteger.
Definition: BinaryStreamWriter.h:74
RawTypes.h
NamedStreamMap.h
llvm::BinaryStreamWriter
Provides write only access to a subclass of WritableBinaryStream.
Definition: BinaryStreamWriter.h:31
llvm::pdb::InfoStreamBuilder::setHashPDBContentsToGUID
void setHashPDBContentsToGUID(bool B)
Definition: InfoStreamBuilder.cpp:38
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::codeview::GUID
This represents the 'GUID' type from windows.h.
Definition: GUID.h:21
llvm::pdb::InfoStreamBuilder::setGuid
void setGuid(codeview::GUID G)
Definition: InfoStreamBuilder.cpp:46
llvm::pdb::NamedStreamMap::calculateSerializedLength
uint32_t calculateSerializedLength() const
Definition: NamedStreamMap.cpp:83
RawError.h
llvm::pdb::InfoStreamBuilder::setAge
void setAge(uint32_t A)
Definition: InfoStreamBuilder.cpp:42
llvm::msf
Definition: IMSFFile.h:18
llvm::msf::MSFBuilder
Definition: MSFBuilder.h:26
llvm::pdb::PdbRaw_FeatureSig
PdbRaw_FeatureSig
Definition: RawConstants.h:36
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::msf::MSFLayout
Definition: MSFCommon.h:51
PDBFileBuilder.h
llvm::pdb::InfoStreamHeader
The header preceding the global PDB Stream (Stream 1)
Definition: RawTypes.h:304
llvm::pdb::InfoStreamBuilder::setVersion
void setVersion(PdbRaw_ImplVer V)
Definition: InfoStreamBuilder.cpp:32
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MSFBuilder.h
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
llvm::BinaryStreamWriter::bytesRemaining
uint64_t bytesRemaining() const
Definition: BinaryStreamWriter.h:186
llvm::pdb::NamedStreamMap::commit
Error commit(BinaryStreamWriter &Writer) const
Definition: NamedStreamMap.cpp:66
MappedBlockStream.h
llvm::pdb::NamedStreamMap
Definition: NamedStreamMap.h:38
llvm::pdb::InfoStreamBuilder::addFeature
void addFeature(PdbRaw_FeatureSig Sig)
Definition: InfoStreamBuilder.cpp:34
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::codeview::CompileSym2Flags::EC
@ EC
llvm::msf::MSFBuilder::setStreamSize
Error setStreamSize(uint32_t Idx, uint32_t Size)
Update the size of an existing stream.
Definition: MSFBuilder.cpp:192
llvm::pdb::InfoStreamBuilder::setSignature
void setSignature(uint32_t S)
Definition: InfoStreamBuilder.cpp:44
llvm::BinaryStreamWriter::writeObject
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
Definition: BinaryStreamWriter.h:135
uint32_t
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::pdb::PdbRaw_ImplVer
PdbRaw_ImplVer
Definition: RawConstants.h:21
llvm::msf::MSFBuilder::getAllocator
BumpPtrAllocator & getAllocator()
Definition: MSFBuilder.h:118
H
#define H(x, y, z)
Definition: MD5.cpp:58
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::pdb::InfoStreamBuilder::finalizeMsfLayout
Error finalizeMsfLayout()
Definition: InfoStreamBuilder.cpp:49
llvm::pdb::InfoStreamBuilder::commit
Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer) const
Definition: InfoStreamBuilder.cpp:58
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
InfoStream.h
llvm::pdb::StreamPDB
@ StreamPDB
Definition: RawConstants.h:78
BinaryStreamWriter.h
llvm::WritableBinaryStreamRef
Definition: BinaryStreamRef.h:221
llvm::pdb::PdbImplVC70
@ PdbImplVC70
Definition: RawConstants.h:28
InfoStreamBuilder.h