This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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] addr2line -i function nesting problem


The new addr2line -i option is getting confused about function nesting
when given a complex example.  The case where it fails looks something
like this.
1: function foo
2: lexical block
3: inline function bar
2: lexical block
3: lexical block
4: inline function baz

We construct the function table in scan_unit_for_symbols.  We end up
with a table like this
1: function foo
3: inline function bar
4: inline function baz

Then in the function lookup_symbol_in_function_table, we set the
caller_func field which determines function nesting.  Since bar has a
nesting level less than baz, the code assumes that bar must have called
baz.  However, from the full nesting tree above, we can see that this is
not the case.  This results in incorrect addr2line -i output.

I see two possible solutions for this problem.
1) We can add lexical blocks to the function table to maintain the
   proper nesting tree.
2) We can keep a stack of in scope function while reading the dwarf
   debug info, and use that to set the caller_func field.
Option 2 seemed like the better option to me, so I wrote a patch to do
that.  This avoids cluttering the function table with entries that
aren't functions.

This patch works correctly for my testcase.  Unfortunately, this is a
74MB compressed tar file, and I also don't know if I can publicly
redistribute it.  I don't have any convenient small testcase.

I've tested this with a ia64-linux make check.  There were no
regressions.

Since this is a non-trivial patch, I'll wait in case someone wants to
comment.
-- 
Jim Wilson, GNU Tools Support, http://www.specifix.com

Attachment: patch.function.nesting
Description: Text document


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