| 10 | namespace LIEF::dwarf::py { |
| 11 | template<> |
| 12 | void create<dw::DebugInfo>(nb::module_& m) { |
| 13 | nb::class_<dw::DebugInfo, LIEF::DebugInfo> dbg_info(m, "DebugInfo", |
| 14 | R"doc( |
| 15 | This class represents a DWARF debug information. It can embed different |
| 16 | compilation units which can be accessed through :attr:`~.compilation_units`. |
| 17 | |
| 18 | This class can be instantiated from :attr:`lief.Binary.debug_info` or |
| 19 | :func:`lief.dwarf.load` |
| 20 | )doc"_doc |
| 21 | ); |
| 22 | |
| 23 | dbg_info |
| 24 | .def("find_function", nb::overload_cast<const std::string&>(&DebugInfo::find_function, nb::const_), |
| 25 | R"doc( |
| 26 | Try to find the function with the given name (mangled or not) |
| 27 | |
| 28 | .. code-block:: python |
| 29 | |
| 30 | info: lief.dwarf.DebugInfo = ... |
| 31 | if func := info.find_function("_ZNSt6localeD1Ev"): |
| 32 | print("Found") |
| 33 | if func := info.find_function("std::locale::~locale()"): |
| 34 | print("Found") |
| 35 | )doc"_doc, "name"_a |
| 36 | ) |
| 37 | |
| 38 | .def("find_function", nb::overload_cast<uint64_t>(&DebugInfo::find_function, nb::const_), |
| 39 | R"doc( |
| 40 | Try to find the function at the given **virtual** address. |
| 41 | )doc"_doc, "addr"_a |
| 42 | ) |
| 43 | |
| 44 | .def("find_variable", nb::overload_cast<uint64_t>(&DebugInfo::find_variable, nb::const_), |
| 45 | R"doc( |
| 46 | Try to find the (static) variable at the given virtual address. |
| 47 | )doc"_doc, "addr"_a |
| 48 | ) |
| 49 | |
| 50 | .def("find_variable", nb::overload_cast<const std::string&>(&DebugInfo::find_variable, nb::const_), |
| 51 | R"doc( |
| 52 | Try to find the variable with the given name. This name can be mangled or not. |
| 53 | )doc"_doc, "name"_a |
| 54 | ) |
| 55 | |
| 56 | .def("find_type", nb::overload_cast<const std::string&>(&DebugInfo::find_type, nb::const_), |
| 57 | R"doc( |
| 58 | Try to find the type with the given name. |
| 59 | )doc"_doc, "name"_a |
| 60 | ) |
| 61 | |
| 62 | .def_prop_ro("compilation_units", |
| 63 | [] (DebugInfo& self) { |
| 64 | auto units = self.compilation_units(); |
| 65 | return nb::make_iterator<nb::rv_policy::reference_internal>( |
| 66 | nb::type<dw::DebugInfo>(), "compilation_units_it", units); |
| 67 | }, nb::keep_alive<0, 1>(), |
| 68 | "Iterator on the CompilationUnit embedded in this dwarf"_doc) |
| 69 | ; |
nothing calls this directly
no test coverage detected