From: Nikolay Molchanov <Nikolay.Molchanov@Sun.COM>
To: gdb@sourceware.org
Cc: Nick Roberts <nickrob@snap.net.nz>
Subject: Re: Can I use -data-evaluate-expression to evaluate sin(4.1)?
Date: Tue, 19 Dec 2006 17:02:00 -0000 [thread overview]
Message-ID: <45881B0B.3090106@sun.com> (raw)
In-Reply-To: <17799.41335.712243.659292@kahikatea.snap.net.nz>
Nick Roberts wrote:
> > -data-evaluate-expression sin(5.1)
> > ^done,value="3"
> > (gdb)
> >
> >
> > Can I use "-data-evaluate-expression" to evaluate
> > sin(x) function? If yes, why it returns a wrong
> > "int" value?
>
> By default (without debuginfo as Frederic says) it assumes sin takes an
> integer argument and returns an value (I think).
>
> You need to cast sin explicitly:
>
> (gdb)
> -data-evaluate-expression "((double ((*) (double))) sin) (5.1)"
> ^done,value="-0.92581468232773245"
> (gdb)
> -data-evaluate-expression "((double ((*) (double))) sin) (4.1)"
> ^done,value="-0.81827711106441026"
>
>
>
Thank you very much for the explanation!
I verified that "ptype sin" gets wrong type ("int"):
ptype sin
&"ptype sin\n"
~"type = \n"
~" int (void)\n"
^done
And thank you for the workaround, probably we can use it for
known functions (sin, cos, ...).
prev parent reply other threads:[~2006-12-19 17:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-19 5:55 Nikolay Molchanov
2006-12-19 7:44 ` Frederic RISS
2006-12-19 8:28 ` Nick Roberts
2006-12-19 16:32 ` Daniel Jacobowitz
2006-12-19 20:14 ` Nick Roberts
2006-12-20 2:42 ` Daniel Jacobowitz
2006-12-19 17:02 ` Nikolay Molchanov [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=45881B0B.3090106@sun.com \
--to=nikolay.molchanov@sun.com \
--cc=gdb@sourceware.org \
--cc=nickrob@snap.net.nz \
/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