From 317d85d71f4b156f6d99342700b8a0867058c4a4 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Tue, 7 Aug 2018 09:08:25 +1000 Subject: rtemstoolkit/dwarf: Add types of inline. Report machine code size not span. - Add the types of inlined functions to the interface. - Return the machine code for each function and not the address span. --- rtemstoolkit/rld-dwarf.cpp | 35 ++++++++++++++++++++++++++++++++++- rtemstoolkit/rld-dwarf.h | 16 ++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/rtemstoolkit/rld-dwarf.cpp b/rtemstoolkit/rld-dwarf.cpp index 9cdd84a..e142c43 100644 --- a/rtemstoolkit/rld-dwarf.cpp +++ b/rtemstoolkit/rld-dwarf.cpp @@ -813,6 +813,28 @@ namespace rld return inline_ == DW_INL_inlined || inline_ == DW_INL_declared_inlined; } + function::inlined + function::get_inlined () const + { + inlined i = inl_not_inlined; + switch (inline_) + { + default: + case DW_INL_not_inlined: + break; + case DW_INL_inlined: + i = inl_inline; + break; + case DW_INL_declared_not_inlined: + i = inl_declared_not_inlined; + break; + case DW_INL_declared_inlined: + i = inl_declared_inlined; + break; + } + return i; + } + std::string function::call_file () const { @@ -831,7 +853,18 @@ namespace rld { size_t s = 0; if (!name_.empty () && has_machine_code ()) - s = pc_high () - pc_low (); + { + if (ranges_.empty ()) + s = pc_high () - pc_low (); + else + { + for (auto& r : ranges_.get ()) + { + if (!r.end () && !r.empty ()) + s += r.addr2 () - r.addr1 (); + } + } + } return s; } diff --git a/rtemstoolkit/rld-dwarf.h b/rtemstoolkit/rld-dwarf.h index d4e4c8a..030be3a 100644 --- a/rtemstoolkit/rld-dwarf.h +++ b/rtemstoolkit/rld-dwarf.h @@ -282,6 +282,17 @@ namespace rld class function { public: + + /** + * The various inline states. See Table 3.4 DWARF 5 standard. + */ + enum inlined { + inl_not_inlined = 0, /**< Not declared inline nore inlined. */ + inl_inline = 1, /**< Not declared inline but inlined. */ + inl_declared_not_inlined = 2, /**< Declared inline but not inlined. */ + inl_declared_inlined = 3 /**< Declared inline and inlined */ + }; + function (file& debug, debug_info_entry& die); function (const function& orig); ~function (); @@ -332,6 +343,11 @@ namespace rld */ bool is_inlined () const; + /** + * Get the inlined state. + */ + inlined get_inlined () const; + /** * Get the call file of the inlined function. */ -- cgit v1.2.3