class DWARFDie

Declaration

class DWARFDie { /* full declaration omitted */ };

Description

Utility class that carries the DWARF compile/type unit and the debug info entry in an object. When accessing information from a debug info entry we always need to DWARF compile/type unit in order to extract the info correctly as some information is relative to the compile/type unit. Prior to this class the DWARFUnit and the DWARFDebugInfoEntry was passed around separately and there was the possibility for error if the wrong DWARFUnit was used to extract a unit relative offset. This class helps to ensure that this doesn't happen and also simplifies the attribute extraction calls by not having to specify the DWARFUnit for each call.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:43

Member Variables

private llvm::DWARFUnit* U = nullptr
private const llvm::DWARFDebugInfoEntry* Die = nullptr

Method Overview

Methods

DWARFDie(llvm::DWARFUnit* Unit,
         const llvm::DWARFDebugInfoEntry* D)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:49

Parameters

llvm::DWARFUnit* Unit
const llvm::DWARFDebugInfoEntry* D

DWARFDie()

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:48

bool addressRangeContainsAddress(
    const uint64_t Address) const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:225

Parameters

const uint64_t Address

iterator_range<llvm::DWARFDie::attribute_iterator>
attributes() const

Description

Get an iterator range to all attributes in the current DIE only.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:281

Returns

an iterator range for the attributes of the current DIE.

llvm::DWARFDie::iterator begin() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:292

iterator_range<llvm::DWARFDie::iterator>
children() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:298

void dump() const

Description

Convenience zero-argument overload for debugging.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:131

void dump(llvm::raw_ostream& OS,
          unsigned int indent = 0,
          llvm::DIDumpOptions DumpOpts =
              llvm::DIDumpOptions()) const

Description

Dump the DIE and all of its attributes to the supplied stream.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:127

Parameters

llvm::raw_ostream& OS
the stream to use for output.
unsigned int indent = 0
the number of characters to indent each line that is output.
llvm::DIDumpOptions DumpOpts = llvm::DIDumpOptions()

llvm::DWARFDie::iterator end() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:293

Optional<llvm::DWARFFormValue> find(
    ArrayRef<dwarf::Attribute> Attrs) const

Description

Extract the first value of any attribute in Attrs from this DIE. Extract the first attribute that matches from this DIE only. This call doesn't look for the attribute value in any DW_AT_specification or DW_AT_abstract_origin referenced DIEs. The attributes will be searched linearly in the order they are specified within Attrs.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:155

Parameters

ArrayRef<dwarf::Attribute> Attrs
an array of DWARF attribute to look for.

Returns

an optional that has a valid DWARFFormValue for the first matching attribute in Attrs, or None if none of the attributes in Attrs exist in this DIE.

Optional<llvm::DWARFFormValue> find(
    dwarf::Attribute Attr) const

Description

Extract the specified attribute from this DIE. Extract an attribute value from this DIE only. This call doesn't look for the attribute value in any DW_AT_specification or DW_AT_abstract_origin referenced DIEs.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:142

Parameters

dwarf::Attribute Attr
the attribute to extract.

Returns

an optional DWARFFormValue that will have the form value if the attribute was successfully extracted.

Optional<llvm::DWARFFormValue> findRecursively(
    ArrayRef<dwarf::Attribute> Attrs) const

Description

Extract the first value of any attribute in Attrs from this DIE and recurse into any DW_AT_specification or DW_AT_abstract_origin referenced DIEs.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:167

Parameters

ArrayRef<dwarf::Attribute> Attrs
an array of DWARF attribute to look for.

Returns

an optional that has a valid DWARFFormValue for the first matching attribute in Attrs, or None if none of the attributes in Attrs exist in this DIE or in any DW_AT_specification or DW_AT_abstract_origin DIEs.

const llvm::DWARFAbbreviationDeclaration*
getAbbreviationDeclarationPtr() const

Description

Get the abbreviation declaration for this DIE.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:59

Returns

the abbreviation declaration or NULL for null tags.

Expected<llvm::DWARFAddressRangesVector>
getAddressRanges() const

Description

Get the address ranges for this DIE. Get the hi/low PC range if both attributes are available or exrtracts the non-contiguous address ranges from the DW_AT_ranges attribute. Extracts the range information from this DIE only. This call doesn't look for the range in any DW_AT_specification or DW_AT_abstract_origin DIEs.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:223

Returns

a address range vector that might be empty if no address range information is available.

llvm::DWARFDie getAttributeValueAsReferencedDie(
    const llvm::DWARFFormValue& V) const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:183

Parameters

const llvm::DWARFFormValue& V

llvm::DWARFDie getAttributeValueAsReferencedDie(
    dwarf::Attribute Attr) const

Description

Extract the specified attribute from this DIE as the referenced DIE. Regardless of the reference type, return the correct DWARFDie instance if the attribute exists. The returned DWARFDie object might be from another DWARFUnit, but that is all encapsulated in the new DWARFDie object. Extract an attribute value from this DIE only. This call doesn't look for the attribute value in any DW_AT_specification or DW_AT_abstract_origin referenced DIEs.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:182

Parameters

dwarf::Attribute Attr
the attribute to extract.

Returns

a valid DWARFDie instance if the attribute exists, or an invalid DWARFDie object if it doesn't.

void getCallerFrame(
    uint32_t& CallFile,
    uint32_t& CallLine,
    uint32_t& CallColumn,
    uint32_t& CallDiscriminator) const

Description

Retrieves values of DW_AT_call_file, DW_AT_call_line and DW_AT_call_column from DIE (or zeroes if they are missing). This function looks for DW_AT_call attributes in this DIE only, it will not resolve the attribute values in any DW_AT_specification or DW_AT_abstract_origin DIEs.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:273

Parameters

