This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/2] 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 <jistone@redhat.com>
---
 src/ChangeLog   |  4 ++++
 src/addr2line.c | 17 ++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index c149a9c67bf3..484cb53d892f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2014-12-10  Josh Stone  <jistone@redhat.com>
+
+	* addr2line.c (handle_address): Find the proper inline parents.
+
 2014-12-04  Mark Wielaard  <mjw@redhat.com>
 
 	* objdump.c (show_relocs_x): Make sure destshdr exists.
diff --git a/src/addr2line.c b/src/addr2line.c
index 50fc2b38c367..eea39da97e2c 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -672,7 +672,22 @@ 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_subprogram)
+				{
+				  print_diesym (parent);
+				  break;
+				}
+			    }
+			}
 
 		      src = NULL;
 		      lineno = 0;
-- 
2.1.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]