public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
From: Gene Smith <gds@chartertn.net>
To: insight@sources.redhat.com
Subject: Re: functions returning double or float inspection
Date: Mon, 11 May 2009 20:30:00 -0000	[thread overview]
Message-ID: <gua1sc$jhb$1@ger.gmane.org> (raw)
In-Reply-To: <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.



      reply	other threads:[~2009-05-11 20:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-11 20:07 Gene Smith
2009-05-11 20:30 ` Gene Smith [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='gua1sc$jhb$1@ger.gmane.org' \
    --to=gds@chartertn.net \
    --cc=insight@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).