LLVM 18.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::DWARFLinker Class Reference

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

#include "llvm/DWARFLinker/DWARFLinker.h"

Public Types

enum class  OutputFileType { Object , Assembly }
 Type of output file. More...
 
enum class  AccelTableKind : uint8_t { Apple , Pub , DebugNames }
 The kind of accelerator tables we should emit. More...
 
typedef std::function< void(const Twine &Warning, StringRef Context, const DWARFDie *DIE)> messageHandler
 
typedef std::function< void(const DWARFFile &File, llvm::StringRef Output)> inputVerificationHandler
 
typedef std::function< ErrorOr< DWARFFile & >(StringRef ContainerName, StringRef Path)> objFileLoader
 

Public Member Functions

 DWARFLinker (messageHandler ErrorHandler, messageHandler WarningHandler, std::function< StringRef(StringRef)> StringsTranslator)
 
Error createEmitter (const Triple &TheTriple, OutputFileType FileType, raw_pwrite_stream &OutFile)
 
DwarfEmittergetEmitter ()
 
void addObjectFile (DWARFFile &File, objFileLoader Loader=nullptr, CompileUnitHandler OnCUDieLoaded=[](const DWARFUnit &) {})
 Add object file to be linked.
 
Error link ()
 Link debug info for added objFiles. Object files are linked all together.
 
void setVerbosity (bool Verbose)
 A number of methods setting various linking options:
 
void setStatistics (bool Statistics)
 Print statistics to standard output.
 
void setVerifyInputDWARF (bool Verify)
 Verify the input DWARF.
 
void setNoODR (bool NoODR)
 Do not unique types according to ODR.
 
void setUpdateIndexTablesOnly (bool Update)
 Update index tables only(do not modify rest of DWARF).
 
void setAllowNonDeterministicOutput (bool)
 Allow generating valid, but non-deterministic output.
 
void setKeepFunctionForStatic (bool KeepFunctionForStatic)
 Set whether to keep the enclosing function for a static variable.
 
void setNumThreads (unsigned NumThreads)
 Use specified number of threads for parallel files linking.
 
void addAccelTableKind (AccelTableKind Kind)
 Add kind of accelerator tables to be generated.
 
void setPrependPath (const std::string &Ppath)
 Set prepend path for clang modules.
 
void setEstimatedObjfilesAmount (unsigned ObjFilesNum)
 Set estimated objects files amount, for preliminary data allocation.
 
void setInputVerificationHandler (inputVerificationHandler Handler)
 Set verification handler which would be used to report verification errors.
 
void setSwiftInterfacesMap (swiftInterfacesMap *Map)
 Set map for Swift interfaces.
 
void setObjectPrefixMap (objectPrefixMap *Map)
 Set prefix map for objects.
 
Error setTargetDWARFVersion (uint16_t TargetDWARFVersion)
 Set target DWARF version.
 

Static Public Member Functions

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

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 337 of file DWARFLinker.h.

Member Typedef Documentation

◆ inputVerificationHandler

typedef std::function<void(const DWARFFile &File, llvm::StringRef Output)> llvm::DWARFLinker::inputVerificationHandler

Definition at line 367 of file DWARFLinker.h.

◆ messageHandler

typedef std::function<void(const Twine &Warning, StringRef Context, const DWARFDie *DIE)> llvm::DWARFLinker::messageHandler

Definition at line 341 of file DWARFLinker.h.

◆ objFileLoader

typedef std::function<ErrorOr<DWARFFile &>(StringRef ContainerName, StringRef Path)> llvm::DWARFLinker::objFileLoader

Definition at line 370 of file DWARFLinker.h.

Member Enumeration Documentation

◆ AccelTableKind

enum class llvm::DWARFLinker::AccelTableKind : uint8_t
strong

The kind of accelerator tables we should emit.

Enumerator
Apple 

.apple_names, .apple_namespaces, .apple_types, .apple_objc.

Pub 

.debug_pubnames, .debug_pubtypes

DebugNames 

.debug_names.

Definition at line 362 of file DWARFLinker.h.

◆ OutputFileType

Type of output file.

Enumerator
Object 
Assembly 

Definition at line 356 of file DWARFLinker.h.

Constructor & Destructor Documentation

◆ DWARFLinker()

llvm::DWARFLinker::DWARFLinker ( messageHandler  ErrorHandler,
messageHandler  WarningHandler,
std::function< StringRef(StringRef)>  StringsTranslator 
)
inline

