Debug Info

PDB and DWARF shares similar traits which are abstracted by the following classes:

C++

DebugInfo

class DebugInfo

This class provides a generic interface for accessing debug information from different formats such as DWARF and PDB.

Users can use this interface to access high-level debug features like resolving function addresses.

See: LIEF::pdb::DebugInfo, LIEF::dwarf::DebugInfo

Subclassed by LIEF::dwarf::DebugInfo, LIEF::pdb::DebugInfo

Public Types

enum class FORMAT

Values:

enumerator UNKNOWN = 0
enumerator DWARF
enumerator PDB

Public Functions

DebugInfo(std::unique_ptr<details::DebugInfo> impl)
virtual ~DebugInfo()
inline virtual FORMAT format() const
template<class T>
inline const T *as() const

This function can be used to down cast a DebugInfo instance:

std::unique_ptr<LIEF::Instruction> dbg = bin->debug_info();
if (const auto* dwarf = inst->as<LIEF::dwarf::DebugInfo>()) {
  dwarf->find_function("main");
}
virtual optional<uint64_t> find_function_address(const std::string &name) const = 0

Attempt to resolve the address of the function specified by name.

Friends

friend class Binary

debug_location_t

struct debug_location_t

This structure holds a debug location (source filename & line).

Public Members

std::string file
uint64_t line = 0

DeclOpt

struct DeclOpt

Configuration options for generated code from debug info.

This structure configures how the debug information (DWARF/PDB) translated into an AST is generated.

Public Members

uint32_t indentation = 2

The number of spaces for indentation.

bool is_cpp = false

Prefer C++ syntax over C syntax.

If true, the output will use C++ features (e.g., bool keyword)

bool show_extended_annotations = true

Enable extended comments and annotations.

If true, the generated code will include comments containing low-level details such as memory addresses, offsets, type sizes, and original source locations.

bool include_types = false

Include full type definitions.

If true, the output will contain the full definition of types (structs, enums, unions).

bool desugar = true

Resolve type aliases (sugar).

If true, typedefs and type aliases are replaced by their underlying canonical types (e.g., uint32_t might become unsigned int).


Python

DebugInfo

class lief.DebugInfo

Bases: object

This class provides a generic interface for accessing debug information from different formats such as DWARF and PDB.

Users can use this interface to access high-level debug features like resolving function addresses.

See: DebugInfo, lief.dwarf.DebugInfo

class FORMAT(*values)

Bases: Enum

DWARF = 1
PDB = 2
UNKNOWN = 0
from_value(arg: int) lief.DebugInfo.FORMAT = <nanobind.nb_func object>
find_function_address(self, name: str) int | None

Attempt to resolve the address of the function specified by name.

property format lief.DebugInfo.FORMAT

The actual debug format (PDB/DWARF)

debug_location_t

class lief.debug_location_t

Bases: object

property file str
property line int

DeclOpt

class lief.DeclOpt(self)

Bases: object

Configuration options for generated code from debug info.

This structure configures how the debug information (DWARF/PDB) translated into an AST is generated.

property desugar bool

Resolve type aliases (sugar).

If true, typedef``s and type aliases are replaced by their underlying canonical types (e.g., ``uint32_t might become unsigned int).

property include_types bool

Include full type definitions.

If true, the output will contain the full definition of types (structs, enums, unions).

property indentation int

The number of spaces for indentation.

property is_cpp bool

Prefer C++ syntax over C syntax.

If true, the output will use C++ features (e.g., bool keyword)

property show_extended_annotations bool

Enable extended comments and annotations.

If true, the generated code will include comments containing low-level details such as memory addresses, offsets, type sizes, and original source locations.


Rust