[Bug debug/43828] Emit debug info allowing inlined functions to show in stack traces

scovich at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri May 7 21:20:00 GMT 2010



------- Comment #6 from scovich at gmail dot com  2010-05-07 21:20 -------
Aha! The problem is not that gcc fails to emit the proper debug info, it's that
it doesn't always track well which instructions came from which function. 

For example, if we compile this toy program:

int  volatile global;
int foo(int a) {
    return a + global;
}
int bar(int a) {
    return global + foo(a);
}
int baz(int a) {
    return global + bar(a);
}
int main(int argc, char const* argv[]) {
    return global + baz(argc);
}

Running it in gdb will seem to begin execution at exit from bar:
Dump of assembler code for function main:
   0x000106cc <+0>:     sethi  %hi(0x20800), %g1
   0x000106d0 <+4>:     ld  [ %g1 + 0x124 ], %g4        ! 0x20924 <global>
=> 0x000106d4 <+8>:     ld  [ %g1 + 0x124 ], %g3
   0x000106d8 <+12>:    ld  [ %g1 + 0x124 ], %g2
   0x000106dc <+16>:    ld  [ %g1 + 0x124 ], %g1
   0x000106e0 <+20>:    add  %g4, %g1, %g1
   0x000106e4 <+24>:    add  %g1, %g3, %g1
   0x000106e8 <+28>:    add  %g1, %g2, %g1
   0x000106ec <+32>:    retl
   0x000106f0 <+36>:    add  %g1, %o0, %o0
End of assembler dump.

Apparently someone made the reasonable judgment call that it was better to only
"enter" inlined functions once rather than jumping around, and even then only
if code from later in the containing function hasn't already run. Putting a
printf in foo() gave the expected result. 


-- 

scovich at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WORKSFORME


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43828



More information about the Gcc-bugs mailing list