* functions returning double or float inspection
@ 2009-05-11 20:07 Gene Smith
2009-05-11 20:30 ` Gene Smith
0 siblings, 1 reply; 2+ messages in thread
From: Gene Smith @ 2009-05-11 20:07 UTC (permalink / raw)
To: insight
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: functions returning double or float inspection
2009-05-11 20:07 functions returning double or float inspection Gene Smith
@ 2009-05-11 20:30 ` Gene Smith
0 siblings, 0 replies; 2+ messages in thread
From: Gene Smith @ 2009-05-11 20:30 UTC (permalink / raw)
To: insight
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-11 20:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-11 20:07 functions returning double or float inspection Gene Smith
2009-05-11 20:30 ` Gene Smith
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).