LLVM  9.0.0svn
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
llvm::DWARFUnit Class Referenceabstract

#include "llvm/DebugInfo/DWARF/DWARFUnit.h"

Inheritance diagram for llvm::DWARFUnit:
Inheritance graph
[legend]
Collaboration diagram for llvm::DWARFUnit:
Collaboration graph
[legend]

Public Member Functions

 DWARFUnit (DWARFContext &Context, const DWARFSection &Section, const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA, const DWARFSection *RS, const DWARFSection *LocSection, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool LE, bool IsDWO, const DWARFUnitVector &UnitVector)
 
virtual ~DWARFUnit ()
 
bool isDWOUnit () const
 
DWARFContextgetContext () const
 
const DWARFSectiongetInfoSection () const
 
const DWARFSectiongetLocSection () const
 
StringRef getLocSectionData () const
 
uint32_t getOffset () const
 
const dwarf::FormParamsgetFormParams () const
 
uint16_t getVersion () const
 
uint8_t getAddressByteSize () const
 
uint8_t getRefAddrByteSize () const
 
uint8_t getDwarfOffsetByteSize () const
 
uint32_t getLength () const
 
uint8_t getUnitType () const
 
bool isTypeUnit () const
 
uint32_t getNextUnitOffset () const
 
const DWARFSectiongetLineSection () const
 
StringRef getStringSection () const
 
const DWARFSectiongetStringOffsetSection () const
 
void setAddrOffsetSection (const DWARFSection *AOS, uint32_t Base)
 
void updateAddressDieMap (DWARFDie Die)
 Recursively update address to Die map. More...
 
void setRangesSection (const DWARFSection *RS, uint32_t Base)
 
Optional< object::SectionedAddressgetAddrOffsetSectionItem (uint32_t Index) const
 
Optional< uint64_t > getStringOffsetSectionItem (uint32_t Index) const
 
DWARFDataExtractor getDebugInfoExtractor () const
 
DataExtractor getStringExtractor () const
 
Error extractRangeList (uint32_t RangeListOffset, DWARFDebugRangeList &RangeList) const
 Extract the range list referenced by this compile unit from the .debug_ranges section. More...
 
void clear ()
 
const Optional< StrOffsetsContributionDescriptor > & getStringOffsetsTableContribution () const
 
uint8_t getDwarfStringOffsetsByteSize () const
 
uint64_t getStringOffsetsBase () const
 
const DWARFAbbreviationDeclarationSetgetAbbreviations () const
 
llvm::Optional< object::SectionedAddressgetBaseAddress ()
 
DWARFDie getUnitDIE (bool ExtractUnitDIEOnly=true)
 
DWARFDie getNonSkeletonUnitDIE (bool ExtractUnitDIEOnly=true)
 
const chargetCompilationDir ()
 
Optional< uint64_t > getDWOId ()
 
void setDWOId (uint64_t NewID)
 
Expected< DWARFAddressRangesVectorfindRnglistFromOffset (uint32_t Offset)
 Return a vector of address ranges resulting from a (possibly encoded) range list starting at a given offset in the appropriate ranges section. More...
 
Expected< DWARFAddressRangesVectorfindRnglistFromIndex (uint32_t Index)
 Return a vector of address ranges retrieved from an encoded range list whose offset is found via a table lookup given an index (DWARF v5 and later). More...
 
Optional< uint32_tgetRnglistOffset (uint32_t Index)
 Return a rangelist's offset based on an index. More...
 
Expected< DWARFAddressRangesVectorcollectAddressRanges ()
 
DWARFDie getSubroutineForAddress (uint64_t Address)
 Returns subprogram DIE with address range encompassing the provided address. More...
 
void getInlinedChainForAddress (uint64_t Address, SmallVectorImpl< DWARFDie > &InlinedChain)
 getInlinedChainForAddress - fetches inlined chain for a given address. More...
 
const DWARFUnitVectorgetUnitVector () const
 Return the DWARFUnitVector containing this unit. More...
 
unsigned getNumDIEs ()
 Returns the number of DIEs in the unit. More...
 
uint32_t getDIEIndex (const DWARFDie &D)
 Return the index of a DIE inside the unit's DIE vector. More...
 
DWARFDie getDIEAtIndex (unsigned Index)
 Return the DIE object at the given index. More...
 
DWARFDie getParent (const DWARFDebugInfoEntry *Die)
 
DWARFDie getSibling (const DWARFDebugInfoEntry *Die)
 
DWARFDie getPreviousSibling (const DWARFDebugInfoEntry *Die)
 
