Consider the following test case: #include <vector>
using namespace std; int main () { vector<int> V(10); V[10] = 1; } Compile it like: g++ -O2 -ggdb -o t t.cc Run gdb and examine the first few instructions in main: (gdb) x/10i main 0x8048880 <main>: push %ebp 0x8048881 <main+1>: mov %esp,%ebp 0x8048883 <main+3>: push %ebx 0x8048884 <main+4>: sub $0x34,%esp 0x8048887 <main+7>: and $0xfffffff0,%esp 0x804888a <main+10>: sub $0x10,%esp 0x804888d <main+13>: cmpb $0x0,0x804a7c0 0x8048894 <main+20>: je 0x8048964 <main+228> 0x804889a <main+26>: xor %eax,%eax 0x804889c <main+28>: lea 0xffffffe8(%ebp),%ebx Run addr2line on the address where the cmpb instruction is and you get (if you use the latest versions of gcc and binutils): $ addr2line -s -f -e t 0804888d _S_get_pool mt_allocator.h:450 The patch (which I'll attach separately) allows addr2line to print additional information about how we arrived at that address via several levels of inlining: $ addr2line -i -s -f -e t 0804888d _S_get_pool mt_allocator.h:450 __mt_alloc mt_allocator.h:656 allocator allocator.h:97 vector stl_vector.h:217 main t.cc:7 One possible use of this is in environments which trap various exceptions and want to print a traceback for the user, by calling addr2line on the current PC and each saved PC in the stack. In the case of functions that inline other functions, that traceback is incomplete because it misses all the inlined functions and the caller of inlined functions. I.E. for the current example, where the caller of main is probably _start(), it would appear that the current function (_S_get_pool) was called directly by _start, skipping main and all the other intermediate inlined functions. The patch is somewhat large because it adds another function to the BFD target structure, which currently returns FALSE for all non-DWARF2 environments. The meat of the changes is actually in bfd/dwarf2.c and binutils/addr2line.c. -- Summary: Extension to BFD and addr2line to print inlining chain Product: binutils Version: 2.17 (HEAD) Status: NEW Severity: normal Priority: P2 Component: binutils AssignedTo: unassigned at sources dot redhat dot com ReportedBy: fnf at specifixinc dot com CC: bug-binutils at gnu dot org,fnf at specifixinc dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://sources.redhat.com/bugzilla/show_bug.cgi?id=947 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils