|
LIEF: Library to Instrument Executable Formats Version 2.0.0
|
This class represents a DWARF compilation unit. More...
#include <CompilationUnit.hpp>
Classes | |
| class | Iterator |
| class | Language |
| Languages supported by the DWARF (v5) format. See: https://dwarfstd.org/languages.html. More... | |
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 Member Functions | |
| CompilationUnit (std::unique_ptr< details::CompilationUnit > impl) | |
| ~CompilationUnit () | |
| std::string_view | 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. | |
| std::string_view | producer () const |
| Information about the program (or library) that generated this compilation unit. For instance, it can output: Debian clang version 17.0.6. | |
| std::string_view | compilation_dir () const |
| Return the path to the directory in which the compilation took place for compiling this compilation unit (e.g. /workdir/build). | |
| Language | language () const |
| Original language of this compilation unit. | |
| 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. | |
| std::vector< range_t > | ranges () const |
| Return a list of address ranges owned by this compilation unit. | |
| std::unique_ptr< Function > | find_function (std::string_view name) const |
| Try to find the function whose name is given in parameter. | |
| 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 (std::string_view 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. | |
| functions_it | imported_functions () const |
| Return an iterator over the functions imported in this compilation unit but not implemented. | |
| types_it | types () const |
| Return an iterator over the different types defined in this compilation unit. | |
| vars_it | variables () const |
| Return an iterator over all the variables defined in this compilation unit: | |
| std::string | to_decl (const DeclOpt &opt=DeclOpt()) const |
| Generate a C/C++ definition for the functions defined in this compilation unit. | |
This class represents a DWARF compilation unit.
Iterator over the dwarf::Function.
Iterator over the dwarf::Type.
Iterator over the CompilationUnit's variables.
| LIEF::dwarf::CompilationUnit::CompilationUnit | ( | std::unique_ptr< details::CompilationUnit > | impl | ) |
| LIEF::dwarf::CompilationUnit::~CompilationUnit | ( | ) |
| std::string_view LIEF::dwarf::CompilationUnit::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_dir attribute
References compilation_dir(), and LIEF_LIFETIMEBOUND.
Referenced by compilation_dir().
| std::unique_ptr< Function > LIEF::dwarf::CompilationUnit::find_function | ( | std::string_view | name | ) | const |
Try to find the function whose name is given in parameter.
The provided name can be demangled
References find_function(), LIEF_LIFETIMEBOUND, and name().
Referenced by find_function(), and find_function().
| std::unique_ptr< Function > LIEF::dwarf::CompilationUnit::find_function | ( | uint64_t | addr | ) | const |
Try to find the function at the given address.
References find_function(), and LIEF_LIFETIMEBOUND.
| std::unique_ptr< Variable > LIEF::dwarf::CompilationUnit::find_variable | ( | std::string_view | name | ) | const |
Try to find the Variable with the given name.
References find_variable(), LIEF_LIFETIMEBOUND, and name().
| std::unique_ptr< Variable > LIEF::dwarf::CompilationUnit::find_variable | ( | uint64_t | addr | ) | const |
Try to find the Variable at the given address.
References find_variable(), and LIEF_LIFETIMEBOUND.
Referenced by find_variable(), and find_variable().
| functions_it LIEF::dwarf::CompilationUnit::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:
The iterator will only return one function for main since get_secret_env is inlined and thus, its implementation is located in main.
References functions(), and LIEF_LIFETIMEBOUND.
Referenced by functions().
| uint64_t LIEF::dwarf::CompilationUnit::high_address | ( | ) | const |
Return the highest virtual address owned by this compilation unit.
References high_address().
Referenced by high_address().
| functions_it LIEF::dwarf::CompilationUnit::imported_functions | ( | ) | const |
Return an iterator over the functions imported in this compilation unit but not implemented.
For instance with this code:
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().
References imported_functions(), and LIEF_LIFETIMEBOUND.
Referenced by imported_functions().
| Language LIEF::dwarf::CompilationUnit::language | ( | ) | const |
Original language of this compilation unit.
This value matches the DW_AT_language attribute.
References language().
Referenced by language().
| uint64_t LIEF::dwarf::CompilationUnit::low_address | ( | ) | const |
Return the lowest virtual address owned by this compilation unit.
References low_address().
Referenced by low_address().
| std::string_view LIEF::dwarf::CompilationUnit::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_name attribute
References LIEF_LIFETIMEBOUND.
Referenced by find_function(), and find_variable().
| std::string_view LIEF::dwarf::CompilationUnit::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_producer attribute
References LIEF_LIFETIMEBOUND, and producer().
Referenced by producer().
| std::vector< range_t > LIEF::dwarf::CompilationUnit::ranges | ( | ) | const |
| uint64_t LIEF::dwarf::CompilationUnit::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.
References size().
Referenced by size().
Generate a C/C++ definition for the functions defined in this compilation unit.
References CompilationUnit(), and to_decl().
Referenced by to_decl().
| types_it LIEF::dwarf::CompilationUnit::types | ( | ) | const |
Return an iterator over the different types defined in this compilation unit.
References LIEF_LIFETIMEBOUND, and types().
Referenced by types().
| vars_it LIEF::dwarf::CompilationUnit::variables | ( | ) | const |
Return an iterator over all the variables defined in this compilation unit:
References LIEF_LIFETIMEBOUND, and variables().
Referenced by variables().