Note
You can also find the Doxygen documentation here: here
Load DWARF file from the given path.
This class represents a DWARF debug information. It can embed different compilation units which can be accessed through compilation_units() .
This class can be instantiated from LIEF::Binary::debug_info() or load()
Public Types
Iterator over the CompilationUnit.
Public Functions
Try to find the function with the given name (mangled or not)
const DebugInfo& info = ...;
if (auto func = info.find_function("_ZNSt6localeD1Ev")) {
// Found
}
if (auto func = info.find_function("std::locale::~locale()")) {
// Found
}
Try to find the function at the given virtual address.
Try to find the variable with the given name. This name can be mangled or not.
Try to find the variable at the given virtual address.
Try to find the type with the given name.
Iterator on the CompilationUnit embedded in this dwarf.
This class represents a DWARF compilation unit.
Public Types
Iterator over the dwarf::Function.
Iterator over the dwarf::Type.
Iterator over the CompilationUnit’s variables.
Public Functions
Name of the file associated with this compilation unit (e.g. test.cpp
) Return an empty string if the name is not found or can’t be resolved.
This value matches the DW_AT_name
attribute
Information about the program (or library) that generated this compilation unit. For instance, it can output: Debian clang version 17.0.6
.
It returns an empty string if the producer is not present or can’t be resolved
This value matches the DW_AT_producer
attribute
Return the path to the directory in which the compilation took place for compiling this compilation unit (e.g. /workdir/build
)
It returns an empty string if the entry is not present or can’t be resolved
This value matches the DW_AT_comp_dir
attribute
Original Language of this compilation unit.
This value matches the DW_AT_language
attribute.
Return the lowest virtual address owned by this compilation unit.
Return the highest virtual address owned by this compilation unit.
Return the size of the compilation unit according to its range of address.
If the compilation is fragmented (i.e. there are some address ranges between the lowest address and the highest that are not owned by the CU), then it returns the sum of all the address ranges owned by this CU.
If the compilation unit is not fragmented, then is basically returns high_address - low_address
.
Return a list of address ranges owned by this compilation unit.
If the compilation unit owns a contiguous range, it should return a single range.
Try to find the function whose name is given in parameter.
The provided name can be demangled
Try to find the function at the given address.
Try to find the Variable at the given address.
Try to find the Variable with the given name.
Return an iterator over the functions implemented in this compilation unit.
Note that this iterator only iterates over the functions that have a concrete implementation in the compilation unit.
For instance with this code:
inline const char* get_secret_env() {
return getenv("MY_SECRET_ENV");
}
int main() {
printf("%s", get_secret_env());
return 0;
}
The iterator will only return one function for main
since get_secret_env
is inlined and thus, its implementation is located in main
.
Public Types
Public Functions
Friends
Languages supported by the DWARF (v5) format. See: https://dwarfstd.org/languages.html.
Some languages (like C++11, C++17, ..) have a version (11, 17, …) which is stored in a dedicated attribute: version
Public Types
This class represents a DWARF function which can be associated with either: DW_TAG_subprogram
or DW_TAG_inlined_subroutine
.
Public Functions
The name of the function (DW_AT_name
)
The name of the function which is used for linking (DW_AT_linkage_name
).
This name differs from name() as it is usually mangled. The function return an empty string if the linkage name is not available.
Return the address of the function (DW_AT_entry_pc
or DW_AT_low_pc
).
Return an iterator of variables (DW_TAG_variable
) defined within the scope of this function. This includes regular stack-based variables as well as static ones.
Whether this function is created by the compiler and not present in the original source code.
Return the size taken by this function in the binary.
Ranges of virtual addresses owned by this function.
Original source code location.
Return the dwarf::Type associated with the return type of this function.
Public Types
Public Functions
Friends
This class wraps a DWARF function’s parameter.
This class materializes a scope in which Function, Variable, Type, … can be defined.
Public Types
Public Functions
Name of the scope. For instance namespace’s name or function’s name.
Represent the whole chain of all (parent) scopes using the provided separator. E.g. ns1::ns2::Class1::Struct2::Type
This class represents a DWARF variable which can be owned by a dwarf::Function or a dwarf::CompilationUnit.
Public Functions
Name of the variable (usually demangled)
The name of the variable which is used for linking (DW_AT_linkage_name
).
This name differs from name() as it is usually mangled. The function return an empty string if the linkage name is not available.
Address of the variable.
If the variable is static, it returns the virtual address where it is defined. If the variable is stack-based, it returns the relative offset from the frame based register.
If the address can’t be resolved, it returns a lief_errors.
Return the size of the variable (or a lief_errors if it can’t be resolved).
This size is defined by its type.
Whether it’s a constexpr
variable.
The original source location where the variable is defined.
Public Types
Public Functions
Friends
This class represents a DWARF Type which includes:
DW_TAG_array_type
DW_TAG_const_type
DW_TAG_pointer_type
DW_TAG_structure_type
DW_TAG_base_type
DW_TAG_class_type
DW_TAG_enumeration_type
DW_TAG_string_type
DW_TAG_union_type
DW_TAG_volatile_type
DW_TAG_unspecified_type
Subclassed by LIEF::dwarf::types::Array, LIEF::dwarf::types::Base, LIEF::dwarf::types::ClassLike, LIEF::dwarf::types::Const, LIEF::dwarf::types::Pointer
Public Types
Public Functions
Whether this type is a DW_TAG_unspecified_type
Return the size of the type or an error if it can’t be computed.
This size should match the equivalent of sizeof(Type)
.
Return the debug location where this type is defined.
Public Types
Public Functions
Friends
This class wraps the DW_TAG_base_type
type which can be used — for instance — to represent integers or primitive types.
Public Types
Values:
Mirror DW_ATE_signed
Mirror DW_ATE_signed_char
Mirror DW_ATE_unsigned
Mirror DW_ATE_unsigned_char
Mirror DW_ATE_float
Mirror DW_ATE_boolean
Mirror DW_ATE_address
Public Functions
This class abstracts a DWARF aggregate: DW_TAG_structure_type
, DW_TAG_class_type
, DW_TAG_union_type
.
Subclassed by LIEF::dwarf::types::Class, LIEF::dwarf::types::Structure, LIEF::dwarf::types::Union
Public Functions
Return the list of all the attributes defined in this class-like type.
Try to find the attribute at the given offset.
This represents a class/struct/union attribute.
Public Functions
Name of the member.
Offset of the current member in the struct/union/class.
If the offset can’t be resolved it returns a lief_errors
Offset of the current member in bits the struct/union/class.
This function differs from offset() for aggregates using bit-field declaration:
struct S {
int flag : 4;
int opt : 1
};
Usually, offset() * 8 == bit_offset()
If the offset can’t be resolved it returns a lief_errors
This structure holds a debug location (source filename & line)