DWARFDie getFirstChild (const DWARFDebugInfoEntry *Die)
 
DWARFDie getLastChild (const DWARFDebugInfoEntry *Die)
 
DWARFDie getDIEForOffset (uint32_t Offset)
 Return the DIE object for a given offset inside the unit's DIE vector. More...
 
uint32_t getLineTableOffset () const
 
die_iterator_range dies ()
 
virtual void dump (raw_ostream &OS, DIDumpOptions DumpOpts)=0
 

Static Public Member Functions

static bool isMatchingUnitTypeAndTag (uint8_t UnitType, dwarf::Tag Tag)
 
static uint32_t getDWARF5HeaderSize (uint8_t UnitType)
 Return the number of bytes for the header of a unit of UnitType type. More...
 

Protected Member Functions

const DWARFUnitHeadergetHeader () const
 
uint32_t getHeaderSize () const
 Size in bytes of the parsed unit header. More...
 
Optional< StrOffsetsContributionDescriptordetermineStringOffsetsTableContribution (DWARFDataExtractor &DA)
 Find the unit's contribution to the string offsets table and determine its length and form. More...
 
Optional< StrOffsetsContributionDescriptordetermineStringOffsetsTableContributionDWO (DWARFDataExtractor &DA)
 Find the unit's contribution to the string offsets table and determine its length and form. More...
 

Detailed Description

Definition at line 188 of file DWARFUnit.h.

Constructor & Destructor Documentation

◆ DWARFUnit()

DWARFUnit::DWARFUnit ( DWARFContext Context,
const DWARFSection Section,
const DWARFUnitHeader Header,
const DWARFDebugAbbrev DA,
const DWARFSection RS,
const DWARFSection LocSection,
StringRef  SS,
const DWARFSection SOS,
const DWARFSection AOS,
const DWARFSection LS,
bool  LE,
bool  IsDWO,
const DWARFUnitVector UnitVector 
)

◆ ~DWARFUnit()

DWARFUnit::~DWARFUnit ( )
virtualdefault

Referenced by DWARFUnit().

Member Function Documentation

◆ clear()

void DWARFUnit::clear ( )

Definition at line 332 of file DWARFUnit.cpp.

Referenced by DWARFUnit().

◆ collectAddressRanges()

Expected< DWARFAddressRangesVector > DWARFUnit::collectAddressRanges ( )

◆ determineStringOffsetsTableContribution()

Optional< StrOffsetsContributionDescriptor > DWARFUnit::determineStringOffsetsTableContribution ( DWARFDataExtractor DA)
protected

Find the unit's contribution to the string offsets table and determine its length and form.

The given offset is expected to be derived from the unit DIE's DW_AT_str_offsets_base attribute.

Definition at line 806 of file DWARFUnit.cpp.

References llvm::find(), getUnitDIE(), parseDWARF32StringOffsetsTableHeader(), parseDWARF64StringOffsetsTableHeader(), llvm::dwarf::toSectionOffset(), and llvm::StrOffsetsContributionDescriptor::validateContributionSize().

Referenced by getCompilationDir().

◆ determineStringOffsetsTableContributionDWO()

Optional< StrOffsetsContributionDescriptor > DWARFUnit::determineStringOffsetsTableContributionDWO ( DWARFDataExtractor DA)
protected

Find the unit's contribution to the string offsets table and determine its length and form.

The given offset is expected to be 0 in a dwo file or, in a dwp file, the start of the unit's contribution to the string offsets table section (as determined by the index table).

Definition at line 820 of file DWARFUnit.cpp.

References C, llvm::DWARFSection::Data, llvm::DW_SECT_STR_OFFSETS, llvm::dwarf::DWARF32, llvm::DWARFUnitHeader::getIndexEntry(), getVersion(), llvm::None, parseDWARF32StringOffsetsTableHeader(), parseDWARF64StringOffsetsTableHeader(), and llvm::StringRef::size().

Referenced by getCompilationDir().

◆ dies()

die_iterator_range llvm::DWARFUnit::dies ( )
inline

Definition at line 487 of file DWARFUnit.h.

References llvm::dump(), and llvm::DWARFUnitHeader::getLength().

◆ dump()

virtual void llvm::DWARFUnit::dump ( raw_ostream OS,
DIDumpOptions  DumpOpts 
)
pure virtual

◆ extractRangeList()

Error DWARFUnit::extractRangeList ( uint32_t  RangeListOffset,
DWARFDebugRangeList RangeList 
) const

Extract the range list referenced by this compile unit from the .debug_ranges section.

