LLVM  7.0.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
llvm::DwarfDebug Class Reference

Collects and handles dwarf debug information. More...

#include "CodeGen/AsmPrinter/DwarfDebug.h"

Inheritance diagram for llvm::DwarfDebug:
[legend]
Collaboration diagram for llvm::DwarfDebug:
[legend]

Public Member Functions

 DwarfDebug (AsmPrinter *A, Module *M)
 
 ~DwarfDebug () override
 
void beginModule ()
 Emit all Dwarf sections that should come prior to the content. More...
 
void endModule () override
 Emit all Dwarf sections that should come after the content. More...
 
void beginInstruction (const MachineInstr *MI) override
 Process beginning of an instruction. More...
 
void addDwarfTypeUnitType (DwarfCompileUnit &CU, StringRef Identifier, DIE &Die, const DICompositeType *CTy)
 Add a DIE to the set of types that we're going to pull into type units. More...
 
void addArangeLabel (SymbolCU SCU)
 Add a label so that arange data can be generated for it. More...
 
void setSymbolSize (const MCSymbol *Sym, uint64_t Size) override
 For symbols that have a size designated (e.g. More...
 
bool useAllLinkageNames () const
 Returns whether we should emit all DW_AT_[MIPS_]linkage_name. More...
 
bool useGNUTLSOpcode () const
 Returns whether to use DW_OP_GNU_push_tls_address, instead of the standard DW_OP_form_tls_address opcode. More...
 
bool useDWARF2Bitfields () const
 Returns whether to use the DWARF2 format for bitfields instyead of the DWARF4 format. More...
 
bool useInlineStrings () const
 Returns whether to use inline strings. More...
 
bool usePubSections () const
 Returns whether GNU pub sections should be emitted. More...
 
bool useRangesSection () const
 Returns whether ranges section should be emitted. More...
 
bool useSectionsAsReferences () const
 Returns whether to use sections as labels rather than temp symbols. More...
 
bool useLocSection () const
 Returns whether .debug_loc section should be emitted. More...
 
bool generateTypeUnits () const
 Returns whether to generate DWARF v4 type units. More...
 
AccelTableKind getAccelTableKind () const
 Returns what kind (if any) of accelerator tables to emit. More...
 
bool useAppleExtensionAttributes () const
 
bool useSplitDwarf () const
 Returns whether or not to change the current debug info for the split dwarf proposal support. More...
 
bool useSegmentedStringOffsetsTable () const
 Returns whether to generate a string offsets table with (possibly shared) contributions from each CU and type unit. More...
 
bool shareAcrossDWOCUs () const
 
uint16_t getDwarfVersion () const
 Returns the Dwarf Version. More...
 
const DwarfCompileUnit * getPrevCU () const
 Returns the previous CU that was being updated. More...
 
void setPrevCU (const DwarfCompileUnit *PrevCU)
 
const DebugLocStream & getDebugLocs () const
 Returns the entries for the .debug_loc section. More...
 
void emitDebugLocEntry (ByteStreamer &Streamer, const DebugLocStream::Entry &Entry)
 Emit an entry for the debug loc section. More...
 
void emitDebugLocEntryLocation (const DebugLocStream::Entry &Entry)
 Emit the location for a debug loc entry, including the size header. More...
 
template<typename T >
T * resolve (TypedDINodeRef< T > Ref) const
 Find the MDNode for the given reference. More...
 
void addSubprogramNames (const DISubprogram *SP, DIE &Die)
 
AddressPool & getAddressPool ()
 
void addAccelName (StringRef Name, const DIE &Die)
 
void addAccelObjC (StringRef Name, const DIE &Die)
 
void addAccelNamespace (StringRef Name, const DIE &Die)
 
void addAccelType (StringRef Name, const DIE &Die, char Flags)
 
const MachineFunction * getCurrentFunction () const
 
bool isLexicalScopeDIENull (LexicalScope *Scope)
 A helper function to check whether the DIE for a given Scope is going to be null. More...
 
DwarfCompileUnit * lookupCU (const DIE *Die)
 Find the matching DwarfCompileUnit for the given CU DIE. More...
 
const DwarfCompileUnit * lookupCU (const DIE *Die) const
 
bool tuneForGDB () const
 
bool tuneForLLDB () const
 
bool tuneForSCE () const
 
- Public Member Functions inherited from llvm::DebugHandlerBase
void endInstruction () override
 Process end of an instruction. More...
 
void beginFunction (const MachineFunction *MF) override
 Gather pre-function debug information. More...
 
void endFunction (const MachineFunction *MF) override
 Gather post-function debug information. More...
 
MCSymbol * getLabelBeforeInsn (const MachineInstr *MI)
 Return Label preceding the instruction. More...
 
MCSymbol * getLabelAfterInsn (const MachineInstr *MI)
 Return Label immediately following the instruction. More...
 
- Public Member Functions inherited from llvm::AsmPrinterHandler
virtual ~AsmPrinterHandler ()
 Pin vtable to this file. More...
 
virtual void markFunctionEnd ()
 
virtual void beginFragment (const MachineBasicBlock *MBB, ExceptionSymbolProvider ESP)
 
virtual void endFragment ()
 
virtual void beginFunclet (const MachineBasicBlock &MBB, MCSymbol *Sym=nullptr)
 Emit target-specific EH funclet machinery. More...
 
virtual void endFunclet ()
 

Static Public Member Functions

static uint64_t makeTypeSignature (StringRef Identifier)
 Perform an MD5 checksum of Identifier and return the lower 64 bits. More...
 
- Static Public Member Functions inherited from llvm::DebugHandlerBase
static uint64_t getBaseTypeSize (const DITypeRef TyRef)
 If this type is derived from a base type then return base type size. More...
 

Protected Member Functions

void beginFunctionImpl (const MachineFunction *MF) override
 Gather pre-function debug information. More...
 
void endFunctionImpl (const MachineFunction *MF) override
 Gather and emit post-function debug information. More...
 
void skippedNonDebugFunction () override
 
- Protected Member Functions inherited from llvm::DebugHandlerBase
 DebugHandlerBase (AsmPrinter *A)
 
void identifyScopeMarkers ()
 Indentify instructions that are marking the beginning of or ending of a scope. More...
 
void requestLabelBeforeInsn (const MachineInstr *MI)
 Ensure that a label will be emitted before MI. More...
 
void requestLabelAfterInsn (const MachineInstr *MI)
 Ensure that a label will be emitted after MI. More...
 

Additional Inherited Members

- Protected Attributes inherited from llvm::DebugHandlerBase
AsmPrinter * Asm
 Target of debug info emission. More...
 
MachineModuleInfo * MMI
 Collected machine module information. More...
 
DebugLoc PrevInstLoc
 Previous instruction's location information. More...
 
MCSymbol * PrevLabel = nullptr
 
const MachineBasicBlock * PrevInstBB = nullptr
 
DebugLoc PrologEndLoc
 This location indicates end of function prologue and beginning of function body. More...
 
const MachineInstr * CurMI = nullptr
 If nonnull, stores the current machine instruction we're processing. More...
 
LexicalScopes LScopes
 
DbgValueHistoryMap DbgValues
 History of DBG_VALUE and clobber instructions for each user variable. More...
 
DenseMap< const MachineInstr *, MCSymbol * > LabelsBeforeInsn
 Maps instruction with label emitted before instruction. More...
 
DenseMap< const MachineInstr *, MCSymbol * > LabelsAfterInsn
 Maps instruction with label emitted after instruction. More...
 

Detailed Description

Collects and handles dwarf debug information.

Definition at line 204 of file DwarfDebug.h.

Constructor & Destructor Documentation

◆ DwarfDebug()

DwarfDebug::DwarfDebug ( AsmPrinter *  A,
Module *  M 
)

◆ ~DwarfDebug()

DwarfDebug::~DwarfDebug ( )
overridedefault

Referenced by DwarfDebug().

Member Function Documentation

◆ addAccelName()

void DwarfDebug::addAccelName ( StringRef  Name,
const DIE &  Die 
)

◆ addAccelNamespace()

void DwarfDebug::addAccelNamespace ( StringRef  Name,
const DIE &  Die 
)

Definition at line 2444 of file DwarfDebug.cpp.

Referenced by llvm::DwarfUnit::getOrCreateNameSpace().

◆ addAccelObjC()

void DwarfDebug::addAccelObjC ( StringRef  Name,
const DIE &  Die 
)

Definition at line 2438 of file DwarfDebug.cpp.

References llvm::Apple, and getAccelTableKind().

Referenced by addSubprogramNames().

◆ addAccelType()

void DwarfDebug::addAccelType ( StringRef  Name,
const DIE &  Die,
char  Flags 
)

◆ addArangeLabel()

void llvm::DwarfDebug::addArangeLabel ( SymbolCU  SCU)
inline

Add a label so that arange data can be generated for it.

Definition at line 523 of file DwarfDebug.h.

Referenced by llvm::DwarfCompileUnit::addLabelAddress(), llvm::DwarfCompileUnit::addLocalLabelAddress(), and llvm::DwarfCompileUnit::getOrCreateGlobalVariableDIE().

◆ addDwarfTypeUnitType()

void DwarfDebug::addDwarfTypeUnitType ( DwarfCompileUnit &  CU,
StringRef  Identifier,
DIE &  Die,
const DICompositeType *  CTy 
)

◆ addSubprogramNames()

void DwarfDebug::addSubprogramNames ( const DISubprogram *  SP,
DIE &  Die 
)

◆ beginFunctionImpl()

void DwarfDebug::beginFunctionImpl ( const MachineFunction *  MF)
overrideprotectedvirtual

◆ beginInstruction()

void DwarfDebug::beginInstruction ( const MachineInstr *  MI)
overridevirtual

◆ beginModule()

void DwarfDebug::beginModule ( )

Emit all Dwarf sections that should come prior to the content.

Definition at line 644 of file DwarfDebug.cpp.

References llvm::DwarfUnit::addRnglistsBase(), llvm::DwarfUnit::addSectionLabel(), llvm::DwarfUnit::addUInt(), llvm::any_of(), llvm::DebugHandlerBase::Asm, assert(), llvm::DwarfCompileUnit::attachRangesOrLowHighPC(), llvm::DIEHash::computeCUSignature(), llvm::DwarfFile::computeSizeAndOffsets(), llvm::DwarfUnit::constructContainingTypeDIEs(), llvm::AsmPrinter::createTempSymbol(), llvm::Module::debug_compile_units(), llvm::Module::debug_compile_units_begin(), llvm::Module::debug_compile_units_end(), DisableDebugInfoPrinting, llvm::DwarfCompileUnit::finishSubprogramDefinition(), llvm::DwarfCompileUnit::finishVariableDefinition(), for(), forBothCUs(), llvm::MCSection::getBeginSymbol(), llvm::MCObjectFileInfo::getDwarfAddrSection(), llvm::MCObjectFileInfo::getDwarfMacinfoSection(), llvm::MCObjectFileInfo::getDwarfRangesSection(), getDwarfVersion(), llvm::DwarfCompileUnit::getMacroLabelBegin(), llvm::MachineModuleInfo::getModule(), llvm::AsmPrinter::getObjFileLowering(), llvm::DwarfCompileUnit::getOrCreateGlobalVariableDIE(), llvm::DwarfUnit::getOrCreateTypeDIE(), llvm::DwarfCompileUnit::getRangeLists(), llvm::DwarfCompileUnit::getRanges(), llvm::DwarfCompileUnit::getSkeleton(), llvm::DIE::getUnitDie(), llvm::DIEUnit::getUnitDie(), Global, llvm::Module::globals(), llvm::ARM_PROC::IE, llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), llvm::AddressPool::isEmpty(), llvm::TargetOptions::MCOptions, llvm::DebugHandlerBase::MMI, llvm::DICompileUnit::NoDebug, llvm::TargetMachine::Options, P, llvm::DwarfCompileUnit::setBaseAddress(), llvm::MachineModuleInfo::setDebugInfoAvailability(), llvm::DwarfCompileUnit::setDWOId(), sortGlobalExprs(), llvm::MCTargetOptions::SplitDwarfFile, T, llvm::DwarfCompileUnit::takeRanges(), llvm::TimePassesIsEnabled, llvm::AsmPrinter::TM, useRangesSection(), useSegmentedStringOffsetsTable(), and useSplitDwarf().

