The following program: #include <stdio.h> #include <math.h> int main() { printf("asin(1.0) = %f\n", asin(1.0)); return 0; } prints correctly 1.570796, but "p asin(1.0)" from within gdb prints 0. However, this work fine: (gdb) p ((double (*)(double))asin) (1.0) $4 = 1.5707963267948966 Or, with libc debug symbols installed: (gdb) p __asin (1.0) $5 = 1.5707963267948966 The explanation from Daniel Jacobowitz is: The C library does not contain debug info for a function named 'asin', because the implementation is __asin, so GDB does not know it returns a double. Also, GCC does not emit debug info for the called function - I don't know why it doesn't, but probably to save space.
Can you attach the preprocessed source? And what options are you using to compile the program? It might be the case that asin is defined in the glibc's header as a macro which causes no debug information to be emitted for asin as asin is not really used.
Oh because constant folding of asin, we remove the reference to asin so no debugging info for asin is going to be emitted because there is no call left for asin. Maybe -fbuiltins should not be enabled at -O0.
Subject: Re: GCC does not emit debug info for a called function On Tue, Apr 21, 2009 at 06:07:01PM -0000, pinskia at gcc dot gnu dot org wrote: > Oh because constant folding of asin, we remove the reference to asin so no > debugging info for asin is going to be emitted because there is no call left > for asin. Maybe -fbuiltins should not be enabled at -O0. In addition to that, there's still no debug info for it with -fno-builtin.