If the extraction is unsuccessful, an error is returned. Successful extraction requires that the compile unit has already been extracted.

Definition at line 322 of file DWARFUnit.cpp.

References assert(), llvm::DWARFDebugRangeList::extract(), getAddressByteSize(), and llvm::DWARFContext::getDWARFObj().

Referenced by findRnglistFromOffset().

◆ findRnglistFromIndex()

Expected< DWARFAddressRangesVector > DWARFUnit::findRnglistFromIndex ( uint32_t  Index)

Return a vector of address ranges retrieved from an encoded range list whose offset is found via a table lookup given an index (DWARF v5 and later).

Definition at line 556 of file DWARFUnit.cpp.

References llvm::createStringError(), findRnglistFromOffset(), getRnglistOffset(), and llvm::invalid_argument.

◆ findRnglistFromOffset()

Expected< DWARFAddressRangesVector > DWARFUnit::findRnglistFromOffset ( uint32_t  Offset)

Return a vector of address ranges resulting from a (possibly encoded) range list starting at a given offset in the appropriate ranges section.

Definition at line 535 of file DWARFUnit.cpp.

References llvm::createStringError(), E, extractRangeList(), llvm::DWARFDebugRangeList::getAbsoluteRanges(), getBaseAddress(), llvm::DWARFContext::getDWARFObj(), getVersion(), and llvm::invalid_argument.

Referenced by findRnglistFromIndex().

◆ getAbbreviations()

const DWARFAbbreviationDeclarationSet * DWARFUnit::getAbbreviations ( ) const

◆ getAddressByteSize()

uint8_t llvm::DWARFUnit::getAddressByteSize ( ) const
inline

◆ getAddrOffsetSectionItem()

Optional< object::SectionedAddress > DWARFUnit::getAddrOffsetSectionItem ( uint32_t  Index) const

◆ getBaseAddress()

llvm::Optional< object::SectionedAddress > DWARFUnit::getBaseAddress ( )

◆ getCompilationDir()

const char * DWARFUnit::getCompilationDir ( )

◆ getContext()

DWARFContext& llvm::DWARFUnit::getContext ( ) const
inline

Definition at line 270 of file DWARFUnit.h.

References Context.

Referenced by dumpAttribute(), dumpLocation(), and llvm::DWARFFormValue::extractValue().

◆ getDebugInfoExtractor()

DWARFDataExtractor DWARFUnit::getDebugInfoExtractor ( ) const

◆ getDIEAtIndex()

DWARFDie llvm::DWARFUnit::getDIEAtIndex ( unsigned  Index)
inline

Return the DIE object at the given index.

Definition at line 454 of file DWARFUnit.h.

References assert(), and getParent().

Referenced by llvm::DWARFVerifier::DieRangeInfo::intersects().

◆ getDIEForOffset()

DWARFDie llvm::DWARFUnit::getDIEForOffset ( uint32_t  Offset)
inline

Return the DIE object for a given offset inside the unit's DIE vector.

The unit needs to have its DIEs extracted for this method to work.

Definition at line 469 of file DWARFUnit.h.

References assert(), llvm::bsearch(), and llvm::DWARFDebugInfoEntry::getOffset().

Referenced by llvm::DWARFTypeUnit::dump(), llvm::DWARFExpression::Operation::print(), and llvm::DWARFExpression::Operation::verify().

◆ getDIEIndex()

uint32_t llvm::DWARFUnit::getDIEIndex ( const DWARFDie D)
inline

Return the index of a DIE inside the unit's DIE vector.

It is illegal to call this method with a DIE that hasn't be created by this unit. In other word, it's illegal to call this method on a DIE that isn't accessible by following children/sibling links starting from this unit's getUnitDIE().

Definition at line 449 of file DWARFUnit.h.

References llvm::DWARFDie::getDebugInfoEntry().

◆ getDWARF5HeaderSize()

static uint32_t llvm::DWARFUnit::getDWARF5HeaderSize ( uint8_t  UnitType)
inlinestatic

Return the number of bytes for the header of a unit of UnitType type.

This function must be called with a valid unit type which in DWARF5 is defined as one of the following six types.

Definition at line 364 of file DWARFUnit.h.

References llvm_unreachable.

◆ getDwarfOffsetByteSize()

uint8_t llvm::DWARFUnit::getDwarfOffsetByteSize ( ) const
inline

◆ getDwarfStringOffsetsByteSize()

uint8_t llvm::DWARFUnit::getDwarfStringOffsetsByteSize ( ) const
inline

Definition at line 330 of file DWARFUnit.h.