Referenced by llvm::AsmPrinter::doInitialization().

◆ emitDebugLocEntry()

void DwarfDebug::emitDebugLocEntry ( ByteStreamer &  Streamer,
const DebugLocStream::Entry &  Entry 
)

Emit an entry for the debug loc section.

This can be used to handle an entry that's going to be emitted into the debug loc section.

Definition at line 1721 of file DwarfDebug.cpp.

References llvm::DebugLocStream::getComments().

Referenced by llvm::DIEHash::addSLEB128(), and emitDebugLocEntryLocation().

◆ emitDebugLocEntryLocation()

void DwarfDebug::emitDebugLocEntryLocation ( const DebugLocStream::Entry &  Entry)

◆ endFunctionImpl()

void DwarfDebug::endFunctionImpl ( const MachineFunction *  MF)
overrideprotectedvirtual

Gather and emit post-function debug information.

Implements llvm::DebugHandlerBase.

Definition at line 1407 of file DwarfDebug.cpp.

References llvm::DebugHandlerBase::Asm, assert(), llvm::DwarfFile::emitAbbrevs(), llvm::emitAppleAccelTable(), llvm::emitDWARF5AccelTable(), llvm::DwarfStringPool::emitStringOffsetsTableHeader(), llvm::DwarfFile::emitUnits(), llvm::LexicalScopes::getAbstractScopesList(), llvm::MCSection::getBeginSymbol(), llvm::LexicalScopes::getCurrentFunctionScope(), llvm::MCObjectFileInfo::getDwarfAbbrevSection(), llvm::MCObjectFileInfo::getDwarfAccelNamespaceSection(), llvm::MCObjectFileInfo::getDwarfAccelNamesSection(), llvm::MCObjectFileInfo::getDwarfAccelObjCSection(), llvm::MCObjectFileInfo::getDwarfAccelTypesSection(), llvm::MCObjectFileInfo::getDwarfDebugNamesSection(), llvm::MCObjectFileInfo::getDwarfStrOffSection(), getDwarfVersion(), llvm::MachineFunction::getFunction(), llvm::AsmPrinter::getFunctionBegin(), llvm::AsmPrinter::getFunctionEnd(), llvm::AsmPrinter::getObjFileLowering(), llvm::LexicalScope::getScopeNode(), llvm::DwarfFile::getScopeVariables(), llvm::DwarfFile::getStringOffsetsStartSym(), llvm::DwarfFile::getStringPool(), llvm::Function::getSubprogram(), llvm::DwarfFile::getUnits(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), llvm::DICompileUnit::LineTablesOnly, llvm::DebugHandlerBase::LScopes, llvm::AsmPrinter::OutStreamer, llvm::DebugHandlerBase::PrevLabel, llvm::ARMBuildAttrs::Section, and useSplitDwarf().

