| 11 | namespace LIEF::dwarf::py { |
| 12 | template<> |
| 13 | void create<dw::editor::Function>(nb::module_& m) { |
| 14 | nb::class_<dw::editor::Function> F(m, "Function", |
| 15 | R"doc( |
| 16 | This class represents an **editable** DWARF function (``DW_TAG_subprogram``) |
| 17 | )doc"_doc |
| 18 | ); |
| 19 | |
| 20 | nb::class_<dw::editor::Function::range_t>(F, "range_t") |
| 21 | .def(nb::init<>()) |
| 22 | .def(nb::init<uint64_t, uint64_t>(), "start"_a, "end"_a) |
| 23 | .def_rw("start", &dw::editor::Function::range_t::start) |
| 24 | .def_rw("end", &dw::editor::Function::range_t::end); |
| 25 | |
| 26 | nb::class_<dw::editor::Function::Parameter> FP(F, "Parameter", |
| 27 | R"doc( |
| 28 | This class represents a parameter of the current function (``DW_TAG_formal_parameter``) |
| 29 | )doc"_doc |
| 30 | ); |
| 31 | |
| 32 | nb::class_<dw::editor::Function::LexicalBlock> FLB(F, "LexicalBlock", |
| 33 | "This class mirrors the `DW_TAG_lexical_block` DWARF tag"_doc |
| 34 | ); |
| 35 | |
| 36 | nb::class_<dw::editor::Function::Label> FL(F, "Label", |
| 37 | "This class mirrors the ``DW_TAG_label`` DWARF tag"_doc |
| 38 | ); |
| 39 | |
| 40 | F |
| 41 | .def("set_address", &dw::editor::Function::set_address, |
| 42 | "Set the address of this function by defining ``DW_AT_entry_pc``"_doc, |
| 43 | "addr"_a, nb::rv_policy::reference_internal) |
| 44 | |
| 45 | .def("set_low_high", &dw::editor::Function::set_low_high, |
| 46 | R"doc( |
| 47 | Set the upper and lower bound addresses for this function. This assumes |
| 48 | that the function is contiguous between ``low`` and ``high``. |
| 49 | |
| 50 | Underneath, the function defines ``DW_AT_low_pc`` and ``DW_AT_high_pc`` |
| 51 | )doc"_doc, "low"_a, "high"_a, nb::rv_policy::reference_internal) |
| 52 | |
| 53 | .def("set_ranges", &dw::editor::Function::set_ranges, |
| 54 | R"doc( |
| 55 | Set the ranges of addresses owned by the implementation of this function |
| 56 | by setting the ``DW_AT_ranges`` attribute. |
| 57 | |
| 58 | This setter should be used for non-contiguous function. |
| 59 | )doc"_doc, "ranges"_a, nb::rv_policy::reference_internal) |
| 60 | |
| 61 | .def("set_external", &dw::editor::Function::set_external, |
| 62 | R"doc( |
| 63 | Set the function as external by defining ``DW_AT_external`` to true. |
| 64 | This means that the function is **imported** by the current compilation |
| 65 | unit.)doc"_doc, nb::rv_policy::reference_internal) |
| 66 | |
| 67 | .def("set_return_type", &dw::editor::Function::set_return_type, |
| 68 | "Set the return type of this function"_doc, |
| 69 | "type"_a, nb::rv_policy::reference_internal) |
| 70 |
nothing calls this directly
no outgoing calls
no test coverage detected