This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Can I use -data-evaluate-expression to evaluate sin(4.1)?
- From: Nick Roberts <nickrob at snap dot net dot nz>
- To: Nikolay dot Molchanov at Sun dot COM
- Cc: gdb at sourceware dot org
- Date: Tue, 19 Dec 2006 21:23:19 +1300
- Subject: Re: Can I use -data-evaluate-expression to evaluate sin(4.1)?
- References: <45877ECA.9090207@sun.com>
> -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"
--
Nick http://www.inet.net.nz/~nickrob