From: Nikolay Molchanov <Nikolay.Molchanov@Sun.COM>
To: gdb@sourceware.org
Subject: Can I use -data-evaluate-expression to evaluate sin(4.1)?
Date: Tue, 19 Dec 2006 05:55:00 -0000 [thread overview]
Message-ID: <45877ECA.9090207@sun.com> (raw)
Debugger "gdb" is used in NetBeans 5.5 C/C++ Development Pack,
and it works just great, but there are several issues that look
like bugs in "gdb". One of them is a "sinus puzzle" - gdb/mi
command "-data-evaluate-expression sin(4.1)" returns a strange
result "3". I use Cygwin on Windows, but the same problem exists
on other systems (Solaris, Linux).
Here is a test program:
$ cat test_1_sin.cc
/* A test program. Uses sin(x) */
#include <math.h>
double x = 3.14;
double m (double z) {
double y1 = sin(z);
double y2 = sin(3.14);
double y3 = sin(4.1);
double y4 = sin(5.1);
double y = y1 * y2 * y3 * y4;
return y;
}
int main(int argc, char**argv) {
x = m(x);
return 0;
}
If I compile it with "-g" option and run under "gdb",
it runs just fine and all calculations are correct.
But if I ask "gdb" to evaluate sin(3.14) I get "1"
(which is not correct), and if I ask to evaluate
sin(4.1) or sin(5.1) I get "3" (?!).
Here is a log file that shows the problem:
Dev@2006nov24 /cygdrive/c/tmp/Dev/Projects/Math_1_sin
$ g++ -g -o test_1_sin test_1_sin.cc
Dev@2006nov24 /cygdrive/c/tmp/Dev/Projects/Math_1_sin
$ gdb --i mi test_1_sin
~"GNU gdb 6.5.50.20060706-cvs (cygwin-special)\n"
~"Copyright (C) 2006 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and
you are\n"
~"welcome to change it and/or distribute copies of it under certain
conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB. Type \"show warranty\" for
details.\n"
~"This GDB was configured as \"i686-pc-cygwin\"..."
~"\n"
(gdb)
-break-insert 8
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
addr="0x00401064",func="m(double)",file="test_1_sin.cc",
fullname="/cygdrive/c/tmp/Dev/Projects/Math_1_sin/test_1_sin.cc",
line="8",times="0"}
(gdb)
-exec-run
^running
(gdb)
*stopped,reason="breakpoint-hit",bkptno="1",thread-id="1",
frame={addr="0x00401064",func="m",args=[{name="z",
value="3.1400000000000001"}],file="test_1_sin.cc",
fullname="/cygdrive/c/tmp/Dev/Projects/Math_1_sin/test_1_sin.cc",
line="8"}
(gdb)
-data-evaluate-expression sin(4.1)
^done,value="3"
(gdb)
-exec-next
^running
(gdb)
*stopped,reason="end-stepping-range",thread-id="1",
frame={addr="0x00401075",func="m",args=[{name="z",
value="3.1400000000000001"}],file="test_1_sin.cc",
ullname="/cygdrive/c/tmp/Dev/Projects/Math_1_sin/test_1_sin.cc",
line="9"}
(gdb)
-exec-next
^running
(gdb)
*stopped,reason="end-stepping-range",thread-id="1",
frame={addr="0x00401086",func="m",args=[{name="z",
value="3.1400000000000001"}],file="test_1_sin.cc",
fullname="/cygdrive/c/tmp/Dev/Projects/Math_1_sin/test_1_sin.cc",
line="10"}
(gdb)
-data-evaluate-expression y3
^done,value="-0.81827711106441026"
(gdb)
-data-evaluate-expression sin(3.14)
^done,value="1"
(gdb)
-data-evaluate-expression y2
^done,value="0.0015926529164868282"
(gdb)
-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?
Thanks in advance,
Nikolay Molchanov
next reply other threads:[~2006-12-19 5:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-19 5:55 Nikolay Molchanov [this message]
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
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=45877ECA.9090207@sun.com \
--to=nikolay.molchanov@sun.com \
--cc=gdb@sourceware.org \
/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