◆ endModule()

void DwarfDebug::endModule ( )
overridevirtual

◆ generateTypeUnits()

bool llvm::DwarfDebug::generateTypeUnits ( ) const
inline

Returns whether to generate DWARF v4 type units.

Definition at line 561 of file DwarfDebug.h.

Referenced by llvm::DwarfUnit::getOrCreateTypeDIE(), and llvm::DwarfUnit::isShareableAcrossCUs().

◆ getAccelTableKind()

AccelTableKind llvm::DwarfDebug::getAccelTableKind ( ) const
inline

Returns what kind (if any) of accelerator tables to emit.

Definition at line 566 of file DwarfDebug.h.

Referenced by addAccelObjC(), addDwarfTypeUnitType(), and endModule().

◆ getAddressPool()

AddressPool& llvm::DwarfDebug::getAddressPool ( )
inline

◆ getCurrentFunction()

const MachineFunction* llvm::DwarfDebug::getCurrentFunction ( ) const
inline

Definition at line 623 of file DwarfDebug.h.

Referenced by llvm::DwarfCompileUnit::updateSubprogramScopeDIE().

◆ getDebugLocs()

const DebugLocStream& llvm::DwarfDebug::getDebugLocs ( ) const
inline

Returns the entries for the .debug_loc section.

