LLVM 20.0.0git
Classes | Public Member Functions | Static Public Member Functions | List of all members
llvm::dwarf_linker::classic::DWARFLinker Class Reference

The core of the Dwarf linking logic. More...

#include "llvm/DWARFLinker/Classic/DWARFLinker.h"

Inheritance diagram for llvm::dwarf_linker::classic::DWARFLinker:
Inheritance graph
[legend]

Public Member Functions

 DWARFLinker (MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler, std::function< StringRef(StringRef)> StringsTranslator)
 
void setOutputDWARFEmitter (DwarfEmitter *Emitter)
 Set output DWARF emitter.
 
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 objFiles. Object files are linked all together.
 
void setVerbosity (bool Verbose) override
 A number of methods setting various linking options:
 
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 Update) override
 Update index tables only(do not modify rest of DWARF).
 
void setAllowNonDeterministicOutput (bool) override
 Allow generating valid, but non-deterministic output.
 
void setKeepFunctionForStatic (bool KeepFunctionForStatic) override
 Set whether 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::DWARFLinkerBase
virtual ~DWARFLinkerBase ()=default
 
virtual void addObjectFile (DWARFFile &File, ObjFileLoaderTy Loader=nullptr, CompileUnitHandlerTy OnCUDieLoaded=[](const DWARFUnit &) {})=0
 Add an object file to be linked.
 
virtual Error link ()=0
 Link the debug info for all object files added through calls to addObjectFile.
 
virtual void setVerbosity (bool Verbose)=0
 A number of methods setting various linking options: Enable logging to standard output.
 
virtual void setStatistics (bool Statistics)=0
 Print statistics to standard output.
 
virtual void setVerifyInputDWARF (bool Verify)=0
 Verify the input DWARF.
 
virtual void setNoODR (bool NoODR)=0
 Do not unique types according to ODR.
 
virtual void setUpdateIndexTablesOnly (bool Update)=0
 Update index tables only (do not modify rest of DWARF).
 
virtual void setAllowNonDeterministicOutput (bool)=0
 Allows generating non-deterministic output in exchange for more parallelism.
 
virtual void setKeepFunctionForStatic (bool KeepFunctionForStatic)=0
 Set whether to keep the enclosing function for a static variable.
 
virtual void setNumThreads (unsigned NumThreads)=0
 Use specified number of threads for parallel files linking.
 
virtual void addAccelTableKind (AccelTableKind Kind)=0
 Add kind of accelerator tables to be generated.
 
virtual void setPrependPath (StringRef Ppath)=0
 Set prepend path for clang modules.
 
virtual void setEstimatedObjfilesAmount (unsigned ObjFilesNum)=0
 Set estimated objects files amount, for preliminary data allocation.
 
virtual void setInputVerificationHandler (InputVerificationHandlerTy Handler)=0
 Set verification handler used to report verification errors.
 
virtual void setSwiftInterfacesMap (SwiftInterfacesMapTy *Map)=0
 Set map for Swift interfaces.
 
virtual void setObjectPrefixMap (ObjectPrefixMapTy *Map)=0
 Set prefix map for objects.
 
virtual Error setTargetDWARFVersion (uint16_t TargetDWARFVersion)=0
 Set target DWARF version.
 

Static Public Member Functions

static std::unique_ptr< DWARFLinkercreateLinker (MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler, std::function< StringRef(StringRef)> StringsTranslator=nullptr)
 

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 = std::function< void(const Twine &Warning, StringRef Context, const DWARFDie *DIE)>
 
using ObjFileLoaderTy = std::function< ErrorOr< DWARFFile & >(StringRef ContainerName, StringRef Path)>
 
using InputVerificationHandlerTy = std::function< void(const DWARFFile &File, llvm::StringRef Output)>
 
using ObjectPrefixMapTy = std::map< std::string, std::string >
 
using CompileUnitHandlerTy = function_ref< void(const DWARFUnit &Unit)>
 
using SwiftInterfacesMapTy = std::map< std::string, std::string >
 

Detailed Description

The core of the Dwarf linking logic.

