003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
lib
/
DebugInfo
/
PDB
/
Native
/
📁
..
📄
DbiModuleDescriptor.cpp
(2.5 KB)
📄
DbiModuleDescriptorBuilder.cpp
(6.63 KB)
📄
DbiModuleList.cpp
(8.3 KB)
📄
DbiStream.cpp
(12.8 KB)
📄
DbiStreamBuilder.cpp
(14.82 KB)
📄
EnumTables.cpp
(1.33 KB)
📄
GSIStreamBuilder.cpp
(17.23 KB)
📄
GlobalsStream.cpp
(6.56 KB)
📄
Hash.cpp
(2.39 KB)
📄
HashTable.cpp
(2.55 KB)
📄
InfoStream.cpp
(3.94 KB)
📄
InfoStreamBuilder.cpp
(2.67 KB)
📄
InjectedSourceStream.cpp
(2.31 KB)
📄
ModuleDebugStream.cpp
(4.74 KB)
📄
NamedStreamMap.cpp
(4.2 KB)
📄
NativeCompilandSymbol.cpp
(2.22 KB)
📄
NativeEnumGlobals.cpp
(1.87 KB)
📄
NativeEnumInjectedSources.cpp
(4.05 KB)
📄
NativeEnumLineNumbers.cpp
(1.44 KB)
📄
NativeEnumModules.cpp
(1.36 KB)
📄
NativeEnumTypes.cpp
(2.62 KB)
📄
NativeExeSymbol.cpp
(3.25 KB)
📄
NativeFunctionSymbol.cpp
(2.12 KB)
📄
NativeLineNumber.cpp
(1.88 KB)
📄
NativePublicSymbol.cpp
(1.92 KB)
📄
NativeRawSymbol.cpp
(14.98 KB)
📄
NativeSession.cpp
(12.36 KB)
📄
NativeSourceFile.cpp
(1.47 KB)
📄
NativeSymbolEnumerator.cpp
(4.24 KB)
📄
NativeTypeArray.cpp
(2.6 KB)
📄
NativeTypeBuiltin.cpp
(1.67 KB)
📄
NativeTypeEnum.cpp
(12.55 KB)
📄
NativeTypeFunctionSig.cpp
(7.3 KB)
📄
NativeTypePointer.cpp
(6.41 KB)
📄
NativeTypeTypedef.cpp
(1.05 KB)
📄
NativeTypeUDT.cpp
(6.93 KB)
📄
NativeTypeVTShape.cpp
(1.42 KB)
📄
PDBFile.cpp
(16.2 KB)
📄
PDBFileBuilder.cpp
(11 KB)
📄
PDBStringTable.cpp
(4.53 KB)
📄
PDBStringTableBuilder.cpp
(6.88 KB)
📄
PublicsStream.cpp
(3.89 KB)
📄
RawError.cpp
(2.13 KB)
📄
SymbolCache.cpp
(22.39 KB)
📄
SymbolStream.cpp
(1.4 KB)
📄
TpiHashing.cpp
(4.32 KB)
📄
TpiStream.cpp
(7.85 KB)
📄
TpiStreamBuilder.cpp
(6.32 KB)
Editing: DbiModuleDescriptorBuilder.cpp
//===- DbiModuleDescriptorBuilder.cpp - PDB Mod Info Creation ---*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/BinaryFormat/COFF.h" #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" #include "llvm/DebugInfo/MSF/MSFBuilder.h" #include "llvm/DebugInfo/MSF/MSFCommon.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" #include "llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h" #include "llvm/DebugInfo/PDB/Native/RawConstants.h" #include "llvm/DebugInfo/PDB/Native/RawError.h" #include "llvm/Support/BinaryStreamWriter.h" using namespace llvm; using namespace llvm::codeview; using namespace llvm::msf; using namespace llvm::pdb; static uint32_t calculateDiSymbolStreamSize(uint32_t SymbolByteSize, uint32_t C13Size) { uint32_t Size = sizeof(uint32_t); // Signature Size += alignTo(SymbolByteSize, 4); // Symbol Data Size += 0; // TODO: Layout.C11Bytes Size += C13Size; // C13 Debug Info Size Size += sizeof(uint32_t); // GlobalRefs substream size (always 0) Size += 0; // GlobalRefs substream bytes return Size; } DbiModuleDescriptorBuilder::DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex, msf::MSFBuilder &Msf) : MSF(Msf), ModuleName(std::string(ModuleName)) { ::memset(&Layout, 0, sizeof(Layout)); Layout.Mod = ModIndex; } DbiModuleDescriptorBuilder::~DbiModuleDescriptorBuilder() {} uint16_t DbiModuleDescriptorBuilder::getStreamIndex() const { return Layout.ModDiStream; } void DbiModuleDescriptorBuilder::setObjFileName(StringRef Name) { ObjFileName = std::string(Name); } void DbiModuleDescriptorBuilder::setPdbFilePathNI(uint32_t NI) { PdbFilePathNI = NI; } void DbiModuleDescriptorBuilder::setFirstSectionContrib( const SectionContrib &SC) { Layout.SC = SC; } void DbiModuleDescriptorBuilder::addSymbol(CVSymbol Symbol) { // Defer to the bulk API. It does the same thing. addSymbolsInBulk(Symbol.data()); } void DbiModuleDescriptorBuilder::addSymbolsInBulk( ArrayRef<uint8_t> BulkSymbols) { // Do nothing for empty runs of symbols. if (BulkSymbols.empty()) return; Symbols.push_back(BulkSymbols); // Symbols written to a PDB file are required to be 4 byte aligned. The same // is not true of object files. assert(BulkSymbols.size() % alignOf(CodeViewContainer::Pdb) == 0 && "Invalid Symbol alignment!"); SymbolByteSize += BulkSymbols.size(); } void DbiModuleDescriptorBuilder::addSourceFile(StringRef Path) { SourceFiles.push_back(std::string(Path)); } uint32_t DbiModuleDescriptorBuilder::calculateC13DebugInfoSize() const { uint32_t Result = 0; for (const auto &Builder : C13Builders) { Result += Builder.calculateSerializedLength(); } return Result; } uint32_t DbiModuleDescriptorBuilder::calculateSerializedLength() const { uint32_t L = sizeof(Layout); uint32_t M = ModuleName.size() + 1; uint32_t O = ObjFileName.size() + 1; return alignTo(L + M + O, sizeof(uint32_t)); } void DbiModuleDescriptorBuilder::finalize() { Layout.FileNameOffs = 0; // TODO: Fix this Layout.Flags = 0; // TODO: Fix this Layout.C11Bytes = 0; Layout.C13Bytes = calculateC13DebugInfoSize(); (void)Layout.Mod; // Set in constructor (void)Layout.ModDiStream; // Set in finalizeMsfLayout Layout.NumFiles = SourceFiles.size(); Layout.PdbFilePathNI = PdbFilePathNI; Layout.SrcFileNameNI = 0; // This value includes both the signature field as well as the record bytes // from the symbol stream. Layout.SymBytes = Layout.ModDiStream == kInvalidStreamIndex ? 0 : getNextSymbolOffset(); } Error DbiModuleDescriptorBuilder::finalizeMsfLayout() { this->Layout.ModDiStream = kInvalidStreamIndex; uint32_t C13Size = calculateC13DebugInfoSize(); if (!C13Size && !SymbolByteSize) return Error::success(); auto ExpectedSN = MSF.addStream(calculateDiSymbolStreamSize(SymbolByteSize, C13Size)); if (!ExpectedSN) return ExpectedSN.takeError(); Layout.ModDiStream = *ExpectedSN; return Error::success(); } Error DbiModuleDescriptorBuilder::commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout, WritableBinaryStreamRef MsfBuffer) { // We write the Modi record to the `ModiWriter`, but we additionally write its // symbol stream to a brand new stream. if (auto EC = ModiWriter.writeObject(Layout)) return EC; if (auto EC = ModiWriter.writeCString(ModuleName)) return EC; if (auto EC = ModiWriter.writeCString(ObjFileName)) return EC; if (auto EC = ModiWriter.padToAlignment(sizeof(uint32_t))) return EC; if (Layout.ModDiStream != kInvalidStreamIndex) { auto NS = WritableMappedBlockStream::createIndexedStream( MsfLayout, MsfBuffer, Layout.ModDiStream, MSF.getAllocator()); WritableBinaryStreamRef Ref(*NS); BinaryStreamWriter SymbolWriter(Ref); // Write the symbols. if (auto EC = SymbolWriter.writeInteger<uint32_t>(COFF::DEBUG_SECTION_MAGIC)) return EC; for (ArrayRef<uint8_t> Syms : Symbols) { if (auto EC = SymbolWriter.writeBytes(Syms)) return EC; } assert(SymbolWriter.getOffset() % alignOf(CodeViewContainer::Pdb) == 0 && "Invalid debug section alignment!"); // TODO: Write C11 Line data for (const auto &Builder : C13Builders) { if (auto EC = Builder.commit(SymbolWriter, CodeViewContainer::Pdb)) return EC; } // TODO: Figure out what GlobalRefs substream actually is and populate it. if (auto EC = SymbolWriter.writeInteger<uint32_t>(0)) return EC; if (SymbolWriter.bytesRemaining() > 0) return make_error<RawError>(raw_error_code::stream_too_long); } return Error::success(); } void DbiModuleDescriptorBuilder::addDebugSubsection( std::shared_ptr<DebugSubsection> Subsection) { assert(Subsection); C13Builders.push_back(DebugSubsectionRecordBuilder(std::move(Subsection))); } void DbiModuleDescriptorBuilder::addDebugSubsection( const DebugSubsectionRecord &SubsectionContents) { C13Builders.push_back(DebugSubsectionRecordBuilder(SubsectionContents)); }
Upload File
Create Folder