Currently addr2line reports inconsistent values for the function name and file+line info for inlined functions. For example, consider: int add2 (int a, int b) { return (a + b); } inline int add3 (int a, int b, int c) { return (a + add2 (b , c)); } main () { printf ("%d\n", add3 (2, 3, 4)); } Run: /usr/bin/gcc -g -O2 -o t t.c /usr/bin/readelf --debug-dump t >t.dwarf /usr/bin/objdump --disassemble t >t.dis Examine the t.dwarf file to ensure that you have a dwarf entry that looks something like: <2><ec>: Abbrev Number: 13 (DW_TAG_inlined_subroutine) DW_AT_abstract_origin: <5f> DW_AT_low_pc : 0x8048398 DW_AT_high_pc : 0x80483a4 The generated code for my test run, with the inlined subroutine marked with '***' is: 0804838c <main>: 804838c: 55 push %ebp 804838d: 89 e5 mov %esp,%ebp 804838f: 83 ec 08 sub $0x8,%esp 8048392: 83 e4 f0 and $0xfffffff0,%esp 8048395: 83 ec 10 sub $0x10,%esp *** 8048398: 6a 04 push $0x4 *** 804839a: 6a 03 push $0x3 *** 804839c: e8 c7 ff ff ff call 8048368 <add2> *** 80483a1: 83 c0 02 add $0x2,%eax 80483a4: 50 push %eax 80483a5: 68 94 84 04 08 push $0x8048494 80483aa: e8 01 ff ff ff call 80482b0 <printf@plt> 80483af: c9 leave 80483b0: c3 ret With an unpatched addr2line you get: $ /usr/bin/addr2line -f -e t 8048398 main /build/sourceware/binutils/i686-pc-linux-gnu/binutils/gcc-3.4.2-6.fc3/t.c:8 I have a patch that fixes this and will try to attach it to the bug report. With this patch I get: $ addr2line -f -e t 8048398 add3 /build/sourceware/binutils/i686-pc-linux-gnu/binutils/gcc-3.4.2-6.fc3/t.c:8
Created attachment 330 [details] Proposed patch to fix the reported problem
Hi Fred, This patch is fine - please apply it and close the PR. In fact if you can think of a way to add this test case to the binutils testsuite that would be even better. Cheers Nick
Patch approved and applied.