class DwarfDieDecoder

Defined at line 39 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.h

Decodes the desired attributes of a given DWARF Debug Info Entry ("DIE").

This transparently follows DW_AT_abstract_origin attributes. This is used to implement

"inheritance" of DIEs.

To use, create once for the unit and register the output variables with the Add* functions. Then

loop through the relevant entries. In the loop first reset() the output variables (so you can

tell which were set), then call Decode().

Public Members

llvm::DWARFContext * context_
vector attrs_
llvm::DWARFDie * abstract_parent_
vector seen_attrs_

Public Methods

void DwarfDieDecoder (llvm::DWARFContext * context)

The context/binary must outlive this class. Prefer the DwarfBinary version when possible.

Defined at line 25 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void DwarfDieDecoder (DwarfBinary & binary)

Defined at line 27 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void ~DwarfDieDecoder ()

Defined at line 29 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddPresenceCheck (llvm::dwarf::Attribute attribute, bool * present)

Adds a check for the given attribute. If the attribute is encountered, the given boolean will

be set to true. You can share a bool pointer between different calls to AddPresenceCheck() to

check if any of a set of attributes is available. It does not check the type of validity of the

attribute.

The output pointer must remain valid until the last call to Decode() has returned.

Defined at line 31 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddBool (llvm::dwarf::Attribute attribute, std::optional<bool> * output)

These register for a given attribute, and call the similarly-named function in

llvm::DWARFFormValue to extract the attribute and place it into the given output variable.

The output pointers must remain valid until the last call to Decode() has returned.

Defined at line 36 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddUnsignedConstant (llvm::dwarf::Attribute attribute, std::optional<uint64_t> * output)

Defined at line 42 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddSignedConstant (llvm::dwarf::Attribute attribute, std::optional<int64_t> * output)

Defined at line 49 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddAddress (llvm::dwarf::Attribute attribute, std::optional<uint64_t> * output)

Defined at line 56 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddHighPC (std::optional<HighPC> * output)

Defined at line 63 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddCString (llvm::dwarf::Attribute attribute, std::optional<const char *> * output)

Defined at line 78 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddLineTableFile (llvm::dwarf::Attribute attribute, std::optional<std::string> * output)

Defined at line 87 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddConstValue (llvm::dwarf::Attribute attribute, ConstValue * const_value)

Defined at line 105 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddSectionOffset (llvm::dwarf::Attribute attribute, std::optional<uint64_t> * offset)

Defined at line 129 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddBlock (llvm::dwarf::Attribute attribute, std::optional<std::vector<uint8_t>> * block)

Defined at line 140 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddReference (llvm::dwarf::Attribute attribute, llvm::DWARFDie * output)

For cross-DIE references. Note that the resulting DIE may not be in the same unit. If the

attribute doesn't exist or is invalid, this DIE will be !isValid().

Defined at line 151 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void DwarfDieDecoder (const DwarfDieDecoder & )

Defined at line 157 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.h

DwarfDieDecoder & operator= (const DwarfDieDecoder & )

Defined at line 157 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.h

void AddFile (llvm::dwarf::Attribute attribute, std::optional<std::string> * output)

Extract a file name. File names (e.g. for DW_AT_decl_file) are not strings but rather indices

into the file name table for the corresponding unit. This accessor resolves the string

automatically.

Defined at line 158 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddAbstractParent (llvm::DWARFDie * output)

A special handler to get the parent of the most deep abstract origin.

Most DIEs can have an "abstract origin" which is another DIE that underlays values.

Theoretically abstract origins can be linked into arbitrarily long chains. In the current Clang

this mostly happens for inlined functions, where the inlined instance references the actual

function definition as its abstract origin. But abstract origins can theoretically appear

almost anywhere.

Normally this class handles abstract origins transparently when querying attributes. But the

parent DIE is not an attribute so needs to be handled explicitly. In the example of inlined

functions, the parent of the inlined subroutine DIE will be the block it's inlined into, but

the parent of the abstract origin will be the namespace or class that lexically encloses that

function.

This function will cause the parent of the deepest abstract origin to be placed into the given

output when the DIE is decoded.

If there is no abstract origin, this will be filled in with the regular parent of the DIE. The

only case the output should be !isValid() is when decoding a toplevel DIE with no parent.

Defined at line 181 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

void AddCustom (llvm::dwarf::Attribute attribute, AttributeHandler callback)

Extracts data with a custom callback. When the attribute is encountered, the callback is

executed with the associated form value. This can be used to cover attributes that could be

encoded using multiple different encodings.

Defined at line 186 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

bool Decode (const llvm::DWARFDie & die)

Decode one info entry. Returns true on success, false means the DIE was corrupt. The outputs

for each encountered attribute will be set.

Defined at line 190 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

bool DecodeInternal (const llvm::DWARFDie & die, int abstract_origin_refs_to_follow)

Backend for Decode() above.

Following abstract origins generates a recursive call. To prevent infinite recursion for

corrupt symbols, this function takes a maximum number of abstract origin references to follow

which is decremented each time a recursive call is made. When this gets to 0, no more abstract

origin references will be followed.

Defined at line 195 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

llvm::DWARFDie DecodeReference (llvm::DWARFUnit * unit, const llvm::DWARFFormValue & form)

Decodes a cross-DIE reference. Return value will be !isValid() on failure.

Defined at line 302 of file ../../src/developer/debug/zxdb/symbols/dwarf_die_decoder.cc

Records