LLVM 22.0.0git
|
This class links debug info. More...
#include "DWARFLinker/Parallel/DWARFLinkerImpl.h"
Classes | |
struct | DebugInfoSize |
Hold the input and output of the debug info size in bytes. More... | |
struct | LinkContext |
Keeps track of data associated with one object during linking. More... |
Public Member Functions | |
DWARFLinkerImpl (MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler) | |
void | addObjectFile (DWARFFile &File, ObjFileLoaderTy Loader=nullptr, CompileUnitHandlerTy OnCUDieLoaded=[](const DWARFUnit &) {}) override |
Add object file to be linked. | |
Error | link () override |
Link debug info for added files. | |
void | setOutputDWARFHandler (const Triple &TargetTriple, SectionHandlerTy SectionHandler) override |
Set output DWARF handler. | |
void | setVerbosity (bool Verbose) override |
Allows to generate log of linking process to the standard output. | |
void | setStatistics (bool Statistics) override |
Print statistics to standard output. | |
void | setVerifyInputDWARF (bool Verify) override |
Verify the input DWARF. | |
void | setNoODR (bool NoODR) override |
Do not unique types according to ODR. | |
void | setUpdateIndexTablesOnly (bool UpdateIndexTablesOnly) override |
Update index tables only(do not modify rest of DWARF). | |
void | setAllowNonDeterministicOutput (bool AllowNonDeterministicOutput) override |
Allow generating valid, but non-deterministic output. | |
void | setKeepFunctionForStatic (bool KeepFunctionForStatic) override |
Set to keep the enclosing function for a static variable. | |
void | setNumThreads (unsigned NumThreads) override |
Use specified number of threads for parallel files linking. | |
void | addAccelTableKind (AccelTableKind Kind) override |
Add kind of accelerator tables to be generated. | |
void | setPrependPath (StringRef Ppath) override |
Set prepend path for clang modules. | |
void | setEstimatedObjfilesAmount (unsigned ObjFilesNum) override |
Set estimated objects files amount, for preliminary data allocation. | |
void | setInputVerificationHandler (InputVerificationHandlerTy Handler) override |
Set verification handler which would be used to report verification errors. | |
void | setSwiftInterfacesMap (SwiftInterfacesMapTy *Map) override |
Set map for Swift interfaces. | |
void | setObjectPrefixMap (ObjectPrefixMapTy *Map) override |
Set prefix map for objects. | |
Error | setTargetDWARFVersion (uint16_t TargetDWARFVersion) override |
Set target DWARF version. | |
Public Member Functions inherited from llvm::dwarf_linker::parallel::DWARFLinker | |
virtual | ~DWARFLinker ()=default |
Public Member Functions inherited from llvm::dwarf_linker::DWARFLinkerBase | |
virtual | ~DWARFLinkerBase ()=default |
Protected Types | |
enum | StringDestinationKind : uint8_t { DebugStr , DebugLineStr } |
Protected Member Functions | |
void | verifyInput (const DWARFFile &File) |
Verify input DWARF file. | |
Error | validateAndUpdateOptions () |
Validate specified options. | |
void | glueCompileUnitsAndWriteToTheOutput () |
Take already linked compile units and glue them into single file. | |
void | assignOffsets () |
Enumerate all compile units and assign offsets to their sections and strings. | |
void | assignOffsetsToSections () |
Enumerate all compile units and assign offsets to their sections. | |
void | assignOffsetsToStrings () |
Enumerate all compile units and assign offsets to their strings. | |
void | printStatistic () |
Print statistic for processed Debug Info. | |
void | forEachOutputString (function_ref< void(StringDestinationKind, const StringEntry *)> StringHandler) |
Enumerates all strings. | |
void | forEachObjectSectionsSet (function_ref< void(OutputSections &SectionsSet)> SectionsSetHandler) |
Enumerates sections for modules, invariant for object files, compile units. | |
void | forEachCompileAndTypeUnit (function_ref< void(DwarfUnit *CU)> UnitHandler) |
Enumerates all compile and type units. | |
void | forEachCompileUnit (function_ref< void(CompileUnit *CU)> UnitHandler) |
Enumerates all comple units. | |
void | patchOffsetsAndSizes () |
Enumerates all patches and update them with the correct values. | |
void | emitCommonSectionsAndWriteCompileUnitsToTheOutput () |
Emit debug sections common for all input files. | |
void | emitAppleAcceleratorSections (const Triple &TargetTriple) |
Emit apple accelerator sections. | |
void | emitDWARFv5DebugNamesSection (const Triple &TargetTriple) |
Emit .debug_names section. | |
void | emitStringSections () |
Emit string sections. | |
void | cleanupDataAfterDWARFOutputIsWritten () |
Cleanup data(string pools) after output sections are generated. | |
void | writeCompileUnitsToTheOutput () |
Enumerate all compile units and put their data into the output stream. | |
void | writeCommonSectionsToTheOutput () |
Enumerate common sections and put their data into the output stream. |
Protected Attributes | |
std::atomic< size_t > | UniqueUnitID |
Unique ID for compile unit. | |
StringMap< uint64_t > | ClangModules |
Mapping the PCM filename to the DwoId. | |
std::mutex | ClangModulesMutex |
std::unique_ptr< TypeUnit > | ArtificialTypeUnit |
Type unit. | |
LinkingGlobalData | GlobalData |
StringEntryToDwarfStringPoolEntryMap | DebugStrStrings |
DwarfStringPoolEntries for .debug_str section. | |
StringEntryToDwarfStringPoolEntryMap | DebugLineStrStrings |
DwarfStringPoolEntries for .debug_line_str section. | |
SmallVector< std::unique_ptr< LinkContext > > | ObjectContexts |
Keeps all linking contexts. | |
OutputSections | CommonSections |
Common sections. | |
SectionHandlerTy | SectionHandler = nullptr |
Hanler for output sections. | |
uint64_t | OverallNumberOfCU = 0 |
Overall compile units number. |
Friends | |
class | DependencyTracker |
Additional Inherited Members | |
Public Types inherited from llvm::dwarf_linker::DWARFLinkerBase | |
enum class | OutputFileType : uint8_t { Object , Assembly } |
Type of output file. More... | |
enum class | AccelTableKind : uint8_t { Apple , Pub , DebugNames } |
The kind of accelerator tables to be emitted. More... | |
using | MessageHandlerTy |
using | ObjFileLoaderTy |
using | InputVerificationHandlerTy |
using | ObjectPrefixMapTy = std::map<std::string, std::string> |
using | CompileUnitHandlerTy = function_ref<void(const DWARFUnit &Unit)> |
using | SwiftInterfacesMapTy = std::map<std::string, std::string> |
Static Public Member Functions inherited from llvm::dwarf_linker::parallel::DWARFLinker | |
static LLVM_ABI std::unique_ptr< DWARFLinker > | createLinker (MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler) |
Creates dwarf linker instance. |
This class links debug info.
Definition at line 26 of file DWARFLinkerImpl.h.
Enumerator | |
---|---|
DebugStr | |
DebugLineStr |
Definition at line 293 of file DWARFLinkerImpl.h.
DWARFLinkerImpl::DWARFLinkerImpl | ( | MessageHandlerTy | ErrorHandler, |
MessageHandlerTy | WarningHandler ) |
Definition at line 21 of file DWARFLinkerImpl.cpp.
References CommonSections, DebugLineStrStrings, DebugStrStrings, ErrorHandler, GlobalData, and UniqueUnitID.
|
overridevirtual |
Add object file to be linked.
Pre-load compile unit die. Call OnCUDieLoaded
for each compile unit die. If specified File
has reference to the Clang module then such module would be pre-loaded by Loader
for !Update case.
Implements llvm::dwarf_linker::DWARFLinkerBase.
Definition at line 61 of file DWARFLinkerImpl.cpp.
References ClangModules, GlobalData, ObjectContexts, OverallNumberOfCU, and UniqueUnitID.
|
protected |
Enumerate all compile units and assign offsets to their sections and strings.
Definition at line 944 of file DWARFLinkerImpl.cpp.
References assignOffsetsToSections(), assignOffsetsToStrings(), and llvm::parallel::TaskGroup::spawn().
Referenced by glueCompileUnitsAndWriteToTheOutput().
|
protected |
Enumerate all compile units and assign offsets to their sections.
Definition at line 987 of file DWARFLinkerImpl.cpp.
References llvm::dwarf_linker::parallel::OutputSections::assignSectionsOffsetAndAccumulateSize(), and forEachObjectSectionsSet().
Referenced by assignOffsets().
|
protected |
Enumerate all compile units and assign offsets to their strings.
Definition at line 950 of file DWARFLinkerImpl.cpp.
References assert(), DebugLineStr, DebugLineStrStrings, DebugStr, DebugStrStrings, forEachOutputString(), and llvm::String.
Referenced by assignOffsets().
|
protected |
Cleanup data(string pools) after output sections are generated.
Definition at line 1398 of file DWARFLinkerImpl.cpp.
References DebugLineStrStrings, DebugStrStrings, and GlobalData.
Referenced by glueCompileUnitsAndWriteToTheOutput().
Emit apple accelerator sections.
Definition at line 1208 of file DWARFLinkerImpl.cpp.
References llvm::dwarf_linker::AppleNames, llvm::dwarf_linker::AppleNamespaces, llvm::dwarf_linker::AppleObjC, llvm::dwarf_linker::AppleTypes, CommonSections, llvm::consumeError(), llvm::dwarf_linker::DebugInfo, DebugStrStrings, llvm::dwarf::DW_FLAG_type_implementation, Emitter, forEachCompileAndTypeUnit(), llvm_unreachable, llvm::dwarf_linker::parallel::DwarfUnit::Name, llvm::dwarf_linker::parallel::DwarfUnit::Namespace, llvm::dwarf_linker::parallel::DwarfUnit::None, llvm::dwarf_linker::parallel::DwarfUnit::ObjC, llvm::dwarf_linker::DWARFLinkerBase::Object, llvm::dwarf_linker::parallel::SectionDescriptor::OS, llvm::dwarf_linker::parallel::SectionDescriptor::setSizesForSectionCreatedByAsmPrinter(), and llvm::dwarf_linker::parallel::DwarfUnit::Type.
Referenced by emitCommonSectionsAndWriteCompileUnitsToTheOutput().
|
protected |
Emit debug sections common for all input files.
Definition at line 1113 of file DWARFLinkerImpl.cpp.
References llvm::dwarf_linker::DWARFLinkerBase::Apple, llvm::dwarf_linker::AppleNames, llvm::dwarf_linker::AppleNamespaces, llvm::dwarf_linker::AppleObjC, llvm::dwarf_linker::AppleTypes, CommonSections, llvm::dwarf_linker::DebugLineStr, llvm::dwarf_linker::DebugNames, llvm::dwarf_linker::DWARFLinkerBase::DebugNames, llvm::dwarf_linker::DebugStr, emitAppleAcceleratorSections(), emitDWARFv5DebugNamesSection(), emitStringSections(), GlobalData, llvm::is_contained(), llvm::parallel::TaskGroup::spawn(), and writeCompileUnitsToTheOutput().
Referenced by glueCompileUnitsAndWriteToTheOutput().
Emit .debug_names section.
Definition at line 1338 of file DWARFLinkerImpl.cpp.
References CommonSections, llvm::consumeError(), llvm::dwarf_linker::DebugInfo, llvm::dwarf_linker::DebugNames, llvm::dwarf_linker::DWARFLinkerBase::DebugNames, DebugStrStrings, Emitter, forEachCompileAndTypeUnit(), llvm::dwarf_linker::parallel::DwarfUnit::Name, llvm::dwarf_linker::parallel::DwarfUnit::Namespace, llvm::dwarf_linker::DWARFLinkerBase::Object, llvm::dwarf_linker::parallel::SectionDescriptor::OS, llvm::dwarf_linker::parallel::SectionDescriptor::setSizesForSectionCreatedByAsmPrinter(), and llvm::dwarf_linker::parallel::DwarfUnit::Type.
Referenced by emitCommonSectionsAndWriteCompileUnitsToTheOutput().
|
protected |
Emit string sections.
Definition at line 1159 of file DWARFLinkerImpl.cpp.
References assert(), CommonSections, llvm::dwarf_linker::DebugLineStr, DebugLineStr, DebugLineStrStrings, llvm::dwarf_linker::DebugStr, DebugStr, DebugStrStrings, forEachOutputString(), llvm::DwarfStringPoolEntry::isIndexed(), llvm::DwarfStringPoolEntry::Offset, llvm::StringRef::size(), llvm::DwarfStringPoolEntryWithExtString::String, and llvm::String.
Referenced by emitCommonSectionsAndWriteCompileUnitsToTheOutput().
|
protected |
Enumerates all compile and type units.
Definition at line 1071 of file DWARFLinkerImpl.cpp.
References ArtificialTypeUnit, ObjectContexts, llvm::dwarf_linker::parallel::CompileUnit::Skipped, and llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::RefModuleUnit::Unit.
Referenced by emitAppleAcceleratorSections(), and emitDWARFv5DebugNamesSection().
|
protected |
Enumerates all comple units.
Definition at line 1089 of file DWARFLinkerImpl.cpp.
References ObjectContexts, llvm::dwarf_linker::parallel::CompileUnit::Skipped, and llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::RefModuleUnit::Unit.
Referenced by forEachOutputString().
|
protected |
Enumerates sections for modules, invariant for object files, compile units.
Definition at line 1047 of file DWARFLinkerImpl.cpp.
References ArtificialTypeUnit, ObjectContexts, llvm::dwarf_linker::parallel::CompileUnit::Skipped, and llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::RefModuleUnit::Unit.
Referenced by assignOffsetsToSections(), patchOffsetsAndSizes(), and writeCompileUnitsToTheOutput().
|
protected |
Enumerates all strings.
Definition at line 995 of file DWARFLinkerImpl.cpp.
References ArtificialTypeUnit, DebugLineStr, DebugStr, forEachCompileUnit(), llvm::dwarf_linker::parallel::DebugStrPatch::String, and llvm::String.
Referenced by assignOffsetsToStrings(), and emitStringSections().
|
protected |
Take already linked compile units and glue them into single file.
Definition at line 851 of file DWARFLinkerImpl.cpp.
References ArtificialTypeUnit, assert(), assignOffsets(), cleanupDataAfterDWARFOutputIsWritten(), emitCommonSectionsAndWriteCompileUnitsToTheOutput(), GlobalData, patchOffsetsAndSizes(), printStatistic(), SectionHandler, and writeCommonSectionsToTheOutput().
Referenced by link().
|
overridevirtual |
Link debug info for added files.
Implements llvm::dwarf_linker::DWARFLinkerBase.
Definition at line 89 of file DWARFLinkerImpl.cpp.
References llvm::dwarf::FormParams::AddrSize, ArtificialTypeUnit, llvm::ThreadPoolInterface::async(), llvm::big, llvm::DIDumpOptions::ChildRecurseDepth, CommonSections, llvm::dwarf::DWARF32, llvm::DWARFDie::find(), GlobalData, glueCompileUnitsAndWriteToTheOutput(), llvm::hardware_concurrency(), llvm::dwarf_linker::parallel::isODRLanguage(), llvm::little, llvm::native, ObjectContexts, llvm::optimal_concurrency(), llvm::outs(), OverallNumberOfCU, llvm::parallel::TaskGroup::spawn(), llvm::parallel::strategy, llvm::Error::success(), llvm::dwarf::toUnsigned(), UniqueUnitID, validateAndUpdateOptions(), llvm::DIDumpOptions::Verbose, verifyInput(), and llvm::SingleThreadExecutor::wait().
|
protected |
Enumerates all patches and update them with the correct values.
Definition at line 1104 of file DWARFLinkerImpl.cpp.
References llvm::dwarf_linker::parallel::OutputSections::applyPatches(), ArtificialTypeUnit, DebugLineStrStrings, DebugStrStrings, llvm::dwarf_linker::parallel::OutputSections::forEach(), and forEachObjectSectionsSet().
Referenced by glueCompileUnitsAndWriteToTheOutput().
|
protected |
Print statistic for processed Debug Info.
Definition at line 880 of file DWARFLinkerImpl.cpp.
References llvm::dwarf_linker::DebugInfo, llvm::sys::path::filename(), llvm::formatv(), ObjectContexts, llvm::outs(), Size, and llvm::sort().
Referenced by glueCompileUnitsAndWriteToTheOutput().
|
inlineoverridevirtual |
Set output DWARF handler.
May be not set if output generation is not necessary.
Implements llvm::dwarf_linker::parallel::DWARFLinker.
Definition at line 47 of file DWARFLinkerImpl.h.
References GlobalData, and SectionHandler.
|
protected |
Validate specified options.
Definition at line 236 of file DWARFLinkerImpl.cpp.
References llvm::createStringError(), GlobalData, and llvm::Error::success().
Referenced by link().
Verify input DWARF file.
Definition at line 224 of file DWARFLinkerImpl.cpp.
References assert(), GlobalData, llvm::DIDumpOptions::noImplicitRecursion(), and llvm::raw_string_ostream::str().
Referenced by link().
|
protected |
Enumerate common sections and put their data into the output stream.
Definition at line 1414 of file DWARFLinkerImpl.cpp.
References CommonSections, and SectionHandler.
Referenced by glueCompileUnitsAndWriteToTheOutput().
|
protected |
Enumerate all compile units and put their data into the output stream.
Definition at line 1404 of file DWARFLinkerImpl.cpp.
References llvm::dwarf_linker::parallel::OutputSections::forEach(), forEachObjectSectionsSet(), and SectionHandler.
Referenced by emitCommonSectionsAndWriteCompileUnitsToTheOutput().
|
friend |
Definition at line 157 of file DWARFLinkerImpl.h.
References DependencyTracker.
Referenced by DependencyTracker.