Definition at line 342 of file DWARFLinker.h.

Member Function Documentation

◆ addAccelTableKind()

void llvm::DWARFLinker::addAccelTableKind ( AccelTableKind  Kind)
inline

Add kind of accelerator tables to be generated.

Definition at line 420 of file DWARFLinker.h.

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

◆ addObjectFile()

void llvm::DWARFLinker::addObjectFile ( DWARFFile File,
objFileLoader  Loader = nullptr,
CompileUnitHandler  OnCUDieLoaded = [](const DWARFUnit &) {} 
)

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.

Definition at line 2676 of file DWARFLinker.cpp.

References LLVM_UNLIKELY.

◆ createEmitter()

Error llvm::DWARFLinker::createEmitter ( const Triple TheTriple,
OutputFileType  FileType,
raw_pwrite_stream OutFile 
)

Definition at line 3052 of file DWARFLinker.cpp.

◆ createLinker()

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

Definition at line 348 of file DWARFLinker.h.

◆ getEmitter()

DwarfEmitter * llvm::DWARFLinker::getEmitter ( )

Definition at line 3062 of file DWARFLinker.cpp.

◆ link()

Error llvm::DWARFLinker::link ( )

◆ setAllowNonDeterministicOutput()

void llvm::DWARFLinker::setAllowNonDeterministicOutput ( bool  )
inline

Allow generating valid, but non-deterministic output.

Definition at line 408 of file DWARFLinker.h.

◆ setEstimatedObjfilesAmount()

void llvm::DWARFLinker::setEstimatedObjfilesAmount ( unsigned  ObjFilesNum)
inline

Set estimated objects files amount, for preliminary data allocation.

Definition at line 429 of file DWARFLinker.h.

◆ setInputVerificationHandler()

void llvm::DWARFLinker::setInputVerificationHandler ( inputVerificationHandler  Handler)
inline

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

Definition at line 435 of file DWARFLinker.h.

◆ setKeepFunctionForStatic()

void llvm::DWARFLinker::setKeepFunctionForStatic ( bool  KeepFunctionForStatic)
inline

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

Definition at line 412 of file DWARFLinker.h.

◆ setNoODR()

void llvm::DWARFLinker::setNoODR ( bool  NoODR)
inline

Do not unique types according to ODR.

Definition at line 402 of file DWARFLinker.h.

◆ setNumThreads()

void llvm::DWARFLinker::setNumThreads ( unsigned  NumThreads)
inline

Use specified number of threads for parallel files linking.

Definition at line 417 of file DWARFLinker.h.

◆ setObjectPrefixMap()

void llvm::DWARFLinker::setObjectPrefixMap ( objectPrefixMap Map)
inline

Set prefix map for objects.

Definition at line 445 of file DWARFLinker.h.

◆ setPrependPath()

void llvm::DWARFLinker::setPrependPath ( const std::string &  Ppath)
inline

Set prepend path for clang modules.

Definition at line 426 of file DWARFLinker.h.

◆ setStatistics()

void llvm::DWARFLinker::setStatistics ( bool  Statistics)
inline

Print statistics to standard output.

Definition at line 396 of file DWARFLinker.h.

◆ setSwiftInterfacesMap()

void llvm::DWARFLinker::setSwiftInterfacesMap ( swiftInterfacesMap Map)
inline

Set map for Swift interfaces.

Definition at line 440 of file DWARFLinker.h.

◆ setTargetDWARFVersion()

Error llvm::DWARFLinker::setTargetDWARFVersion ( uint16_t  TargetDWARFVersion)
inline

Set target DWARF version.

Definition at line 450 of file DWARFLinker.h.

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

◆ setUpdateIndexTablesOnly()

void llvm::DWARFLinker::setUpdateIndexTablesOnly ( bool  Update)
inline

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

Definition at line 405 of file DWARFLinker.h.

◆ setVerbosity()

void llvm::DWARFLinker::setVerbosity ( bool  Verbose)
inline

A number of methods setting various linking options:

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

Definition at line 393 of file DWARFLinker.h.

References llvm::Verbose.

◆ setVerifyInputDWARF()

void llvm::DWARFLinker::setVerifyInputDWARF ( bool  Verify)
inline

Verify the input DWARF.

Definition at line 399 of file DWARFLinker.h.

References Verify.


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