| 13 | namespace LIEF::dwarf::py { |
| 14 | template<> |
| 15 | void create<dw::Variable>(nb::module_& m) { |
| 16 | nb::class_<dw::Variable> var(m, "Variable", |
| 17 | R"doc( |
| 18 | This class represents a DWARF variable which can be owned by a |
| 19 | :class:`~.Function` or a :class:`~.CompilationUnit`. |
| 20 | )doc"_doc |
| 21 | ); |
| 22 | |
| 23 | var |
| 24 | .def_prop_ro("name", &dw::Variable::name, |
| 25 | R"doc( |
| 26 | Name of the variable (usually demangled) |
| 27 | )doc"_doc |
| 28 | ) |
| 29 | .def_prop_ro("linkage_name", &dw::Variable::linkage_name, |
| 30 | R"doc( |
| 31 | The name of the variable which is used for linking (``DW_AT_linkage_name``). |
| 32 | |
| 33 | This name differs from :attr:`~.name` as it is usually mangled. The function |
| 34 | return an empty string if the linkage name is not available. |
| 35 | )doc"_doc |
| 36 | ) |
| 37 | .def_prop_ro("address", |
| 38 | [] (const dw::Variable& self) { |
| 39 | return LIEF::py::value_or_none(&dw::Variable::address, self); |
| 40 | }, |
| 41 | R"doc( |
| 42 | Address of the variable. |
| 43 | |
| 44 | If the variable is **static**, it returns the **virtual address** |
| 45 | where it is defined. |
| 46 | If the variable is stack-based, it returns the **relative offset** from |
| 47 | the frame-base register. |
| 48 | |
| 49 | If the address can't be resolved, it returns ``None``. |
| 50 | )doc"_doc |
| 51 | ) |
| 52 | .def_prop_ro("size", |
| 53 | [] (const dw::Variable& self) { |
| 54 | return LIEF::py::value_or_none(&dw::Variable::size, self); |
| 55 | }, |
| 56 | R"doc( |
| 57 | Return the size of the variable (or a lief_errors if it can't be |
| 58 | resolved). |
| 59 | |
| 60 | This size is defined by the type of the variable. |
| 61 | )doc"_doc |
| 62 | ) |
| 63 | .def_prop_ro("is_constexpr", |
| 64 | &dw::Variable::is_constexpr, |
| 65 | R"doc( |
| 66 | Whether it's a ``constexpr`` variable. |
| 67 | )doc"_doc |
| 68 | ) |
| 69 | .def_prop_ro("debug_location", |
| 70 | &dw::Variable::debug_location, |
| 71 | R"doc( |
| 72 | The original source location where the variable is defined. |
nothing calls this directly
no test coverage detected