Definition at line 596 of file DwarfDebug.h.

Referenced by llvm::DIEHash::addSLEB128(), and llvm::DIELocList::EmitValue().

◆ getDwarfVersion()

uint16_t DwarfDebug::getDwarfVersion ( ) const

◆ getPrevCU()

const DwarfCompileUnit* llvm::DwarfDebug::getPrevCU ( ) const
inline

Returns the previous CU that was being updated.

Definition at line 592 of file DwarfDebug.h.

Referenced by llvm::DwarfCompileUnit::addRange().

◆ isLexicalScopeDIENull()

bool DwarfDebug::isLexicalScopeDIENull ( LexicalScope *  Scope)

A helper function to check whether the DIE for a given Scope is going to be null.

Check whether we should create a DIE for the given Scope, return true if we don't create a DIE (the corresponding DIE is null).

Definition at line 453 of file DwarfDebug.cpp.

References llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T, typename >::front(), llvm::DebugHandlerBase::getLabelAfterInsn(), llvm::LexicalScope::getRanges(), llvm::LexicalScope::isAbstractScope(), and llvm::SmallVectorBase::size().

Referenced by llvm::DwarfCompileUnit::constructLexicalScopeDIE(), and llvm::DwarfCompileUnit::constructScopeDIE().

◆ lookupCU() [1/2]

