C++¶
Note
You can also find the Doxygen documentation here: here
- inline std::unique_ptr<DebugInfo> LIEF::dwarf::load(const std::string &dwarf_path)¶
Load DWARF file from the given path.
DebugInfo¶
- class DebugInfo : public LIEF::DebugInfo¶
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
- using compilation_units_it = iterator_range<CompilationUnit::Iterator>¶
Iterator over the CompilationUnit.
Public Functions
- std::unique_ptr<Function> find_function(const std::string &name) const¶
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 }
- std::unique_ptr<Function> find_function(uint64_t addr) const¶
Try to find the function at the given virtual address.
- std::unique_ptr<Variable> find_variable(const std::string &name) const¶
Try to find the variable with the given name. This name can be mangled or not.
- std::unique_ptr<Variable> find_variable(uint64_t addr) const¶
Try to find the variable at the given virtual address.
- std::unique_ptr<Type> find_type(const std::string &name) const¶
Try to find the type with the given name.
- compilation_units_it compilation_units() const¶
Iterator on the CompilationUnit embedded in this dwarf.
- virtual std::optional<uint64_t> find_function_address(const std::string &name) const override¶
Attempt to resolve the address of the function specified by
name.
- inline virtual FORMAT format() const override¶
- virtual ~DebugInfo() override = default¶
- DebugInfo(std::unique_ptr<details::DebugInfo> impl)¶
- using compilation_units_it = iterator_range<CompilationUnit::Iterator>¶
CompilationUnit¶
- class CompilationUnit¶
This class represents a DWARF compilation unit.
Public Types
- using functions_it = iterator_range<Function::Iterator>¶
Iterator over the dwarf::Function.
- using types_it = iterator_range<Type::Iterator>¶
Iterator over the dwarf::Type.
- using vars_it = iterator_range<Variable::Iterator>¶
Iterator over the CompilationUnit’s variables.
Public Functions
- CompilationUnit(std::unique_ptr<details::CompilationUnit> impl)¶
- ~CompilationUnit()¶
- std::string name() const¶
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_nameattribute
- std::string producer() const¶
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_producerattribute
- std::string compilation_dir() const¶
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_dirattribute
- Language language() const¶
Original language of this compilation unit.
This value matches the
DW_AT_languageattribute.
- uint64_t low_address() const¶
Return the lowest virtual address owned by this compilation unit.
- uint64_t high_address() const¶
Return the highest virtual address owned by this compilation unit.
- uint64_t size() const¶
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 it basically returns
high_address - low_address.
- std::vector<range_t> ranges() const¶
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.
- std::unique_ptr<Function> find_function(const std::string &name) const¶
Try to find the function whose name is given in parameter.
The provided name can be demangled
- std::unique_ptr<Function> find_function(uint64_t addr) const¶
Try to find the function at the given address.
- std::unique_ptr<Variable> find_variable(uint64_t addr) const¶
Try to find the Variable at the given address.
- std::unique_ptr<Variable> find_variable(const std::string &name) const¶
Try to find the Variable with the given name.
- functions_it functions() const¶
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
mainsinceget_secret_envis inlined and thus, its implementation is located inmain.
- functions_it imported_functions() const¶
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; }
printfis 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().
- types_it types() const¶
Return an iterator over the different types defined in this compilation unit.
- class Iterator : public LIEF::iterator_facade_base<Iterator, std::bidirectional_iterator_tag, CompilationUnit, std::ptrdiff_t, const CompilationUnit*, const CompilationUnit&>¶
Public Types
- using implementation = details::CompilationUnitIt¶
Public Functions
- Iterator()¶
- Iterator(std::unique_ptr<details::CompilationUnitIt> impl)¶
- ~Iterator()¶
- const CompilationUnit &operator*() const¶
- const CompilationUnit *operator->() const¶
- std::unique_ptr<CompilationUnit> yield()¶
Transfer ownership of the compilation unit at the current position to the caller. Returns
nullptrif the iterator is past-the-end.
- inline DerivedT operator++(int)¶
- inline DerivedT operator--(int)¶
- using implementation = details::CompilationUnitIt¶
- class Language¶
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
- using functions_it = iterator_range<Function::Iterator>¶
Function¶
- class Function¶
This class represents a DWARF function which can be associated with either:
DW_TAG_subprogramorDW_TAG_inlined_subroutine.Public Types
- using vars_it = iterator_range<Variable::Iterator>¶
Iterator over the variables defined in the scope of this function.
- using lexical_blocks_it = iterator_range<LexicalBlock::Iterator>¶
- using instructions_it = iterator_range<assembly::Instruction::Iterator>¶
Public Functions
- Function(std::unique_ptr<details::Function> impl)¶
- std::string name() const¶
The name of the function (
DW_AT_name).
- std::string linkage_name() const¶
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 returns an empty string if the linkage name is not available.
- result<uint64_t> address() const¶
Return the address of the function (
DW_AT_entry_pcorDW_AT_low_pc).
- vars_it variables() const¶
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.
- bool is_artificial() const¶
Whether this function is created by the compiler and not present in the original source code.
- bool is_external() const¶
Whether the function is defined outside the current compilation unit (
DW_AT_external).
- uint64_t size() const¶
Return the size taken by this function in the binary.
- std::vector<range_t> ranges() const¶
Ranges of virtual addresses owned by this function.
- debug_location_t debug_location() const¶
Original source code location.
- std::unique_ptr<Type> type() const¶
Return the dwarf::Type associated with the return type of this function.
- parameters_t parameters() const¶
Return the function’s parameters (including any template parameter).
- thrown_types_t thrown_types() const¶
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.
- instructions_it instructions() const¶
Disassemble the current function by returning an iterator over the assembly::Instruction.
- lexical_blocks_it lexical_blocks() const¶
Iterator over the LexicalBlock owned by this function.
- std::string description() const¶
Description (
DW_AT_description) of this function or an empty string.
- std::string to_decl(const DeclOpt &opt = DeclOpt()) const¶
Generates a C/C++ definition for this function.
- ~Function()¶
- class Iterator : public LIEF::iterator_facade_base<Iterator, std::bidirectional_iterator_tag, Function, std::ptrdiff_t, const Function*, const Function&>¶
Public Types
- using implementation = details::FunctionIt¶
Public Functions
- Iterator()¶
- Iterator(std::unique_ptr<details::FunctionIt> impl)¶
- ~Iterator()¶
- std::unique_ptr<Function> yield()¶
Transfer ownership of the function at the current position to the caller. Returns
nullptrif the iterator is past-the-end.
- inline DerivedT operator++(int)¶
- inline DerivedT operator--(int)¶
- using implementation = details::FunctionIt¶
- using vars_it = iterator_range<Variable::Iterator>¶
Parameter¶
- class Parameter¶
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
Public Functions
- Parameter() = delete¶
- std::string name() const¶
Name of the parameter.
- std::unique_ptr<Location> location() const¶
Location of this parameter. For instance it can be a specific register that is not following the calling convention.
- virtual ~Parameter()¶
Public Static Functions
- class Location¶
This class exposes information about the location of a parameter.
Subclassed by LIEF::dwarf::Parameter::RegisterLoc
Formal Parameter¶
- class Formal : public LIEF::dwarf::Parameter¶
This class represents a regular function parameter.
For instance, given this prototype:
int main(int argc, const char** argv);
The function
mainhas two parameters::Formal parameters:argc(Parameter::name) typed asint(types::Base from Parameter::type)argv(Parameter::name) typed asconst char**(types::Const from Parameter::type)
Template Value Parameter¶
- class TemplateValue : public LIEF::dwarf::Parameter¶
This class represents a template value parameter.
For instance, given this prototype:
template<int X = 5> void generic();
The function
generichas one parameters::TemplateValue parameter:X.
Template Type Parameter¶
- class TemplateType : public LIEF::dwarf::Parameter¶
This class represents a template type parameter.
For instance, given this prototype:
template<class Y> void generic();
The function
generichas one parameters::TemplateType parameter:Y.
Scope¶
- class Scope¶
This class materializes a scope in which Function, Variable, Type, … can be defined.
Public Types
Public Functions
- Scope(std::unique_ptr<details::Scope> impl)¶
- std::string name() const¶
Name of the scope. For instance namespace’s name or function’s name.
- std::string chained(const std::string &sep = "::") const¶
Represent the whole chain of all (parent) scopes using the provided separator. E.g.
ns1::ns2::Class1::Struct2::Type.
- ~Scope()¶
- Scope(std::unique_ptr<details::Scope> impl)¶
Variable¶
- class Variable¶
This class represents a DWARF variable which can be owned by a dwarf::Function or a dwarf::CompilationUnit.
Public Functions
- Variable(std::unique_ptr<details::Variable> impl)¶
- std::string name() const¶
Name of the variable (usually demangled).
- std::string linkage_name() const¶
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 returns an empty string if the linkage name is not available.
- result<int64_t> address() const¶
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.
- result<uint64_t> size() const¶
Return the size of the variable (or a lief_errors if it can’t be resolved).
This size is defined by its type.
- bool is_constexpr() const¶
Whether it’s a
constexprvariable.
- bool is_stack_based() const¶
Whether this variable is allocated on the stack.
- debug_location_t debug_location() const¶
The original source location where the variable is defined.
- std::string description() const¶
Description (
DW_AT_description) of the variable or an empty string.
- std::string to_decl(const DeclOpt &opt = DeclOpt()) const¶
Generates a C/C++ definition for this variable.
- ~Variable()¶
- class Iterator : public LIEF::iterator_facade_base<Iterator, std::bidirectional_iterator_tag, Variable, std::ptrdiff_t, const Variable*, const Variable&>¶
Public Types
- using implementation = details::VariableIt¶
Public Functions
- Iterator()¶
- Iterator(std::unique_ptr<details::VariableIt> impl)¶
- ~Iterator()¶
- std::unique_ptr<Variable> yield()¶
Transfer ownership of the variable at the current position to the caller. Returns
nullptrif the iterator is past-the-end.
- inline DerivedT operator++(int)¶
- inline DerivedT operator--(int)¶
- using implementation = details::VariableIt¶
- Variable(std::unique_ptr<details::Variable> impl)¶
LexicalBlock¶
- class LexicalBlock¶
This class represents a DWARF lexical block (
DW_TAG_lexical_block).Public Types
- using sub_blocks_it = iterator_range<Iterator>¶
Public Functions
- LexicalBlock(std::unique_ptr<details::LexicalBlock> impl)¶
- LexicalBlock() = delete¶
- LexicalBlock &operator=(const LexicalBlock&) = delete¶
- LexicalBlock(const LexicalBlock&) = delete¶
- std::string name() const¶
Return the name associated with this lexical block or an empty string.
- std::string description() const¶
Return the description associated with this lexical block or an empty string.
- sub_blocks_it sub_blocks() const¶
Return an iterator over the sub-LexicalBlock owned by this block.
- std::optional<uint64_t> addr() const¶
Return the start address of this block.
- uint64_t size() const¶
Return the size of this block as the difference of the highest address and the lowest address.
- std::optional<uint64_t> low_pc() const¶
Return the lowest virtual address owned by this block.
- std::optional<uint64_t> high_pc() const¶
Return the highest virtual address owned by this block.
- std::vector<range_t> ranges() const¶
Return a list of address ranges owned by this block.
If the lexical block owns a contiguous range, it should return a single range.
- ~LexicalBlock()¶
Public Static Functions
- static std::unique_ptr<LexicalBlock> create(std::unique_ptr<details::LexicalBlock> impl)¶
- class Iterator : public LIEF::iterator_facade_base<Iterator, std::bidirectional_iterator_tag, LexicalBlock, std::ptrdiff_t, const LexicalBlock*, const LexicalBlock&>¶
Public Types
- using implementation = details::LexicalBlockIt¶
Public Functions
- Iterator()¶
- Iterator(std::unique_ptr<details::LexicalBlockIt> impl)¶
- ~Iterator()¶
- const LexicalBlock &operator*() const¶
- const LexicalBlock *operator->() const¶
- std::unique_ptr<LexicalBlock> yield()¶
Transfer ownership of the lexical block at the current position to the caller. Returns
nullptrif the iterator is past-the-end.
- inline DerivedT operator++(int)¶
- inline DerivedT operator--(int)¶
- using implementation = details::LexicalBlockIt¶
- using sub_blocks_it = iterator_range<Iterator>¶
Type¶
- class Type¶
This class represents a DWARF Type which includes:
DW_TAG_array_typeDW_TAG_atomic_typeDW_TAG_base_typeDW_TAG_class_typeDW_TAG_coarray_typeDW_TAG_const_typeDW_TAG_dynamic_typeDW_TAG_enumeration_typeDW_TAG_file_typeDW_TAG_immutable_typeDW_TAG_interface_typeDW_TAG_packed_typeDW_TAG_pointer_typeDW_TAG_ptr_to_member_typeDW_TAG_reference_typeDW_TAG_restrict_typeDW_TAG_rvalue_reference_typeDW_TAG_set_typeDW_TAG_shared_typeDW_TAG_string_typeDW_TAG_structure_typeDW_TAG_subroutine_typeDW_TAG_template_aliasDW_TAG_thrown_typeDW_TAG_typedefDW_TAG_union_typeDW_TAG_unspecified_typeDW_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
- enum class KIND¶
Values:
- enumerator UNKNOWN = 0¶
- enumerator UNSPECIFIED¶
- enumerator BASE¶
- enumerator CONST_KIND¶
- enumerator CLASS¶
- enumerator ARRAY¶
- enumerator POINTER¶
- enumerator STRUCT¶
- enumerator UNION¶
- enumerator TYPEDEF¶
- enumerator REF¶
- enumerator SET_TYPE¶
- enumerator STRING¶
- enumerator SUBROUTINE¶
- enumerator POINTER_MEMBER¶
- enumerator PACKED¶
- enumerator FILE¶
- enumerator THROWN¶
- enumerator VOLATILE¶
- enumerator RESTRICT¶
- enumerator INTERFACE¶
- enumerator SHARED¶
- enumerator RVALREF¶
- enumerator TEMPLATE_ALIAS¶
- enumerator COARRAY¶
- enumerator DYNAMIC¶
- enumerator ATOMIC¶
- enumerator IMMUTABLE¶
- enumerator ENUM¶
- enumerator UNKNOWN = 0¶
Public Functions
- Type(std::unique_ptr<details::Type> impl)¶
- Type(details::Type &impl)¶
- virtual ~Type()¶
- inline bool is_unspecified() const¶
Whether this type is a
DW_TAG_unspecified_type.
- result<std::string> name() const¶
Return the type’s name using either
DW_AT_nameorDW_AT_picture_string(if any).
- result<uint64_t> size() const¶
Return the size of the type or an error if it can’t be computed.
This size should match the equivalent of
sizeof(Type).
- debug_location_t location() const¶
Return the debug location where this type is defined.
Array¶
- class Array : public LIEF::dwarf::Type¶
This class represents a
DW_TAG_array_type.Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline Array(Args&&... args)¶
- size_info_t size_info() const¶
Return information about the size of this array.
This size info is usually embedded in a
DW_TAG_subrange_typeDIE which is represented by the size_info_t structure.
- ~Array() override¶
- struct size_info_t¶
Structure that wraps information about the dimension of this array.
Public Functions
- inline operator bool() const¶
Public Members
- std::unique_ptr<Type> type = nullptr¶
Type of the index for this array.
For instance in
uint8_t[3]the index type could be set to asize_t.
- std::string name¶
Name of the index (usually not relevant like
__ARRAY_SIZE_TYPE__).
- size_t size = 0¶
Size of the array. For instance in
uint8_t[3], it returns 3.
- inline operator bool() const¶
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
Base¶
- class Base : public LIEF::dwarf::Type¶
This class wraps the
DW_TAG_base_typetype which can be used — for instance — to represent integers or primitive types.Public Types
- enum class ENCODING¶
Values:
- enumerator NONE = 0¶
- enumerator SIGNED¶
Mirror
DW_ATE_signed.
- enumerator SIGNED_CHAR¶
Mirror
DW_ATE_signed_char.
- enumerator UNSIGNED¶
Mirror
DW_ATE_unsigned.
- enumerator UNSIGNED_CHAR¶
Mirror
DW_ATE_unsigned_char.
- enumerator FLOAT¶
Mirror
DW_ATE_float.
- enumerator BOOLEAN¶
Mirror
DW_ATE_boolean.
- enumerator ADDRESS¶
Mirror
DW_ATE_address.
- enumerator NONE = 0¶
- enum class ENCODING¶
ClassLike¶
- class ClassLike : public LIEF::dwarf::Type¶
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
- using functions_it = iterator_range<Function::Iterator>¶
Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline ClassLike(Args&&... args)¶
- std::vector<Member> members() const¶
Return the list of all the attributes defined in this class-like type.
- std::unique_ptr<Member> find_member(uint64_t offset) const¶
Try to find the attribute at the given offset.
- functions_it functions() const¶
Iterator over the functions defined by the class-like.
- ~ClassLike() override¶
- class Member¶
This represents a class/struct/union attribute.
Public Functions
- Member(std::unique_ptr<details::Member> impl)¶
- std::string name() const¶
Name of the member.
- result<uint64_t> offset() const¶
Offset of the current member in the struct/union/class.
If the offset can’t be resolved it returns a lief_errors
- result<uint64_t> bit_offset() const¶
Offset of the current member in bits in 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
- result<uint64_t> bit_size() const¶
If the current member is a bit-field, this function returns its size in bits.
- bool is_external() const¶
- bool is_declaration() const¶
- ~Member()¶
- Member(std::unique_ptr<details::Member> impl)¶
- using functions_it = iterator_range<Function::Iterator>¶
Structure¶
Class¶
Union¶
Packed¶
Const¶
Pointer¶
Typedef¶
Atomic¶
Coarray¶
Dynamic¶
Enum¶
- class Enum : public LIEF::dwarf::Type¶
This class represents a
DW_TAG_enumeration_type.Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline Enum(Args&&... args)¶
- ~Enum() override¶
- class Entry¶
This class represents an enum entry which is essentially composed of a name and its value (integer).
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
File¶
Immutable¶
Interface¶
PointerToMember¶
- class PointerToMember : public LIEF::dwarf::Type¶
This class represents a
DW_TAG_ptr_to_member_type.Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline PointerToMember(Args&&... args)¶
- PointerToMember(const PointerToMember&) = delete¶
- PointerToMember &operator=(const PointerToMember&) = delete¶
- PointerToMember(PointerToMember&&) noexcept = default¶
- PointerToMember &operator=(PointerToMember&&) noexcept = default¶
- ~PointerToMember() override¶
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
RValueReference¶
- class RValueReference : public LIEF::dwarf::Type¶
This class represents a
DW_TAG_rvalue_reference_type.Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline RValueReference(Args&&... args)¶
- RValueReference(const RValueReference&) = delete¶
- RValueReference &operator=(const RValueReference&) = delete¶
- RValueReference(RValueReference&&) noexcept = default¶
- RValueReference &operator=(RValueReference&&) noexcept = default¶
- ~RValueReference() override¶
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
Reference¶
Restrict¶
SetTy¶
StringTy¶
Subroutine¶
- class Subroutine : public LIEF::dwarf::Type¶
This class represents a
DW_TAG_subroutine_type.Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline Subroutine(Args&&... args)¶
- Subroutine(const Subroutine&) = delete¶
- Subroutine &operator=(const Subroutine&) = delete¶
- Subroutine(Subroutine&&) noexcept = default¶
- Subroutine &operator=(Subroutine&&) noexcept = default¶
- std::unique_ptr<Type> return_type() const¶
Return the dwarf::Type associated with the return type of this function.
- parameters_t parameters() const¶
Parameters of this subroutine.
- ~Subroutine() override¶
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
TemplateAlias¶
- class TemplateAlias : public LIEF::dwarf::Type¶
This class represents a
DW_TAG_template_alias.Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline TemplateAlias(Args&&... args)¶
- TemplateAlias(const TemplateAlias&) = delete¶
- TemplateAlias &operator=(const TemplateAlias&) = delete¶
- TemplateAlias(TemplateAlias&&) noexcept = default¶
- TemplateAlias &operator=(TemplateAlias&&) noexcept = default¶
- parameters_t parameters() const¶
Parameters associated with the underlying template.
- ~TemplateAlias() override¶
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
Thrown¶
Volatile¶
Editor¶
- class Editor¶
This class exposes the main API to create DWARF information.
Public Types
Editor - CompilationUnit¶
- class CompilationUnit¶
This class represents an editable DWARF compilation unit.
Public Functions
- CompilationUnit() = delete¶
- CompilationUnit(std::unique_ptr<details::CompilationUnit> impl)¶
- CompilationUnit &set_producer(const std::string &producer)¶
Set the
DW_AT_producerproducer attribute.This attribute aims to inform about the program that generated this compilation unit (e.g.
LIEF Extended)
- std::unique_ptr<Function> create_function(const std::string &name)¶
Create a new function owned by this compilation unit.
- std::unique_ptr<Variable> create_variable(const std::string &name)¶
Create a new global variable owned by this compilation unit.
- std::unique_ptr<Type> create_generic_type(const std::string &name)¶
Create a
DW_TAG_unspecified_typetype with the given name.
- std::unique_ptr<EnumType> create_enum(const std::string &name)¶
Create an enum type (
DW_TAG_enumeration_type).
- std::unique_ptr<TypeDef> create_typedef(const std::string &name, const Type &type)¶
Create a typedef with the name provided in the first parameter which aliases the type provided in the second parameter.
- std::unique_ptr<StructType> create_structure(const std::string &name, StructType::TYPE kind = StructType::TYPE::STRUCT)¶
Create a struct-like type (struct, class, union) with the given name.
- std::unique_ptr<BaseType> create_base_type(const std::string &name, size_t size, BaseType::ENCODING encoding = BaseType::ENCODING::NONE)¶
Create a primitive type with the given name and size.
- std::unique_ptr<FunctionType> create_function_type(const std::string &name)¶
Create a function type with the given name.
- inline std::unique_ptr<PointerType> create_pointer_type(const Type &ty)¶
Create a pointer on the provided type.
- std::unique_ptr<ArrayType> create_array(const std::string &name, const Type &type, size_t count)¶
Create an array type with the given name, type and size.
- ~CompilationUnit()¶
- CompilationUnit() = delete¶
Editor - Function¶
- class Function¶
This class represents an editable DWARF function (
DW_TAG_subprogram).Public Functions
- Function() = delete¶
- Function(std::unique_ptr<details::Function> impl)¶
- Function &set_low_high(uint64_t low, uint64_t high)¶
Set the upper and lower bound addresses for this function. This assumes that the function is contiguous between
lowandhigh.Underneath, the function defines
DW_AT_low_pcandDW_AT_high_pc
- Function &set_ranges(const std::vector<range_t> &ranges)¶
Set the ranges of addresses owned by the implementation of this function by setting the
DW_AT_rangesattribute.This setter should be used for non-contiguous functions.
- Function &set_external()¶
Set the function as external by defining
DW_AT_externalto true. This means that the function is imported by the current compilation unit.
- std::unique_ptr<Parameter> add_parameter(const std::string &name, const Type &type)¶
Add a parameter to the current function.
- std::unique_ptr<Variable> create_stack_variable(const std::string &name)¶
Create a stack-based variable owned by the current function.
- std::unique_ptr<LexicalBlock> add_lexical_block(uint64_t start, uint64_t end)¶
Add a lexical block with the given range.
- std::unique_ptr<Label> add_label(uint64_t addr, const std::string &label)¶
Add a label at the given address.
- Function &add_description(const std::string &description)¶
Create a
DW_AT_descriptionentry with the description provided in parameter.
- ~Function()¶
- struct range_t¶
- class Parameter¶
This class represents a parameter of the current function (
DW_TAG_formal_parameter).
- class LexicalBlock¶
This class mirrors the
DW_TAG_lexical_blockDWARF tag.Public Functions
- LexicalBlock() = delete¶
- LexicalBlock(std::unique_ptr<details::FunctionLexicalBlock> impl)¶
- std::unique_ptr<LexicalBlock> add_block(uint64_t start, uint64_t end)¶
Create a sub-block with the given low/high addresses.
- std::unique_ptr<LexicalBlock> add_block(const std::vector<range_t> &range)¶
Create a sub-block with the given range of addresses.
- LexicalBlock &add_description(const std::string &description)¶
Create a
DW_AT_descriptionentry with the description provided in parameter.
- LexicalBlock &add_name(const std::string &name)¶
Create a
DW_AT_nameentry to associate a name to this entry.
- ~LexicalBlock()¶
- LexicalBlock() = delete¶
- class Label¶
This class mirrors the
DW_TAG_labelDWARF tag.
- Function() = delete¶
Editor - Variable¶
- class Variable¶
This class represents an editable DWARF variable which can be scoped by a function or a compilation unit (
DW_TAG_variable).Public Functions
- Variable() = delete¶
- Variable(std::unique_ptr<details::Variable> impl)¶
- Variable &set_addr(uint64_t address)¶
Set the global address of this variable. Setting this address is only relevant in the case of a static global variable. For stack variable, you should use set_stack_offset.
This function sets the
DW_AT_locationattribute
- Variable &set_stack_offset(uint64_t offset)¶
Set the stack offset of this variable.
This function sets the
DW_AT_locationattribute
- Variable &add_description(const std::string &description)¶
Create a
DW_AT_descriptionentry with the description provided in parameter.
- ~Variable()¶
- Variable() = delete¶
Editor - Type¶
- class Type¶
This class is the base class for any types created when editing DWARF debug info.
A type is owned by a LIEF::dwarf::editor::CompilationUnit and should be created from this class.
Subclassed by LIEF::dwarf::editor::ArrayType, LIEF::dwarf::editor::BaseType, LIEF::dwarf::editor::EnumType, LIEF::dwarf::editor::FunctionType, LIEF::dwarf::editor::PointerType, LIEF::dwarf::editor::StructType, LIEF::dwarf::editor::TypeDef
Editor - PointerType¶
Editor - EnumType¶
- class EnumType : public LIEF::dwarf::editor::Type¶
This class represents an editable enum type (
DW_TAG_enumeration_type).Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline EnumType(Args&&... args)¶
- EnumType &set_size(uint64_t size)¶
Define the number of bytes required to hold an instance of the enumeration (
DW_AT_byte_size).
- EnumType &set_underlying_type(const Type &type)¶
Set the underlying type that is used to encode this enum.
- std::unique_ptr<Value> add_value(const std::string &name, int64_t value)¶
Add an enum value by specifying its name and its integer value.
- ~EnumType() override = default¶
- class Value¶
This class represents an enum value.
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
Editor - BaseType¶
Editor - ArrayType¶
Editor - FunctionType¶
- class FunctionType : public LIEF::dwarf::editor::Type¶
This class represents a function type (
DW_TAG_subroutine_type).Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline FunctionType(Args&&... args)¶
- FunctionType &set_return_type(const Type &type)¶
Set the return type of this function.
- ~FunctionType() override = default¶
- class Parameter¶
This class represents a function’s parameter.
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
Editor - TypeDef¶
Editor - StructType¶
- class StructType : public LIEF::dwarf::editor::Type¶
This class represents a struct-like type which can be:
DW_TAG_class_typeDW_TAG_structure_typeDW_TAG_union_type
Public Types
Public Functions
- template<typename ...Args, typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
inline StructType(Args&&... args)¶
- StructType &set_size(uint64_t size)¶
Define the overall size which is equivalent to the
sizeofof the current type.This function defines the
DW_AT_byte_sizeattribute
- std::unique_ptr<Member> add_member(const std::string &name, const Type &type, int64_t offset = -1)¶
Adds a member to the current struct-like.
- std::unique_ptr<Member> add_bitfield(const std::string &name, const Type &type, uint64_t bitsize, int64_t bitoffset = -1)¶
Adds a bitfield member to the current structure.
- ~StructType() override = default¶
- class Member¶
This class represents a member of the struct-like.