| 15 | namespace LIEF::dwarf::py { |
| 16 | template<> |
| 17 | void create<dw::Function>(nb::module_& m) { |
| 18 | nb::class_<dw::Function> func(m, "Function", |
| 19 | R"doc( |
| 20 | This class represents a DWARF function which can be associated with either: |
| 21 | ``DW_TAG_subprogram`` or ``DW_TAG_inlined_subroutine``. |
| 22 | )doc"_doc |
| 23 | ); |
| 24 | |
| 25 | func |
| 26 | .def_prop_ro("name", &dw::Function::name, |
| 27 | R"doc( |
| 28 | The name of the function (``DW_AT_name``) |
| 29 | )doc"_doc |
| 30 | ) |
| 31 | |
| 32 | .def_prop_ro("linkage_name", &dw::Function::linkage_name, |
| 33 | R"doc( |
| 34 | The name of the function which is used for linking (`DW_AT_linkage_name`). |
| 35 | |
| 36 | This name differs from :attr:`~.name` as it is usually mangled. The function |
| 37 | return an empty string if the linkage name is not available. |
| 38 | )doc"_doc |
| 39 | ) |
| 40 | |
| 41 | .def_prop_ro("address", |
| 42 | [] (const dw::Function& self) { |
| 43 | return LIEF::py::value_or_none(&dw::Function::address, self); |
| 44 | }, |
| 45 | R"doc( |
| 46 | Return the address of the function (``DW_AT_entry_pc`` or ``DW_AT_low_pc``) or |
| 47 | ``None`` if it's not available. |
| 48 | )doc"_doc |
| 49 | ) |
| 50 | |
| 51 | .def_prop_ro("variables", |
| 52 | [] (dw::Function& self) { |
| 53 | auto vars = self.variables(); |
| 54 | return nb::make_iterator<nb::rv_policy::reference_internal>( |
| 55 | nb::type<dw::Function>(), "variables_it", vars); |
| 56 | }, nb::keep_alive<0, 1>(), |
| 57 | R"delim( |
| 58 | Return an iterator over the variables (``DW_TAG_variable``) defined within the |
| 59 | scope of this function. This includes regular stack-based variables as |
| 60 | well as static ones. |
| 61 | )delim"_doc |
| 62 | ) |
| 63 | |
| 64 | .def_prop_ro("is_artificial", &dw::Function::is_artificial, |
| 65 | R"doc( |
| 66 | Whether this function is created by the compiler and not |
| 67 | present in the original source code. |
| 68 | )doc"_doc |
| 69 | ) |
| 70 | |
| 71 | .def_prop_ro("is_external", &dw::Function::is_external, |
| 72 | R"doc( |
| 73 | Whether the function is defined **outside** the current compilation unit |
| 74 | (``DW_AT_external``). |
nothing calls this directly
no test coverage detected