The generation of the dwarf information from the object files will be driven by the selection of 'root DIEs', which are DIEs that describe variables or functions that resolves to the corresponding code section(and thus have entries in the Addresses map). All the debug information that will be generated(the DIEs, but also the line tables, ranges, ...) is derived from that set of root DIEs.

The root DIEs are identified because they contain relocations that points to code section(the low_pc for a function, the location for a variable). These relocations are called ValidRelocs in the AddressesInfo and are gathered as a very first step when we start processing a object file.

Definition at line 211 of file DWARFLinker.h.

Constructor & Destructor Documentation

◆ DWARFLinker()

llvm::dwarf_linker::classic::DWARFLinker::DWARFLinker ( MessageHandlerTy  ErrorHandler,
MessageHandlerTy  WarningHandler,
std::function< StringRef(StringRef)>  StringsTranslator 
)
inline

Definition at line 213 of file DWARFLinker.h.

Member Function Documentation

◆ addAccelTableKind()

void llvm::dwarf_linker::classic::DWARFLinker::addAccelTableKind ( AccelTableKind  Kind)
inlineoverridevirtual

Add kind of accelerator tables to be generated.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 281 of file DWARFLinker.h.

References assert(), and llvm::is_contained().

◆ addObjectFile()

void llvm::DWARFLinker::addObjectFile ( DWARFFile File,
ObjFileLoaderTy  Loader = nullptr,
CompileUnitHandlerTy  OnCUDieLoaded = [](const DWARFUnit &) {} 
)
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.

Precondition
NoODR, Update options should be set before call to addObjectFile.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 2692 of file DWARFLinker.cpp.

References LLVM_UNLIKELY.

◆ createLinker()

static std::unique_ptr< DWARFLinker > llvm::dwarf_linker::classic::DWARFLinker::createLinker ( MessageHandlerTy  ErrorHandler,
MessageHandlerTy  WarningHandler,
std::function< StringRef(StringRef)>  StringsTranslator = nullptr 
)
inlinestatic

Definition at line 218 of file DWARFLinker.h.

◆ link()

Error llvm::DWARFLinker::link ( )
overridevirtual

Link debug info for added objFiles. Object files are linked all together.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 2713 of file DWARFLinker.cpp.

References llvm::analyzeContextInfo(), llvm::dwarf_linker::DWARFLinkerBase::Apple, assert(), llvm::ThreadPoolInterface::async(), llvm::DIDumpOptions::ChildRecurseDepth, llvm::dwarf_linker::DWARFLinkerBase::DebugNames, E, llvm::dwarf_linker::classic::DwarfEmitter::emitAbbrevs(), llvm::dwarf_linker::classic::DwarfEmitter::emitAppleNames(), llvm::dwarf_linker::classic::DwarfEmitter::emitAppleNamespaces(), llvm::dwarf_linker::classic::DwarfEmitter::emitAppleObjc(), llvm::dwarf_linker::classic::DwarfEmitter::emitAppleTypes(), llvm::dwarf_linker::classic::DwarfEmitter::emitDebugNames(), llvm::dwarf_linker::classic::DwarfEmitter::emitLineStrings(), llvm::dwarf_linker::classic::DwarfEmitter::emitStringOffsets(), llvm::dwarf_linker::classic::DwarfEmitter::emitStrings(), llvm::sys::path::filename(), llvm::formatv(), llvm::dwarf_linker::classic::DwarfEmitter::getDebugInfoSectionSize(), llvm::getDebugInfoSize(), llvm::getPCMFile(), llvm::dwarf_linker::classic::DeclContextTree::getRoot(), llvm::dwarf_linker::IndexedValuesMap< T >::getValues(), llvm::hardware_concurrency(), I, LHS, LLVM_LIKELY, LLVM_UNLIKELY, llvm::outs(), llvm::dwarf_linker::DWARFLinkerBase::Pub, RHS, llvm::BitVector::set(), llvm::sort(), llvm::Error::success(), llvm::StringRef::take_back(), llvm::dwarf::toString(), llvm::DIDumpOptions::Verbose, llvm::verifyKeepChain(), llvm::SingleThreadExecutor::wait(), and llvm::Warning.

◆ setAllowNonDeterministicOutput()

