From aecdf2670c027adde8ff800397a48b1b2403dd89 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 10 Dec 2014 11:06:52 -0800 Subject: [PATCH] addr2line: Iterate scopes for inline's parent function The function which contains an inline might not be the immediate next die scope. For instance, there may be a lexical scope in between. Instead, iterate the remaining scopes until an appropriate tag is found. Signed-off-by: Josh Stone --- src/ChangeLog | 4 ++++ src/addr2line.c | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 1c3cf2fc6..413a6bf6c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2014-12-10 Josh Stone + + * addr2line.c (handle_address): Find the proper inline parents. + 2014-12-07 Mark Wielaard * readelf.c (print_debug_line_section): max_ops_per_instr cannot diff --git a/src/addr2line.c b/src/addr2line.c index 50fc2b38c..e8ffbc687 100644 --- a/src/addr2line.c +++ b/src/addr2line.c @@ -672,7 +672,23 @@ handle_address (const char *string, Dwfl *dwfl) continue; if (show_functions) - print_diesym (&scopes[i + 1]); + { + /* Search for the parent inline or function. It + might not be directly above this inline -- e.g. + there could be a lexical_block in between. */ + for (int j = i + 1; j < nscopes; j++) + { + Dwarf_Die *parent = &scopes[j]; + int tag = dwarf_tag (parent); + if (tag == DW_TAG_inlined_subroutine + || tag == DW_TAG_entry_point + || tag == DW_TAG_subprogram) + { + print_diesym (parent); + break; + } + } + } src = NULL; lineno = 0; -- 2.47.3