LLVM  15.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 
17 
18 using namespace llvm;
19 using namespace llvm::codeview;
20 using namespace llvm::msf;
21 using namespace llvm::pdb;
22 
23 InfoStreamBuilder::InfoStreamBuilder(msf::MSFBuilder &Msf,
24  NamedStreamMap &NamedStreams)
25  : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Age(0),
26  NamedStreams(NamedStreams) {
27  ::memset(&Guid, 0, sizeof(Guid));
28 }
29 
31 
33  Features.push_back(Sig);
34 }
35 
37  HashPDBContentsToGUID = B;
38 }
39 
40 void InfoStreamBuilder::setAge(uint32_t A) { Age = A; }
41 
43 
45 
46 
48  uint32_t Length = sizeof(InfoStreamHeader) +
49  NamedStreams.calculateSerializedLength() +
50  (Features.size() + 1) * sizeof(uint32_t);
51  if (auto EC = Msf.setStreamSize(StreamPDB, Length))
52  return EC;
53  return Error::success();
54 }
55 
57  WritableBinaryStreamRef Buffer) const {
58  auto InfoS = WritableMappedBlockStream::createIndexedStream(
59  Layout, Buffer, StreamPDB, Msf.getAllocator());
60  BinaryStreamWriter Writer(*InfoS);
61 
63  // Leave the build id fields 0 so they can be set as the last step before
64  // committing the file to disk.
65  ::memset(&H, 0, sizeof(H));
66  H.Version = Ver;
67  if (auto EC = Writer.writeObject(H))
68  return EC;
69 
70  if (auto EC = NamedStreams.commit(Writer))
71  return EC;
72  if (auto EC = Writer.writeInteger(0))
73  return EC;
74  for (auto E : Features) {
75  if (auto EC = Writer.writeEnum(E))
76  return EC;
77  }
78  assert(Writer.bytesRemaining() == 0);
79  return Error::success();
80 }
BinaryStreamReader.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::BinaryStreamWriter::writeInteger
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
Definition: BinaryStreamWriter.h:58
llvm::BinaryStreamWriter::writeEnum
Error writeEnum(T Num)
Similar to writeInteger.
Definition: BinaryStreamWriter.h:68
RawTypes.h
NamedStreamMap.h
llvm::BinaryStreamWriter
Provides write only access to a subclass of WritableBinaryStream.
Definition: BinaryStreamWriter.h:30
llvm::pdb::InfoStreamBuilder::setHashPDBContentsToGUID
void setHashPDBContentsToGUID(bool B)
Definition: InfoStreamBuilder.cpp:36
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
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:44
llvm::pdb::NamedStreamMap::calculateSerializedLength
uint32_t calculateSerializedLength() const
Definition: NamedStreamMap.cpp:81
llvm::pdb::InfoStreamBuilder::setAge
void setAge(uint32_t A)
Definition: InfoStreamBuilder.cpp:40
llvm::msf
Definition: IMSFFile.h:18
llvm::msf::MSFBuilder
Definition: MSFBuilder.h:27
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
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:30
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:200
llvm::BinaryStreamWriter::bytesRemaining
uint64_t bytesRemaining() const
Definition: BinaryStreamWriter.h:180
llvm::pdb::NamedStreamMap::commit
Error commit(BinaryStreamWriter &Writer) const
Definition: NamedStreamMap.cpp:64
MappedBlockStream.h
llvm::pdb::NamedStreamMap
Definition: NamedStreamMap.h:36
llvm::pdb::InfoStreamBuilder::addFeature
void addFeature(PdbRaw_FeatureSig Sig)
Definition: InfoStreamBuilder.cpp:32
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:42
llvm::BinaryStreamWriter::writeObject
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
Definition: BinaryStreamWriter.h:129
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:119
H
#define H(x, y, z)
Definition: MD5.cpp:57
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::pdb::InfoStreamBuilder::finalizeMsfLayout
Error finalizeMsfLayout()
Definition: InfoStreamBuilder.cpp:47
llvm::pdb::InfoStreamBuilder::commit
Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer) const
Definition: InfoStreamBuilder.cpp:56
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
llvm::pdb::StreamPDB
@ StreamPDB
Definition: RawConstants.h:78
BinaryStreamWriter.h
llvm::WritableBinaryStreamRef
Definition: BinaryStreamRef.h:220
llvm::pdb::PdbImplVC70
@ PdbImplVC70
Definition: RawConstants.h:28
InfoStreamBuilder.h