This is the mail archive of the
insight@sourceware.org
mailing list for the Insight project.
Re: functions returning double or float inspection
- From: Gene Smith <gds at chartertn dot net>
- To: insight at sources dot redhat dot com
- Date: Mon, 11 May 2009 16:30:01 -0400
- Subject: Re: functions returning double or float inspection
- References: <gua0i4$eol$1@ger.gmane.org>
Gene Smith wrote:
I have been experimenting with function that return doubles in gcc such
as c = pow(x,y). They work OK and I can inspect the float/double c
return value (as a pop-up or as a watch) and it is ok. But if I inspect
pow(x,y) itself (highlighting the function call with the mouse or
evaluating in a watch window or print /f pow(x,y) in the console) I see
usually an integer value with no decimal or an incorrect real value. Is
this a bug or am I doing something wrong when letting insight/gdb
calculate a float/double function value?
-gene
Well, to quickly answer my own question see
http://sourceware.org/gdb/wiki/FAQ .
<quote>
GDB reports a nonsensical return value from an inferior function call.
What's going on?
* GDB doesn't know the return type nor the type of the arguments
for that function call, because there's no debug information available
for it. Either provide debuginfo for the program or library which
contains the function, or cast the function to a function pointer of the
appropriate signature.
For example, to call fabs, which takes a double and returns a
double, use:
(gdb) print ((double (*) (double)) fabs) ( -1.25 )
<end quote>
In my case
print ((double (*) (double,double) pow(x,y)
works for in the console. Pop-up and watch would require the libary
built with debug info to see the correct values I think.