References assert().

Referenced by getStringOffsetSectionItem().

◆ getDWOId()

Optional<uint64_t> llvm::DWARFUnit::getDWOId ( )
inline

Definition at line 396 of file DWARFUnit.h.

Referenced by llvm::DWARFCompileUnit::dump(), and getCompilationDir().

◆ getFirstChild()

DWARFDie DWARFUnit::getFirstChild ( const DWARFDebugInfoEntry Die)

Definition at line 715 of file DWARFUnit.cpp.

References llvm::DWARFDebugInfoEntry::hasChildren(), and I.

◆ getFormParams()

const dwarf::FormParams& llvm::DWARFUnit::getFormParams ( ) const
inline

◆ getHeader()

const DWARFUnitHeader& llvm::DWARFUnit::getHeader ( ) const
inlineprotected

◆ getHeaderSize()

uint32_t llvm::DWARFUnit::getHeaderSize ( ) const
inlineprotected

Size in bytes of the parsed unit header.

Definition at line 244 of file DWARFUnit.h.

References llvm::DWARFUnitHeader::getSize(), llvm::AArch64CC::LE, llvm::AArch64CC::LS, and llvm::ARMBuildAttrs::Section.

Referenced by getCompilationDir().

◆ getInfoSection()

const DWARFSection& llvm::DWARFUnit::getInfoSection ( ) const
inline

Definition at line 271 of file DWARFUnit.h.

◆ getInlinedChainForAddress()

void DWARFUnit::getInlinedChainForAddress ( uint64_t  Address,
SmallVectorImpl< DWARFDie > &  InlinedChain 
)

getInlinedChainForAddress - fetches inlined chain for a given address.

Returns empty chain if there is no subprogram containing address. The chain is valid as long as parsed compile unit DIEs are not cleared.

Definition at line 628 of file DWARFUnit.cpp.

References assert(), llvm::SmallVectorBase::empty(), llvm::DWARFDie::getParent(), getSubroutineForAddress(), llvm::DWARFDie::getTag(), llvm::DWARFDie::isSubprogramDIE(), and llvm::SmallVectorTemplateBase< T >::push_back().

Referenced by getFunctionNameAndStartLineForAddress(), and llvm::DWARFContext::getInliningInfoForAddress().

◆ getLastChild()

DWARFDie DWARFUnit::getLastChild ( const DWARFDebugInfoEntry Die)

◆ getLength()

uint32_t llvm::DWARFUnit::getLength ( ) const
inline

◆ getLineSection()

const DWARFSection& llvm::DWARFUnit::getLineSection ( ) const
inline

Definition at line 288 of file DWARFUnit.h.

Referenced by llvm::DWARFContext::getLineTableForUnit().

◆ getLineTableOffset()

uint32_t llvm::DWARFUnit::getLineTableOffset ( ) const
inline

◆ getLocSection()

const DWARFSection* llvm::DWARFUnit::getLocSection ( ) const
inline

Definition at line 272 of file DWARFUnit.h.

Referenced by dumpLocation().

◆ getLocSectionData()

StringRef llvm::DWARFUnit::getLocSectionData ( ) const
inline

Definition at line 273 of file DWARFUnit.h.

Referenced by dumpLocation().

◆ getNextUnitOffset()

uint32_t llvm::DWARFUnit::getNextUnitOffset ( ) const
inline

◆ getNonSkeletonUnitDIE()

DWARFDie llvm::DWARFUnit::getNonSkeletonUnitDIE ( bool  ExtractUnitDIEOnly = true)
inline

Definition at line 388 of file DWARFUnit.h.

◆ getNumDIEs()

unsigned llvm::DWARFUnit::getNumDIEs ( )
inline

Returns the number of DIEs in the unit.

Parses the unit if necessary.

Definition at line 438 of file DWARFUnit.h.

Referenced by llvm::DWARFVerifier::DieRangeInfo::intersects().

◆ getOffset()

uint32_t llvm::DWARFUnit::getOffset ( ) const
inline

◆ getParent()

DWARFDie DWARFUnit::getParent ( const DWARFDebugInfoEntry Die)

◆ getPreviousSibling()

DWARFDie DWARFUnit::getPreviousSibling ( const DWARFDebugInfoEntry Die)

Definition at line 696 of file DWARFUnit.cpp.

References llvm::Depth, llvm::DWARFDebugInfoEntry::getDepth(), getDepth(), and I.

◆ getRefAddrByteSize()

uint8_t llvm::DWARFUnit::getRefAddrByteSize ( ) const
inline

◆ getRnglistOffset()

