Bug 39814 - GCC does not emit debug info for a called function
Summary: GCC does not emit debug info for a called function
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.3.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
Depends on:
Blocks:
 
Reported: 2009-04-19 11:39 UTC by Arthur Loiret
Modified: 2021-09-09 09:28 UTC (History)
1 user (show)

See Also:
Host: i486-linux-gnu
Target: i486-linux-gnu
Build: i486-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2009-04-21 18:07:01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur Loiret 2009-04-19 11:39:30 UTC
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.
Comment 1 Andrew Pinski 2009-04-19 16:04:59 UTC
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.
Comment 2 Andrew Pinski 2009-04-21 18:07:01 UTC
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.
Comment 3 Daniel Jacobowitz 2009-04-23 16:07:13 UTC
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.