uint32_t& CallFile
filled in with non-zero if successful, zero if there is no DW_AT_call_file attribute in this DIE.
uint32_t& CallLine
filled in with non-zero if successful, zero if there is no DW_AT_call_line attribute in this DIE.
uint32_t& CallColumn
filled in with non-zero if successful, zero if there is no DW_AT_call_column attribute in this DIE.
uint32_t& CallDiscriminator
filled in with non-zero if successful, zero if there is no DW_AT_GNU_discriminator attribute in this DIE.

const llvm::DWARFDebugInfoEntry*
getDebugInfoEntry() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:53

std::string getDeclFile(
    DILineInfoSpecifier::FileLineInfoKind Kind)
    const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:259

Parameters

DILineInfoSpecifier::FileLineInfoKind Kind

uint64_t getDeclLine() const

Description

Returns the declaration line (start line) for a DIE, assuming it specifies a subprogram. This may be fetched from specification or abstract origin for this subprogram by resolving DW_AT_sepcification or DW_AT_abstract_origin references if necessary.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:258

llvm::DWARFUnit* getDwarfUnit() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:54

llvm::DWARFDie getFirstChild() const

Description

Get the first child of this DIE object.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:115

Returns

a valid DWARFDie instance if this object has children or an invalid DWARFDie instance if it doesn't.

void getFullName(
    llvm::raw_string_ostream&,
    std::string* OriginalFullName = nullptr) const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:241

Parameters

llvm::raw_string_ostream&
std::string* OriginalFullName = nullptr

Optional<uint64_t> getHighPC(uint64_t LowPC) const

Description

Get the DW_AT_high_pc attribute value as an address. In DWARF version 4 and later the high PC can be encoded as an offset from the DW_AT_low_pc. This function takes care of extracting the value as an address or offset and adds it to the low PC if needed and returns the value as an optional in case the DIE doesn't have a DW_AT_high_pc attribute.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:206

Parameters

uint64_t LowPC
the low PC that might be needed to calculate the high PC.

Returns

an optional address value for the attribute.

llvm::DWARFDie getLastChild() const

Description

Get the last child of this DIE object.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:121

Returns

a valid null DWARFDie instance if this object has children or an invalid DWARFDie instance if it doesn't.

const char* getLinkageName() const

Description

Return the DIE linkage name resolving DW_AT_specification or DW_AT_abstract_origin references if necessary. Returns null if no name is found.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:252

Optional<uint64_t> getLocBaseAttribute() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:194

Expected<llvm::DWARFLocationExpressionsVector>
getLocations(dwarf::Attribute Attr) const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:228

Parameters

dwarf::Attribute Attr

bool getLowAndHighPC(uint64_t& LowPC,
                     uint64_t& HighPC,
                     uint64_t& SectionIndex) const

Description

Retrieves DW_AT_low_pc and DW_AT_high_pc from CU. Returns true if both attributes are present.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:210

Parameters

uint64_t& LowPC
uint64_t& HighPC
uint64_t& SectionIndex

const char* getName(llvm::DINameKind Kind) const

Description

Return the DIE name resolving DW_AT_specification or DW_AT_abstract_origin references if necessary. For the LinkageName case it additionaly searches for ShortName if LinkageName is not found. Returns null if no name is found.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:240

Parameters

llvm::DINameKind Kind

uint64_t getOffset() const

Description

Get the absolute offset into the debug info or types section.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:67

Returns

the DIE offset or -1U if invalid.

llvm::DWARFDie getParent() const

Description

Get the parent of this DIE object.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:97

Returns

a valid DWARFDie instance if this object has a parent or an invalid DWARFDie instance if it doesn't.

llvm::DWARFDie getPreviousSibling() const

Description

Get the previous sibling of this DIE object.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:109

Returns

a valid DWARFDie instance if this object has a sibling or an invalid DWARFDie instance if it doesn't.

Optional<uint64_t> getRangesBaseAttribute() const

Description

Extract the range base attribute from this DIE as absolute section offset. This is a utility function that checks for either the DW_AT_rnglists_base or DW_AT_GNU_ranges_base attribute.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:193

Returns

anm optional absolute section offset value for the attribute.

const char* getShortName() const

Description

Return the DIE short name resolving DW_AT_specification or DW_AT_abstract_origin references if necessary. Returns null if no name is found.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:247

llvm::DWARFDie getSibling() const

Description

Get the sibling of this DIE object.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:103

Returns

a valid DWARFDie instance if this object has a sibling or an invalid DWARFDie instance if it doesn't.

const char* getSubroutineName(
    llvm::DINameKind Kind) const

Description

If a DIE represents a subprogram (or inlined subroutine), returns its mangled name (or short name, if mangled is missing). This name may be fetched from specification or abstract origin for this subprogram. Returns null if no name is found.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:234

Parameters

llvm::DINameKind Kind

dwarf::Tag getTag() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:72

Optional<uint64_t> getTypeSize(
    uint64_t PointerSize)

Description

Gets the type size (in bytes) for this DIE.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:288

Parameters

uint64_t PointerSize
the pointer size of the containing CU.

Returns

if this is a type DIE, or this DIE contains a DW_AT_type, returns the size of the type.

bool hasChildren() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:79

bool isNULL() const

Description

Returns true for a valid DIE that terminates a sibling chain.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:85

bool isSubprogramDIE() const

Description

Returns true if DIE represents a subprogram (not inlined).

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:88

bool isSubroutineDIE() const

Description

Returns true if DIE represents a subprogram or an inlined subroutine.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:91

bool isValid() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:51

bool operator bool() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:52

std::reverse_iterator<iterator> rbegin() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:295

std::reverse_iterator<iterator> rend() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:296

llvm::DWARFDie resolveTypeUnitReference() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h:185