DwarfCompileUnit* llvm::DwarfDebug::lookupCU ( const DIE *  Die)
inline

◆ lookupCU() [2/2]

const DwarfCompileUnit* llvm::DwarfDebug::lookupCU ( const DIE *  Die) const
inline

◆ makeTypeSignature()

uint64_t DwarfDebug::makeTypeSignature ( StringRef  Identifier)
static

Perform an MD5 checksum of Identifier and return the lower 64 bits.

Definition at line 2317 of file DwarfDebug.cpp.

References llvm::MD5::final(), llvm::MD5::MD5Result::high(), Result, and llvm::MD5::update().

Referenced by addDwarfTypeUnitType().

◆ resolve()

template<typename T >
T* llvm::DwarfDebug::resolve ( TypedDINodeRef< T >  Ref) const
inline

Find the MDNode for the given reference.

Definition at line 607 of file DwarfDebug.h.

References llvm::TypedDINodeRef< T >::resolve().

Referenced by llvm::DwarfCompileUnit::getOrCreateGlobalVariableDIE(), and isUnsignedDIType().

◆ setPrevCU()

void llvm::DwarfDebug::setPrevCU ( const DwarfCompileUnit *  PrevCU)
inline

Definition at line 593 of file DwarfDebug.h.

Referenced by llvm::DwarfCompileUnit::addRange().

◆ setSymbolSize()

void llvm::DwarfDebug::setSymbolSize ( const MCSymbol *  Sym,
uint64_t  Size 
)
inlineoverridevirtual

For symbols that have a size designated (e.g.

common symbols), this tracks that size.

Implements llvm::AsmPrinterHandler.

Definition at line 527 of file DwarfDebug.h.

References llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Size.

◆ shareAcrossDWOCUs()

bool DwarfDebug::shareAcrossDWOCUs ( ) const