Optional<uint32_t> llvm::DWARFUnit::getRnglistOffset ( uint32_t  Index)
inline

Return a rangelist's offset based on an index.

The index designates an entry in the rangelist table's offset array and is supplied by DW_FORM_rnglistx.

Definition at line 414 of file DWARFUnit.h.

References llvm::Address, and llvm::None.

Referenced by dumpAttribute(), and findRnglistFromIndex().

◆ getSibling()

DWARFDie DWARFUnit::getSibling ( const DWARFDebugInfoEntry Die)

◆ getStringExtractor()

DataExtractor llvm::DWARFUnit::getStringExtractor ( ) const
inline

Definition at line 313 of file DWARFUnit.h.

References clear().

◆ getStringOffsetsBase()

uint64_t llvm::DWARFUnit::getStringOffsetsBase ( ) const
inline

Definition at line 335 of file DWARFUnit.h.

References assert().

Referenced by getStringOffsetSectionItem().

◆ getStringOffsetSection()

const DWARFSection& llvm::DWARFUnit::getStringOffsetSection ( ) const
inline

Definition at line 290 of file DWARFUnit.h.

◆ getStringOffsetSectionItem()

Optional< uint64_t > DWARFUnit::getStringOffsetSectionItem ( uint32_t  Index) const

◆ getStringOffsetsTableContribution()

const Optional<StrOffsetsContributionDescriptor>& llvm::DWARFUnit::getStringOffsetsTableContribution ( ) const
inline

Definition at line 326 of file DWARFUnit.h.

◆ getStringSection()

StringRef llvm::DWARFUnit::getStringSection ( ) const
inline

Definition at line 289 of file DWARFUnit.h.

◆ getSubroutineForAddress()

DWARFDie DWARFUnit::getSubroutineForAddress ( uint64_t  Address)

Returns subprogram DIE with address range encompassing the provided address.

The pointer is alive as long as parsed compile unit DIEs are not cleared.

Definition at line 613 of file DWARFUnit.cpp.

References getUnitDIE(), and updateAddressDieMap().

Referenced by llvm::DWARFContext::getDIEsForAddress(), and getInlinedChainForAddress().

◆ getUnitDIE()

DWARFDie llvm::DWARFUnit::getUnitDIE ( bool  ExtractUnitDIEOnly = true)
inline

◆ getUnitType()

uint8_t llvm::DWARFUnit::getUnitType ( ) const
inline

◆ getUnitVector()

const DWARFUnitVector& llvm::DWARFUnit::getUnitVector ( ) const
inline

Return the DWARFUnitVector containing this unit.

Definition at line 434 of file DWARFUnit.h.

◆ getVersion()

uint16_t llvm::DWARFUnit::getVersion ( ) const
inline

◆ isDWOUnit()

bool llvm::DWARFUnit::isDWOUnit ( ) const
inline

Definition at line 269 of file DWARFUnit.h.

Referenced by dumpLocation().

◆ isMatchingUnitTypeAndTag()

static bool llvm::DWARFUnit::isMatchingUnitTypeAndTag ( uint8_t  UnitType,
dwarf::Tag  Tag 
)
inlinestatic

Definition at line 342 of file DWARFUnit.h.

References llvm::dwarf::isUnitType().

Referenced by llvm::DWARFVerifier::DieRangeInfo::intersects().

◆ isTypeUnit()

bool llvm::DWARFUnit::isTypeUnit ( ) const
inline

◆ setAddrOffsetSection()

void llvm::DWARFUnit::setAddrOffsetSection ( const DWARFSection AOS,
uint32_t  Base 
)
inline

Definition at line 294 of file DWARFUnit.h.

◆ setDWOId()

void llvm::DWARFUnit::setDWOId ( uint64_t  NewID)
inline

Definition at line 400 of file DWARFUnit.h.

References llvm::DWARFUnitHeader::setDWOId().

◆ setRangesSection()

void llvm::DWARFUnit::setRangesSection ( const DWARFSection RS,
uint32_t  Base 
)
inline

Definition at line 302 of file DWARFUnit.h.

Referenced by getCompilationDir().

◆ updateAddressDieMap()

void DWARFUnit::updateAddressDieMap ( DWARFDie  Die)

Member Data Documentation

◆ LocSection

const DWARFSection* llvm::DWARFUnit::LocSection

Definition at line 200 of file DWARFUnit.h.

◆ LocSectionData

StringRef llvm::DWARFUnit::LocSectionData

Definition at line 201 of file DWARFUnit.h.

Referenced by DWARFUnit().


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