The following simple test case shows a problem with inlined code in addr2line (running on x86_64/Linux): $ cat foo.cc #include <stdio.h> void __attribute__((always_inline)) bar() { printf ("Hello World\n"); // line 4 } void __attribute__((always_inline)) foo() { bar(); bar(); } int main() { foo(); // line 13 return 0; // line 14 } $ g++ -g -o foo foo.cc $ objdump -d foo ... 00000000004005b2 <main>: 4005b2: 55 push %rbp 4005b3: 48 89 e5 mov %rsp,%rbp 4005b6: bf c8 06 40 00 mov $0x4006c8,%edi 4005bb: e8 d8 fe ff ff callq 400498 <puts@plt> 4005c0: bf c8 06 40 00 mov $0x4006c8,%edi 4005c5: e8 ce fe ff ff callq 400498 <puts@plt> 4005ca: b8 00 00 00 00 mov $0x0,%eax 4005cf: c9 leaveq 4005d0: c3 retq ... $ readelf -wL foo ... CU: foo.cc: File name Line number Starting address foo.cc 3 0x400588 foo.cc 4 0x40058c foo.cc 5 0x400596 foo.cc 7 0x400598 foo.cc 4 0x40059c foo.cc 10 0x4005b0 foo.cc 12 0x4005b2 foo.cc 4 0x4005b6 foo.cc 14 0x4005ca foo.cc 15 0x4005cf ... $ addr2line -e foo 0x4005c5 .../foo.cc:14 The call at 0x4005c5 is inlined from bar (via foo), and should be shown at line 4, but a test for line table rows that span functions in bfd/dwarf2.c is getting in the way and forcing lookup_address_in_line_info_table to return the line number from the next row (line 14 starting at pc 0x4005ca).
Subject: Bug 10654 CVSROOT: /cvs/src Module name: src Changes by: amodra@sourceware.org 2009-09-24 00:11:51 Modified files: bfd : ChangeLog dwarf2.c Log message: PR binutils/10654 * dwarf2.c (lookup_address_in_line_info_table): Remove workaround for invalid location lists generated by gcc-2.95 and Intel 6.0 C++. Remove "function" parm, adjust caller. Patches: http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.4793&r2=1.4794 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/dwarf2.c.diff?cvsroot=src&r1=1.123&r2=1.124
Subject: Bug 10654 CVSROOT: /cvs/src Module name: src Branch: binutils-2_20-branch Changes by: amodra@sourceware.org 2009-09-24 00:16:31 Modified files: bfd : ChangeLog dwarf2.c Log message: PR binutils/10654 * dwarf2.c (lookup_address_in_line_info_table): Remove workaround for invalid location lists generated by gcc-2.95 and Intel 6.0 C++. Remove "function" parm, adjust caller. Patches: http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.4761.2.19&r2=1.4761.2.20 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/dwarf2.c.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.122.4.1&r2=1.122.4.2
Fixed