◆ skippedNonDebugFunction()

void DwarfDebug::skippedNonDebugFunction ( )
overrideprotectedvirtual

Reimplemented from llvm::DebugHandlerBase.

Definition at line 1398 of file DwarfDebug.cpp.

◆ useAllLinkageNames()

bool llvm::DwarfDebug::useAllLinkageNames ( ) const
inline

Returns whether we should emit all DW_AT_[MIPS_]linkage_name.

If not, we still might emit certain cases.

Definition at line 533 of file DwarfDebug.h.

Referenced by addSubprogramNames(), llvm::DwarfUnit::applySubprogramDefinitionAttributes(), and llvm::DwarfCompileUnit::getOrCreateGlobalVariableDIE().

◆ useAppleExtensionAttributes()

bool llvm::DwarfDebug::useAppleExtensionAttributes ( ) const
inline

◆ useDWARF2Bitfields()

bool llvm::DwarfDebug::useDWARF2Bitfields ( ) const
inline

Returns whether to use the DWARF2 format for bitfields instyead of the DWARF4 format.

Definition at line 541 of file DwarfDebug.h.

Referenced by llvm::DwarfUnit::constructContainingTypeDIEs().

◆ useGNUTLSOpcode()

bool llvm::DwarfDebug::useGNUTLSOpcode ( ) const
inline

Returns whether to use DW_OP_GNU_push_tls_address, instead of the standard DW_OP_form_tls_address opcode.

Definition at line 537 of file DwarfDebug.h.

Referenced by llvm::DwarfCompileUnit::getOrCreateGlobalVariableDIE().

◆ useInlineStrings()

bool llvm::DwarfDebug::useInlineStrings ( ) const
inline

Returns whether to use inline strings.

Definition at line 544 of file DwarfDebug.h.

Referenced by llvm::DwarfUnit::addString().

◆ useLocSection()

bool llvm::DwarfDebug::useLocSection ( ) const
inline

Returns whether .debug_loc section should be emitted.

Definition at line 558 of file DwarfDebug.h.

Referenced by validThroughout().

◆ usePubSections()

bool llvm::DwarfDebug::usePubSections ( ) const
inline

Returns whether GNU pub sections should be emitted.

Definition at line 547 of file DwarfDebug.h.

Referenced by llvm::DwarfCompileUnit::hasDwarfPubSections().

◆ useRangesSection()

bool llvm::DwarfDebug::useRangesSection ( ) const
inline

Returns whether ranges section should be emitted.

Definition at line 550 of file DwarfDebug.h.

Referenced by llvm::DwarfCompileUnit::attachRangesOrLowHighPC(), beginModule(), and emitRnglistsTableHeader().

◆ useSectionsAsReferences()

bool llvm::DwarfDebug::useSectionsAsReferences ( ) const
inline

Returns whether to use sections as labels rather than temp symbols.

Definition at line 553 of file DwarfDebug.h.

Referenced by computeIndexValue(), llvm::DwarfCompileUnit::emitHeader(), and llvm::DwarfCompileUnit::initStmtList().

◆ useSegmentedStringOffsetsTable()

bool llvm::DwarfDebug::useSegmentedStringOffsetsTable ( ) const
inline

Returns whether to generate a string offsets table with (possibly shared) contributions from each CU and type unit.

This implies the use of DW_FORM_strx* indirect references with DWARF v5 and beyond. Note that DW_FORM_GNU_str_index is also an indirect reference, but it is used with a pre-DWARF v5 implementation of split DWARF sections, which uses a monolithic string offsets table.

Definition at line 582 of file DwarfDebug.h.

Referenced by addDwarfTypeUnitType(), beginModule(), computeIndexValue(), emitRnglistsTableHeader(), shareAcrossDWOCUs(), and llvm::DwarfUnit::useSegmentedStringOffsetsTable().

◆ useSplitDwarf()

bool llvm::DwarfDebug::useSplitDwarf ( ) const
inline

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