void llvm::dwarf_linker::classic::DWARFLinker::setAllowNonDeterministicOutput ( bool  )
inlineoverridevirtual

Allow generating valid, but non-deterministic output.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 267 of file DWARFLinker.h.

◆ setEstimatedObjfilesAmount()

void llvm::dwarf_linker::classic::DWARFLinker::setEstimatedObjfilesAmount ( unsigned  ObjFilesNum)
inlineoverridevirtual

Set estimated objects files amount, for preliminary data allocation.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 290 of file DWARFLinker.h.

◆ setInputVerificationHandler()

void llvm::dwarf_linker::classic::DWARFLinker::setInputVerificationHandler ( InputVerificationHandlerTy  Handler)
inlineoverridevirtual

Set verification handler which would be used to report verification errors.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 297 of file DWARFLinker.h.

◆ setKeepFunctionForStatic()

void llvm::dwarf_linker::classic::DWARFLinker::setKeepFunctionForStatic ( bool  KeepFunctionForStatic)
inlineoverridevirtual

Set whether to keep the enclosing function for a static variable.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 271 of file DWARFLinker.h.

◆ setNoODR()

void llvm::dwarf_linker::classic::DWARFLinker::setNoODR ( bool  NoODR)
inlineoverridevirtual

Do not unique types according to ODR.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 259 of file DWARFLinker.h.

◆ setNumThreads()

void llvm::dwarf_linker::classic::DWARFLinker::setNumThreads ( unsigned  NumThreads)
inlineoverridevirtual

Use specified number of threads for parallel files linking.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 276 of file DWARFLinker.h.

◆ setObjectPrefixMap()

void llvm::dwarf_linker::classic::DWARFLinker::setObjectPrefixMap ( ObjectPrefixMapTy Map)
inlineoverridevirtual

Set prefix map for objects.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 307 of file DWARFLinker.h.

◆ setOutputDWARFEmitter()

void llvm::dwarf_linker::classic::DWARFLinker::setOutputDWARFEmitter ( DwarfEmitter Emitter)
inline

Set output DWARF emitter.

Definition at line 226 of file DWARFLinker.h.

References Emitter.

◆ setPrependPath()

void llvm::dwarf_linker::classic::DWARFLinker::setPrependPath ( StringRef  Ppath)
inlineoverridevirtual

Set prepend path for clang modules.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 287 of file DWARFLinker.h.

◆ setStatistics()

void llvm::dwarf_linker::classic::DWARFLinker::setStatistics ( bool  Statistics)
inlineoverridevirtual

Print statistics to standard output.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 249 of file DWARFLinker.h.

◆ setSwiftInterfacesMap()

void llvm::dwarf_linker::classic::DWARFLinker::setSwiftInterfacesMap ( SwiftInterfacesMapTy Map)
inlineoverridevirtual

Set map for Swift interfaces.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 302 of file DWARFLinker.h.

◆ setTargetDWARFVersion()

Error llvm::dwarf_linker::classic::DWARFLinker::setTargetDWARFVersion ( uint16_t  TargetDWARFVersion)
inlineoverridevirtual

Set target DWARF version.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 312 of file DWARFLinker.h.

References llvm::createStringError(), and llvm::Error::success().

◆ setUpdateIndexTablesOnly()

void llvm::dwarf_linker::classic::DWARFLinker::setUpdateIndexTablesOnly ( bool  Update)
inlineoverridevirtual

Update index tables only(do not modify rest of DWARF).

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 262 of file DWARFLinker.h.

◆ setVerbosity()

void llvm::dwarf_linker::classic::DWARFLinker::setVerbosity ( bool  Verbose)
inlineoverridevirtual

A number of methods setting various linking options:

Allows to generate log of linking process to the standard output.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 246 of file DWARFLinker.h.

References llvm::Verbose.

◆ setVerifyInputDWARF()

void llvm::dwarf_linker::classic::DWARFLinker::setVerifyInputDWARF ( bool  Verify)
inlineoverridevirtual

Verify the input DWARF.

Implements llvm::dwarf_linker::DWARFLinkerBase.

Definition at line 254 of file DWARFLinker.h.

References Verify.


The documentation for this class was generated from the following files: