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
.
Return an iterator over the functions imported in this compilation unit but not implemented.
For instance with this code:
#include <cstdio>
int main() {
printf("Hello\n");
return 0;
}
printf
is imported from the standard libc so the function is returned by the iterator. On the other hand, main()
is implemented in this compilation unit so it is not returned by imported_function() but functions().
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 Types
Iterator over the variables defined in the scope of this function.
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.
Whether the function is defined outside the current compilation unit (DW_AT_external
).
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.
Return the function’s parameters (including any template parameter)
List of exceptions (types) that can be thrown by the function.
For instance, given this Swift code:
func summarize(_ ratings: [Int]) throws(StatisticsError) {
// ...
}
thrown_types() returns one element associated with the Type: StatisticsError
.
Disassemble the current function by returning an iterator over the assembly::Instruction.
Public Types
Public Functions
Friends
This class represents a DWARF parameter which can be either:
A regular function parameter (see: parameters::Formal)
A template type parameter (see: parameters::TemplateType)
A template value parameter (see: parameters::TemplateValue)
Subclassed by LIEF::dwarf::parameters::Formal, LIEF::dwarf::parameters::TemplateType, LIEF::dwarf::parameters::TemplateValue
Public Types
This class represents a regular function parameter.
For instance, given this prototype:
int main(int argc, const char** argv);
The function main
has two parameters::Formal parameters:
argc
(Parameter::name) typed as int
(types::Base from Parameter::type)
argv
(Parameter::name) typed as const char**
(types::Const from Parameter::type)
This class represents a template value parameter.
For instance, given this prototype:
template<int X = 5>
void generic();
The function generic
has one parameters::TemplateValue parameter: X
.
This class represents a template type parameter.
For instance, given this prototype:
template<class Y>
void generic();
The function generic
has one parameters::TemplateType parameter: Y
.
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_atomic_type
DW_TAG_base_type
DW_TAG_class_type
DW_TAG_coarray_type
DW_TAG_const_type
DW_TAG_dynamic_type
DW_TAG_enumeration_type
DW_TAG_file_type
DW_TAG_immutable_type
DW_TAG_interface_type
DW_TAG_packed_type
DW_TAG_pointer_type
DW_TAG_ptr_to_member_type
DW_TAG_reference_type
DW_TAG_restrict_type
DW_TAG_rvalue_reference_type
DW_TAG_set_type
DW_TAG_shared_type
DW_TAG_string_type
DW_TAG_structure_type
DW_TAG_subroutine_type
DW_TAG_template_alias
DW_TAG_thrown_type
DW_TAG_typedef
DW_TAG_union_type
DW_TAG_unspecified_type
DW_TAG_volatile_type
Subclassed by LIEF::dwarf::types::Array, LIEF::dwarf::types::Atomic, LIEF::dwarf::types::Base, LIEF::dwarf::types::ClassLike, LIEF::dwarf::types::Coarray, LIEF::dwarf::types::Const, LIEF::dwarf::types::Dynamic, LIEF::dwarf::types::Enum, LIEF::dwarf::types::File, LIEF::dwarf::types::Immutable, LIEF::dwarf::types::Interface, LIEF::dwarf::types::Pointer, LIEF::dwarf::types::PointerToMember, LIEF::dwarf::types::RValueReference, LIEF::dwarf::types::Reference, LIEF::dwarf::types::Restrict, LIEF::dwarf::types::SetTy, LIEF::dwarf::types::Shared, LIEF::dwarf::types::StringTy, LIEF::dwarf::types::Subroutine, LIEF::dwarf::types::TemplateAlias, LIEF::dwarf::types::Thrown, LIEF::dwarf::types::Typedef, LIEF::dwarf::types::Volatile
Public Types
Values:
Public Functions
Whether this type is a DW_TAG_unspecified_type
Return the type’s name using either DW_AT_name
or DW_AT_picture_string
(if any).
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 represents a DW_TAG_array_type
Public Functions
Return information about the size of this array.
This size info is usually embedded in a DW_TAG_subrange_type
DIE which is represented by the size_info_t structure.
Structure that wraps information about the dimension of this array.
Public Functions
Public Members
Type of the index for this array.
For instance in uint8_t[3]
the index type could be set to a size_t
.
Name of the index (usually not relevant like __ARRAY_SIZE_TYPE__
)
Size of the array. For instance in uint8_t[3]
, it returns 3.
This class wraps the DW_TAG_base_type
type which can be used &#8212; for instance &#8212; 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::Packed, LIEF::dwarf::types::Structure, LIEF::dwarf::types::Union
Public Types
Public Functions
Return the list of all the attributes defined in this class-like type.
Try to find the attribute at the given offset.
Iterator over the functions defined by the class-like.
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 class represents a DWARF struct
type (DW_TAG_structure_type
)
Public Functions
This class represents a DWARF class
type (DW_TAG_class_type
)
Public Functions
This class represents a DWARF class
type (DW_TAG_union_type
)
Public Functions
This class represents a DWARF packed
type (DW_TAG_packed_type
)
Public Functions
This class represents a DW_TAG_coarray_type
Public Functions
This class represents a DW_TAG_dynamic_type
Public Functions
This class represents a DW_TAG_enumeration_type
Public Functions
This class represents a DW_TAG_file_type
Public Functions
This class represents a DW_TAG_interface_type
Public Functions
This class represents a DW_TAG_ptr_to_member_type
Public Functions
This class represents a DW_TAG_rvalue_reference_type
Public Functions
This class represents a DW_TAG_string_type
Public Functions
This class represents a DW_TAG_subroutine_type
Public Functions
Parameters of this subroutine.
This class represents a DW_TAG_template_alias
Public Functions
Parameters associated with the underlying template.