1//===- DbiModuleDescriptorBuilder.cpp - PDB Mod Info Creation ---*- C++ -*-===// 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 7//===----------------------------------------------------------------------===// 36Size += 0;
// TODO: Layout.C11Bytes 37Size += C13Size;
// C13 Debug Info Size 38Size +=
sizeof(
uint32_t);
// GlobalRefs substream size (always 0) 39Size += 0;
// GlobalRefs substream bytes 47 ::memset(&Layout, 0,
sizeof(Layout));
48 Layout.
Mod = ModIndex;
58 ObjFileName = std::string(
Name);
71// Defer to the bulk API. It does the same thing. 77// Do nothing for empty runs of symbols. 78if (BulkSymbols.
empty())
82// Symbols written to a PDB file are required to be 4 byte aligned. The same 83// is not true of object files. 85"Invalid Symbol alignment!");
86 SymbolByteSize += BulkSymbols.
size();
94// Symbols written to a PDB file are required to be 4 byte aligned. The same 95// is not true of object files. 97"Invalid Symbol alignment!");
98 SymbolByteSize += SymLength;
101void DbiModuleDescriptorBuilder::addSourceFile(
StringRefPath) {
105uint32_t DbiModuleDescriptorBuilder::calculateC13DebugInfoSize()
const{
107for (
constauto &Builder : C13Builders) {
108 Result += Builder.calculateSerializedLength();
122 Layout.
Flags = 0;
// TODO: Fix this 124 Layout.
C13Bytes = calculateC13DebugInfoSize();
125 (void)Layout.
Mod;
// Set in constructor 126 (
void)Layout.
ModDiStream;
// Set in finalizeMsfLayout 131// This value includes both the signature field as well as the record bytes 132// from the symbol stream. 139uint32_t C13Size = calculateC13DebugInfoSize();
140if (!C13Size && !SymbolByteSize)
145return ExpectedSN.takeError();
151// We write the Modi record to the `ModiWriter`, but we additionally write its 152// symbol stream to a brand new stream. 177if (
Sym.NeedsToBeMerged) {
179if (
autoEC = MergeSymsCallback(MergeSymsCtx,
Sym.SymPtr, SymbolWriter))
187// Apply the string table fixups. 188auto SavedOffset = SymbolWriter.
getOffset();
197"Invalid debug section alignment!");
198// TODO: Write C11 Line data 199for (
constauto &Builder : C13Builders) {
200if (
autoEC = Builder.commit(SymbolWriter, CodeViewContainer::Pdb))
204// TODO: Figure out what GlobalRefs substream actually is and populate it. 214 std::shared_ptr<DebugSubsection> Subsection) {
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static uint32_t calculateDiSymbolStreamSize(uint32_t SymbolByteSize, uint32_t C13Size)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
Provides write only access to a subclass of WritableBinaryStream.
Error writeCString(StringRef Str)
Write the string Str to the underlying stream followed by a null terminator.
uint64_t getOffset() const
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
uint64_t bytesRemaining() const
Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
void setOffset(uint64_t Off)
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
Error padToAlignment(uint32_t Align)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
StringRef - Represent a constant reference to a string, i.e.
CVRecord is a fat pointer (base + size pair) to a symbol or type record.
BumpPtrAllocator & getAllocator()
Expected< uint32_t > addStream(uint32_t Size, ArrayRef< uint32_t > Blocks)
Add a stream to the MSF file with the given size, occupying the given list of blocks.
static std::unique_ptr< WritableMappedBlockStream > createIndexedStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, uint32_t StreamIndex, BumpPtrAllocator &Allocator)
void addUnmergedSymbols(void *SymSrc, uint32_t SymLength)
void setObjFileName(StringRef Name)
void addDebugSubsection(std::shared_ptr< codeview::DebugSubsection > Subsection)
~DbiModuleDescriptorBuilder()
void setFirstSectionContrib(const SectionContrib &SC)
Error finalizeMsfLayout()
uint16_t getStreamIndex() const
void addSymbol(codeview::CVSymbol Symbol)
void setPdbFilePathNI(uint32_t NI)
Error commitSymbolStream(const msf::MSFLayout &MsfLayout, WritableBinaryStreamRef MsfBuffer)
Commit the accumulated symbols to the module symbol stream.
Error commit(BinaryStreamWriter &ModiWriter)
Commit the DBI descriptor to the DBI stream.
uint32_t getNextSymbolOffset() const
Return the offset within the module symbol stream of the next symbol record passed to addSymbol.
void addSymbolsInBulk(ArrayRef< uint8_t > BulkSymbols)
DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex, msf::MSFBuilder &Msf)
uint32_t calculateSerializedLength() const
uint32_t alignOf(CodeViewContainer Container)
const uint16_t kInvalidStreamIndex
This is an optimization pass for GlobalISel generic memory operations.
@ Ref
The access may reference the value stored in memory.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Implement std::hash so that hash_code can be used in STL containers.
support::ulittle32_t PdbFilePathNI
Name Index for path to compiler PDB.
support::ulittle32_t FileNameOffs
Array of [0..NumFiles) DBI name buffer offsets.
support::ulittle16_t ModDiStream
Stream Number of module debug info.
support::ulittle16_t NumFiles
Number of files contributing to this module.
support::ulittle16_t Flags
See ModInfoFlags definition.
support::ulittle32_t SrcFileNameNI
Name Index for src file name.
SectionContrib SC
First section contribution of this module.
support::ulittle32_t C13Bytes
Size of C13 line number info in above stream.
support::ulittle32_t SymBytes
Size of local symbol debug info in above stream.
support::ulittle32_t C11Bytes
Size of C11 line number info in above stream.
support::ulittle32_t Mod
Currently opened module.
Represents a string table reference at some offset in the module symbol stream.