From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29507 invoked by alias); 19 Dec 2006 05:55:35 -0000 Received: (qmail 29494 invoked by uid 22791); 19 Dec 2006 05:55:34 -0000 X-Spam-Check-By: sourceware.org Received: from nwk-ea-fw-1.sun.com (HELO nwk-ea-fw-1.sun.com) (192.18.42.249) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 19 Dec 2006 05:55:27 +0000 Received: from d1-sfbay-09.sun.com ([192.18.39.119]) by nwk-ea-fw-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id kBJ5tP1M021431 for ; Mon, 18 Dec 2006 21:55:25 -0800 (PST) Received: from conversion-daemon.d1-sfbay-09.sun.com by d1-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) id <0JAI00101B22DH00@d1-sfbay-09.sun.com> (original mail from Nikolay.Molchanov@Sun.COM) for gdb@sourceware.org; Mon, 18 Dec 2006 21:55:25 -0800 (PST) Received: from [192.168.1.6] ([67.169.108.58]) by d1-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPSA id <0JAI00H8GB4D3N1I@d1-sfbay-09.sun.com> for gdb@sourceware.org; Mon, 18 Dec 2006 21:55:25 -0800 (PST) Date: Tue, 19 Dec 2006 05:55:00 -0000 From: Nikolay Molchanov Subject: Can I use -data-evaluate-expression to evaluate sin(4.1)? To: gdb@sourceware.org Reply-to: Nikolay.Molchanov@Sun.COM Message-id: <45877ECA.9090207@sun.com> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-12/txt/msg00172.txt.bz2 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 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