LLVM API Documentation
Collects and handles dwarf debug information. More...
#include <DwarfDebug.h>
Public Member Functions | |
DwarfDebug (AsmPrinter *A, Module *M) | |
~DwarfDebug () override | |
void | insertDIE (const MDNode *TypeMD, DIE *Die) |
DIE * | getDIE (const MDNode *TypeMD) |
void | beginModule () |
Emit all Dwarf sections that should come prior to the content. | |
void | endModule () override |
Emit all Dwarf sections that should come after the content. | |
void | beginFunction (const MachineFunction *MF) override |
Gather pre-function debug information. | |
void | endFunction (const MachineFunction *MF) override |
Gather and emit post-function debug information. | |
void | beginInstruction (const MachineInstr *MI) override |
Process beginning of an instruction. | |
void | endInstruction () override |
Process end of an instruction. | |
void | addDwarfTypeUnitType (DwarfCompileUnit &CU, StringRef Identifier, DIE &Die, DICompositeType CTy) |
Add a DIE to the set of types that we're going to pull into type units. | |
void | addArangeLabel (SymbolCU SCU) |
Add a label so that arange data can be generated for it. | |
void | setSymbolSize (const MCSymbol *Sym, uint64_t Size) override |
For symbols that have a size designated (e.g. common symbols), this tracks that size. | |
void | emitDIE (DIE &Die) |
Recursively Emits a debug information entry. | |
bool | useDwarfAccelTables () const |
Returns whether or not to emit tables that dwarf consumers can use to accelerate lookup. | |
bool | useSplitDwarf () const |
Returns whether or not to change the current debug info for the split dwarf proposal support. | |
unsigned | getDwarfVersion () const |
Returns the Dwarf Version. | |
MCSymbol * | getDebugLocSym () const |
Returns the section symbol for the .debug_loc section. | |
MCSymbol * | getDebugStrSym () const |
Returns the section symbol for the .debug_str section. | |
const DwarfCompileUnit * | getPrevCU () const |
Returns the previous CU that was being updated. | |
void | setPrevCU (const DwarfCompileUnit *PrevCU) |
const SmallVectorImpl < DebugLocList > & | getDebugLocEntries () const |
Returns the entries for the .debug_loc section. | |
void | emitDebugLocEntry (ByteStreamer &Streamer, const DebugLocEntry &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. | |
void | emitDebugLocValue (ByteStreamer &Streamer, const DebugLocEntry::Value &Value) |
emit a single value for the debug loc section. | |
void | emitLocPieces (ByteStreamer &Streamer, const DITypeIdentifierMap &Map, ArrayRef< DebugLocEntry::Value > Values) |
Emits an optimal (=sorted) sequence of DW_OP_pieces. | |
void | emitDebugLocEntryLocation (const DebugLocEntry &Entry) |
Emit the location for a debug loc entry, including the size header. | |
template<typename T > | |
T | resolve (DIRef< T > Ref) const |
Find the MDNode for the given reference. | |
const DITypeIdentifierMap & | getTypeIdentifierMap () const |
Return the TypeIdentifierMap. | |
DwarfCompileUnit * | lookupUnit (const DIE *CU) const |
Find the DwarfCompileUnit for the given CU Die. | |
bool | isSubprogramContext (const MDNode *Context) |
void | addSubprogramNames (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) |
Collects and handles dwarf debug information.
Definition at line 152 of file DwarfDebug.h.
DwarfDebug::DwarfDebug | ( | AsmPrinter * | A, |
Module * | M | ||
) |
Definition at line 169 of file DwarfDebug.cpp.
References beginModule(), DbgTimerName, Default, DwarfAccelTables, DWARFGroupName, DwarfPubSections, llvm::MCTargetOptions::DwarfVersion, llvm::MCStreamer::getContext(), llvm::Module::getDwarfVersion(), llvm::MachineModuleInfo::getModule(), llvm::AsmPrinter::getTargetTriple(), llvm::TargetOptions::MCOptions, llvm::TargetMachine::Options, llvm::AsmPrinter::OutStreamer, llvm::MCContext::setDwarfVersion(), SplitDwarf, T, llvm::TimePassesIsEnabled, and llvm::AsmPrinter::TM.
DwarfDebug::~DwarfDebug | ( | ) | [override] |
Definition at line 223 of file DwarfDebug.cpp.
void DwarfDebug::addAccelName | ( | StringRef | Name, |
const DIE & | Die | ||
) |
Definition at line 2629 of file DwarfDebug.cpp.
References llvm::DwarfAccelTable::AddName(), llvm::DwarfFile::getStringPool(), llvm::DwarfStringPool::getSymbol(), and useDwarfAccelTables().
Referenced by addSubprogramNames(), and llvm::DwarfCompileUnit::createGlobalVariableDIE().
void DwarfDebug::addAccelNamespace | ( | StringRef | Name, |
const DIE & | Die | ||
) |
Definition at line 2643 of file DwarfDebug.cpp.
References llvm::DwarfAccelTable::AddName(), llvm::DwarfFile::getStringPool(), llvm::DwarfStringPool::getSymbol(), and useDwarfAccelTables().
Referenced by llvm::DwarfUnit::getOrCreateNameSpace().
void DwarfDebug::addAccelObjC | ( | StringRef | Name, |
const DIE & | Die | ||
) |
Definition at line 2636 of file DwarfDebug.cpp.
References llvm::DwarfAccelTable::AddName(), llvm::DwarfFile::getStringPool(), llvm::DwarfStringPool::getSymbol(), and useDwarfAccelTables().
Referenced by addSubprogramNames().
void DwarfDebug::addAccelType | ( | StringRef | Name, |
const DIE & | Die, | ||
char | Flags | ||
) |
Definition at line 2650 of file DwarfDebug.cpp.
References llvm::DwarfAccelTable::AddName(), llvm::DwarfFile::getStringPool(), llvm::DwarfStringPool::getSymbol(), and useDwarfAccelTables().
void llvm::DwarfDebug::addArangeLabel | ( | SymbolCU | SCU | ) | [inline] |
Add a label so that arange data can be generated for it.
Definition at line 607 of file DwarfDebug.h.
Referenced by llvm::DwarfCompileUnit::addLabelAddress(), llvm::DwarfCompileUnit::addLocalLabelAddress(), and llvm::DwarfCompileUnit::createGlobalVariableDIE().
void DwarfDebug::addDwarfTypeUnitType | ( | DwarfCompileUnit & | CU, |
StringRef | Identifier, | ||
DIE & | Die, | ||
DICompositeType | CTy | ||
) |
Add a DIE to the set of types that we're going to pull into type units.
Definition at line 2537 of file DwarfDebug.cpp.
References llvm::DwarfUnit::addDIETypeSignature(), llvm::DwarfCompileUnit::applyStmtList(), llvm::SmallVectorImpl< T >::clear(), llvm::DwarfUnit::constructTypeDIE(), llvm::dwarf::DW_AT_language, llvm::dwarf::DW_FORM_data2, llvm::SmallVectorBase::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::erase(), llvm::DwarfUnit::getLanguage(), llvm::DwarfFile::getUnits(), llvm::AddressPool::hasBeenUsed(), makeTypeSignature(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::AddressPool::resetUsedFlag(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and useSplitDwarf().
Referenced by llvm::DwarfUnit::getOrCreateTypeDIE().
void DwarfDebug::addSubprogramNames | ( | DISubprogram | SP, |
DIE & | Die | ||
) |
Definition at line 277 of file DwarfDebug.cpp.
References addAccelName(), addAccelObjC(), llvm::tgtok::Class, llvm::DISubprogram::getLinkageName(), llvm::DISubprogram::getName(), getObjCClassCategory(), getObjCMethodName(), llvm::DISubprogram::isDefinition(), and isObjCClass().
void DwarfDebug::beginFunction | ( | const MachineFunction * | MF | ) | [override, virtual] |
Gather pre-function debug information.
Implements llvm::AsmPrinterHandler.
Definition at line 1518 of file DwarfDebug.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::calculateDbgValueHistory(), llvm::dwarf::DW_TAG_arg_variable, DWARF2_FLAG_IS_STMT, llvm::SmallVectorBase::empty(), llvm::LexicalScopes::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::find(), findPrologueEndLoc(), llvm::SmallVectorTemplateCommon< T, typename >::front(), llvm::DebugLoc::getCol(), llvm::Function::getContext(), llvm::DIVariable::getContext(), llvm::LexicalScopes::getCurrentFunctionScope(), llvm::getDISubprogram(), llvm::DebugLoc::getFnDebugLoc(), llvm::MachineFunction::getFunction(), llvm::DebugLoc::getLine(), llvm::DebugLoc::getScope(), llvm::LexicalScope::getScopeNode(), llvm::DIDescriptor::getTag(), llvm::DwarfUnit::getUniqueID(), llvm::MachineModuleInfo::hasDebugInfo(), I, llvm::LexicalScopes::initialize(), llvm::DebugLoc::isUnknown(), llvm::DIDescriptor::isVariable(), llvm::DIVariable::isVariablePiece(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::lookup(), and piecesOverlap().
void DwarfDebug::beginInstruction | ( | const MachineInstr * | MI | ) | [override, virtual] |
Process beginning of an instruction.
Implements llvm::AsmPrinterHandler.
Definition at line 1408 of file DwarfDebug.cpp.
References llvm::MCContext::CreateTempSymbol(), DWARF2_FLAG_IS_STMT, DWARF2_FLAG_PROLOGUE_END, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::find(), llvm::DebugLoc::getCol(), llvm::MachineModuleInfo::getContext(), llvm::MachineInstr::getDebugLoc(), llvm::DebugLoc::getLine(), llvm::DebugLoc::getScope(), I, llvm::MachineInstr::isDebugValue(), llvm::DebugLoc::isUnknown(), llvm::AArch64CC::MI, and UnknownLocations.
void DwarfDebug::beginModule | ( | ) |
Emit all Dwarf sections that should come prior to the content.
Definition at line 750 of file DwarfDebug.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::DwarfCompileUnit::createGlobalVariableDIE(), DisableDebugInfoPrinting, llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::generateDITypeIdentifierMap(), llvm::DITypedArray< T >::getElement(), llvm::DICompileUnit::getEnumTypes(), llvm::DICompileUnit::getGlobalVariables(), llvm::DICompileUnit::getImportedEntities(), llvm::MachineModuleInfo::getModule(), llvm::Module::getNamedMetadata(), llvm::DITypedArray< T >::getNumElements(), llvm::NamedMDNode::getNumOperands(), llvm::DwarfUnit::getOrCreateTypeDIE(), llvm::DICompileUnit::getRetainedTypes(), llvm::DICompileUnit::getSubprograms(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::insert(), llvm::makeSubprogramMap(), llvm::NamedMDNode::operands(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), resolve(), and llvm::MachineModuleInfo::setDebugInfoAvailability().
Referenced by DwarfDebug().
void DwarfDebug::emitDebugLocEntry | ( | ByteStreamer & | Streamer, |
const DebugLocEntry & | 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 2107 of file DwarfDebug.cpp.
References emitDebugLocValue(), emitLocPieces(), llvm::DebugLocEntry::getValues(), and llvm::DebugLocEntry::Value::isVariablePiece().
Referenced by emitDebugLocEntryLocation().
void DwarfDebug::emitDebugLocEntryLocation | ( | const DebugLocEntry & | Entry | ) |
Emit the location for a debug loc entry, including the size header.
Definition at line 2181 of file DwarfDebug.cpp.
References llvm::sys::path::begin(), emitDebugLocEntry(), and llvm::sys::path::end().
void DwarfDebug::emitDebugLocValue | ( | ByteStreamer & | Streamer, |
const DebugLocEntry::Value & | Value | ||
) |
emit a single value for the debug loc section.
Definition at line 2118 of file DwarfDebug.cpp.
References llvm::dwarf::DW_ATE_signed, llvm::dwarf::DW_ATE_signed_char, llvm::dwarf::DW_OP_consts, llvm::dwarf::DW_OP_constu, llvm::dwarf::DW_OP_deref, llvm::dwarf::DW_OP_plus_uconst, llvm::ByteStreamer::EmitInt8(), llvm::ByteStreamer::EmitSLEB128(), llvm::ByteStreamer::EmitULEB128(), llvm::DIVariable::getAddrElement(), llvm::DIBasicType::getEncoding(), llvm::DebugLocEntry::Value::getInt(), llvm::DebugLocEntry::Value::getLoc(), llvm::DIVariable::getNumAddrElements(), llvm::MachineLocation::getOffset(), llvm::MachineLocation::getReg(), llvm::DIVariable::getType(), llvm::DebugLocEntry::Value::getVariable(), llvm::DIVariable::hasComplexAddress(), llvm::DIVariable::isIndirect(), llvm::DebugLocEntry::Value::isInt(), llvm::DebugLocEntry::Value::isLocation(), llvm::MachineLocation::isReg(), llvm_unreachable, llvm::DIBuilder::OpDeref, llvm::DIBuilder::OpPiece, llvm::DIBuilder::OpPlus, resolve(), and llvm::DIBasicType::Verify().
Referenced by emitDebugLocEntry(), and emitLocPieces().
void DwarfDebug::emitDIE | ( | DIE & | Die | ) |
Recursively Emits a debug information entry.
Definition at line 1803 of file DwarfDebug.cpp.
References llvm::dwarf::AccessibilityString(), llvm::dwarf::AttributeString(), llvm::dwarf::DW_AT_accessibility, llvm::DIE::getAbbrev(), llvm::DIE::getChildren(), llvm::DIEAbbrev::getData(), llvm::DIEAbbrev::getNumber(), llvm::DIE::getOffset(), llvm::DIE::getSize(), llvm::DIEAbbrev::getTag(), llvm::DIE::getValues(), llvm::DIEAbbrev::hasChildren(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::dwarf::TagString(), and llvm::Twine::utohexstr().
Referenced by llvm::DwarfFile::emitUnits().
void DwarfDebug::emitLocPieces | ( | ByteStreamer & | Streamer, |
const DITypeIdentifierMap & | Map, | ||
ArrayRef< DebugLocEntry::Value > | Values | ||
) |
Emits an optimal (=sorted) sequence of DW_OP_pieces.
Definition at line 2063 of file DwarfDebug.cpp.
References llvm::ArrayRef< T >::begin(), emitDebugLocValue(), llvm::ArrayRef< T >::end(), llvm::DIVariable::getPieceOffset(), llvm::DIVariable::getPieceSize(), llvm::DIVariable::getSizeInBits(), llvm::DbgVariable::getVariable(), llvm::DIVariable::isIndirect(), and P.
Referenced by emitDebugLocEntry().
void DwarfDebug::endFunction | ( | const MachineFunction * | MF | ) | [override, virtual] |
Gather and emit post-function debug information.
Implements llvm::AsmPrinterHandler.
Definition at line 1655 of file DwarfDebug.cpp.
References llvm::DwarfUnit::addFlag(), llvm::DwarfCompileUnit::addRange(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::clear(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::count(), llvm::TargetOptions::DisableFramePointerElim(), llvm::dwarf::DW_AT_APPLE_omit_frame_ptr, llvm::LexicalScopes::empty(), llvm::LexicalScopes::getAbstractScopesList(), llvm::DIVariable::getContext(), llvm::LexicalScopes::getCurrentFunctionScope(), llvm::MachineFunction::getFunction(), llvm::LexicalScope::getScopeNode(), llvm::MachineFunction::getTarget(), llvm::DISubprogram::getVariables(), llvm::MachineModuleInfo::hasDebugInfo(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::DIDescriptor::isSubprogram(), llvm::DIDescriptor::isVariable(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::lookup(), and llvm::TargetMachine::Options.
void DwarfDebug::endInstruction | ( | ) | [override, virtual] |
Process end of an instruction.
Implements llvm::AsmPrinterHandler.
Definition at line 1452 of file DwarfDebug.cpp.
References llvm::MCContext::CreateTempSymbol(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::find(), llvm::MachineModuleInfo::getContext(), I, and llvm::MachineInstr::isDebugValue().
void DwarfDebug::endModule | ( | ) | [override, virtual] |
Emit all Dwarf sections that should come after the content.
Implements llvm::AsmPrinterHandler.
Definition at line 1032 of file DwarfDebug.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::clear(), llvm::AddressPool::emit(), GenerateARangeSection, GenerateGnuPubSections, useDwarfAccelTables(), and useSplitDwarf().
AddressPool& llvm::DwarfDebug::getAddressPool | ( | ) | [inline] |
Definition at line 681 of file DwarfDebug.h.
Referenced by llvm::DwarfCompileUnit::addLabelAddress(), llvm::DwarfUnit::addOpAddress(), and llvm::DwarfCompileUnit::createGlobalVariableDIE().
const SmallVectorImpl<DebugLocList>& llvm::DwarfDebug::getDebugLocEntries | ( | ) | const [inline] |
Returns the entries for the .debug_loc section.
Definition at line 643 of file DwarfDebug.h.
Referenced by llvm::DIELocList::EmitValue().
MCSymbol* llvm::DwarfDebug::getDebugLocSym | ( | ) | const [inline] |
Returns the section symbol for the .debug_loc section.
Definition at line 632 of file DwarfDebug.h.
Referenced by llvm::DIELocList::EmitValue().
MCSymbol* llvm::DwarfDebug::getDebugStrSym | ( | ) | const [inline] |
Returns the section symbol for the .debug_str section.
Definition at line 635 of file DwarfDebug.h.
Referenced by llvm::DwarfUnit::addLocalString().
DIE* llvm::DwarfDebug::getDIE | ( | const MDNode * | TypeMD | ) | [inline] |
Definition at line 578 of file DwarfDebug.h.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::lookup().
Referenced by llvm::DwarfUnit::getDIE().
unsigned llvm::DwarfDebug::getDwarfVersion | ( | ) | const [inline] |
Returns the Dwarf Version.
Definition at line 629 of file DwarfDebug.h.
Referenced by llvm::DwarfUnit::addBlock(), llvm::DwarfUnit::addFlag(), llvm::DwarfUnit::addLocationList(), llvm::DwarfUnit::addSectionDelta(), llvm::DwarfUnit::addSectionLabel(), llvm::DwarfUnit::addSectionOffset(), llvm::DwarfCompileUnit::createGlobalVariableDIE(), llvm::DwarfUnit::emitHeader(), llvm::DwarfUnit::getOrCreateTypeDIE(), and llvm::DIEEntry::getRefAddrSize().
const DwarfCompileUnit* llvm::DwarfDebug::getPrevCU | ( | ) | const [inline] |
Returns the previous CU that was being updated.
Definition at line 638 of file DwarfDebug.h.
Referenced by llvm::DwarfCompileUnit::addRange().
const DITypeIdentifierMap& llvm::DwarfDebug::getTypeIdentifierMap | ( | ) | const [inline] |
Return the TypeIdentifierMap.
Definition at line 667 of file DwarfDebug.h.
Referenced by llvm::DbgVariable::getType(), and llvm::DbgVariable::isBlockByrefVariable().
void llvm::DwarfDebug::insertDIE | ( | const MDNode * | TypeMD, |
DIE * | Die | ||
) | [inline] |
Definition at line 575 of file DwarfDebug.h.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::insert().
Referenced by llvm::DwarfUnit::insertDIE().
bool DwarfDebug::isSubprogramContext | ( | const MDNode * | Context | ) |
isSubprogramContext - Return true if Context is either a subprogram or another context nested inside a subprogram.
Definition at line 302 of file DwarfDebug.cpp.
References llvm::DIDescriptor::isSubprogram(), llvm::DIDescriptor::isType(), and resolve().
Referenced by llvm::DwarfCompileUnit::createGlobalVariableDIE().
DwarfCompileUnit* llvm::DwarfDebug::lookupUnit | ( | const DIE * | CU | ) | const [inline] |
Find the DwarfCompileUnit for the given CU Die.
Definition at line 672 of file DwarfDebug.h.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::lookup().
Referenced by llvm::DIEEntry::EmitValue().
T llvm::DwarfDebug::resolve | ( | DIRef< T > | Ref | ) | const [inline] |
Find the MDNode for the given reference.
Definition at line 662 of file DwarfDebug.h.
References llvm::DIRef< T >::resolve().
Referenced by beginModule(), llvm::DwarfCompileUnit::createGlobalVariableDIE(), emitDebugLocValue(), getBaseTypeSize(), isSubprogramContext(), and isUnsignedDIType().
void llvm::DwarfDebug::setPrevCU | ( | const DwarfCompileUnit * | PrevCU | ) | [inline] |
Definition at line 639 of file DwarfDebug.h.
Referenced by llvm::DwarfCompileUnit::addRange().
void llvm::DwarfDebug::setSymbolSize | ( | const MCSymbol * | Sym, |
uint64_t | Size | ||
) | [inline, override, virtual] |
For symbols that have a size designated (e.g. common symbols), this tracks that size.
Implements llvm::AsmPrinterHandler.
Definition at line 611 of file DwarfDebug.h.
bool llvm::DwarfDebug::useDwarfAccelTables | ( | ) | const [inline] |
Returns whether or not to emit tables that dwarf consumers can use to accelerate lookup.
Definition at line 622 of file DwarfDebug.h.
Referenced by addAccelName(), addAccelNamespace(), addAccelObjC(), addAccelType(), and endModule().
bool llvm::DwarfDebug::useSplitDwarf | ( | ) | const [inline] |
Returns whether or not to change the current debug info for the split dwarf proposal support.
Definition at line 626 of file DwarfDebug.h.
Referenced by addDwarfTypeUnitType(), llvm::DwarfCompileUnit::addLabelAddress(), llvm::DwarfUnit::addOpAddress(), llvm::DwarfUnit::addString(), llvm::DwarfCompileUnit::createGlobalVariableDIE(), llvm::DIEEntry::EmitValue(), llvm::DIELocList::EmitValue(), and endModule().