Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] Decimal Floating Point support for GDB (Part 2: testcase)
@ 2005-09-28  5:26 Wu Zhou
  2005-10-02 21:05 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Wu Zhou @ 2005-09-28  5:26 UTC (permalink / raw)
  To: gdb-patches

Hello all,

This post is to add testcase for the part 1.  Maybe you can get some 
concrete feeling from this about how dfp is used in gcc and gdb.

In this testcase, there are totally 83 tests.  Most of them are about 
displaying and setting of dfp types, which are partitioned into 
three groups, one for each dfp types (_Decimal32, _Decimal64 and 
_Decimal128).  In each group, we first begin with the printing of 
a normal finite dfp value, then Infinity and NaN. Then we call 
d32_set_tests (d64_set_tests or d128_set_tests) to test that GDB 
could handle the setting different values of variable d32 (d64 or 
d128).

At the end of the testcase, we test that GDB could print out the dfp
values correctly in the function arguments and backtrace.

Here goes the testcase.  I tested it against x86 with a "-msse" option.
The gcc used is from the dfp-branch. All the 83 testcases passed.  The 
command line used is: 
make check RUNTESTFLAGS="CC_FOR_TARGET='gcc -msse' gdb.base/dfp-test.exp"

Index: gdb.base/dfp-test.c
===================================================================
RCS file: gdb.base/dfp-test.c
diff -N gdb.base/dfp-test.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gdb.base/dfp-test.c	28 Sep 2005 01:40:37 -0000
***************
*** 0 ****
--- 1,61 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+ volatile _Decimal32 d32;
+ volatile _Decimal64 d64;
+ volatile _Decimal128 d128;
+ 
+ static _Decimal32
+ arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
+          _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
+ {
+   return arg0;
+ }
+ 
+ static _Decimal64
+ arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
+          _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
+ {
+   return arg0;
+ }
+ 
+ static _Decimal128
+ arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
+          _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
+ {
+   return arg0;
+ }
+ 
+ int main()
+ {
+   /* An finite 32-bits decimal floating point.  */
+   d32 = 1.2345df;		/* Initialize d32.  */
+ 
+   /* Non-finite 32-bits decimal floating point: infinity and NaN.  */
+   d32 = __builtin_infd32();	/* Positive infd32.  */
+   d32 = -__builtin_infd32();	/* Negative infd32.  */
+   d32 = __builtin_nand32("");
+ 
+   /* An finite 64-bits decimal floating point.  */
+   d64 = 1.2345dd;		/* Initialize d64.  */
+ 
+   /* Non-finite 64-bits decimal floating point: infinity and NaN.  */
+   d64 = __builtin_infd64();	/* Positive infd64.  */
+   d64 = -__builtin_infd64();	/* Negative infd64.  */
+   d64 = __builtin_nand64("");
+ 
+   /* An finite 128-bits decimal floating point.  */
+   d128 = 1.2345dl;		/* Initialize d128.  */
+ 
+   /* Non-finite 128-bits decimal floating point: infinity and NaN.  */
+   d128 = __builtin_infd128();	/* Positive infd128.  */
+   d128 = -__builtin_infd128();	/* Negative infd128.  */
+   d128 = __builtin_nand128("");
+ 
+   /* Functions with decimal floating point as parameter and return value.  */
+   d32 = arg0_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df);
+   d64 = arg0_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd);
+   d128 = arg0_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl);
+ 
+   return 0;
+ }
Index: gdb.base/dfp-test.exp
===================================================================
RCS file: gdb.base/dfp-test.exp
diff -N gdb.base/dfp-test.exp
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gdb.base/dfp-test.exp	28 Sep 2005 01:40:37 -0000
***************
*** 0 ****
--- 1,219 ----
+ # Copyright 2005 Free Software Foundation, Inc.
+ 
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+ 
+ # This file is part of the gdb testsuite.  It is intended to test that
+ # gdb could correctly handle decimal floating point introduced in IEEE 754R.
+ 
+ proc d32_set_tests {} {
+ 
+     gdb_test "p d32=123.45df" "123.45df" "p d32=123.45df"
+     gdb_test "p d32=12345.df" "12345.df" "p d32=12345.df"
+     gdb_test "p d32=12345.67df" "12345.67df" "p d32=12345.67df"
+     gdb_test "p d32=1234567.df" "1234567.df" "p d32=1234567.df"
+ 
+     gdb_test "p d32=1.234567E0df" "1.234567df" "p d32=1.234567E0df"
+     gdb_test "p d32=1.234567E10df" "1.234567E\\+10df" "p d32=1.234567E10df"
+     gdb_test "p d32=1.234567E+96df" "1.234567E\\+96df" "p d32=1.234567E+96df"
+ 
+     # Test that gdb could handle the max, normalized min and subnormalized min.
+     gdb_test "p d32=9.999999E+96df" "9.999999E\\+96df" "p d32=9.999999E+96df"
+     gdb_test "p d32=1.0E-95df" "1.E\\-95df" "p d32=1.0E-95df"
+     gdb_test "p d32=1.E-101df" "1.E\\-101df" "p d32=1.E-101df"
+     gdb_test "p d32=0.000001E-95df" "1.E\\-101df" "p d32=0.000001E-95df"
+ 
+     # Test that gdb could detect coefficient/exponent out of range.
+     gdb_test "p d32=1.2345678df" ".*coefficient is out of range.*" "1.2345678df is out of range (coefficient)"
+     gdb_test "p d32=1.0E-101df" ".*exponent is out of range.*" "1.0E-101df is out of range (exponent)"
+     gdb_test "p d32=1.234567E+97df" ".*exponent is out of range.*" "1.234567E+97df is out of range (exponent)"
+ 
+     # Test that gdb could detect the errors in the string representation of _Decimal32
+     gdb_test "p d32=12345df" ".*Invalid number.*" "12345df is an invalid number"
+     gdb_test "p d32=1.23Edf" ".*Digit expected.*" "p d32=1.23Edf"
+     gdb_test "p d32=1.23E45Adf" ".*Invalid char found.*" "p d32=1.23E45Adf"
+ }
+ 
+ proc d64_set_tests {} {
+ 
+     gdb_test "p d64=123.45dd" "123.45dd" "p d64=123.45dd"
+     gdb_test "p d64=12345.dd" "12345.dd" "p d64=12345.dd"
+     gdb_test "p d64=12345.67dd" "12345.67dd" "p d64=12345.67dd"
+     gdb_test "p d64=1.234567890123456dd" "1.234567890123456dd" "p d64=1.234567890123456dd"
+ 
+     gdb_test "p d64=1.234567890123456E10dd" "12345678901.23456dd" "p d64=1.234567890123456E10dd"
+     gdb_test "p d64=1.234567890123456E100dd" "1.234567890123456E\\+100dd" "p d64=1.234567890123456E100dd"
+     gdb_test "p d64=1.234567890123456E384dd" "1.234567890123456E\\+384dd" "p d64=1.234567890123456E384dd"
+ 
+     # Test that gdb could handle the max, normalized min and subnormalized min.
+     gdb_test "p d64=9.999999999999999E384dd" "9.999999999999999E\\+384dd" "p d64=9.999999999999999E384dd"
+     gdb_test "p d64=1.E-383dd" "1.E\\-383dd" "p d64=1.E-383dd"
+     gdb_test "p d64=1.E-398dd" "1.E\\-398dd" "p d64=1.E-398dd"
+     gdb_test "p d64=0.000000000000001E-383dd" "1.E\\-398dd" "p d64=0.000000000000001E-383dd"
+ 
+     # Test that gdb could detect coefficient/exponent out of range.
+     gdb_test "p d64=1.2345678901234567dd" ".*coefficient is out of range.*" "1.2345678901234567dd is out of range (coefficient)"
+     gdb_test "p d64=9.9999999999999999E384dd" ".*coefficient is out of range.*" "d64=9.9999999999999999E384dd is out of range (coefficient)"
+     gdb_test "p d64=1.234567890123456E385dd" ".*exponent is out of range.*" "d64=1.234567890123456E385dd is out of range (exponent)"
+     gdb_test "p d64=1.E-399dd" ".*exponent is out of range.*" "d64=1.E-399dd is out of range (exponent)"
+ 
+     # Test that gdb could detect the errors in the string representation of _Decimal32
+     gdb_test "p d64=12345dd" ".*Invalid number.*" "12345dd is an invalid number"
+     gdb_test "p d64=1.23Edd" ".*Digit expected.*" "p d64=1.23Edd"
+     gdb_test "p d64=1.23E45Add" ".*Invalid char found.*" "p d64=1.23E45Add"
+ }
+ 
+ proc d128_set_tests {} {
+ 
+     gdb_test "p d128=123.45dl" "123.45dl" "p d128=123.45dl"
+     gdb_test "p d128=12345.dl" "12345.dl" "p d128=12345.dl"
+     gdb_test "p d128=12345.67dl" "12345.67dl" "p d128=12345.67dl"
+     gdb_test "p d128=1.234567890123456789012345678901234dl" "1.234567890123456789012345678901234dl" "p d128=1.234567890123456789012345678901234dl"
+ 
+     gdb_test "p d128=1.234567890123456E10dl" "12345678901.23456dl" "p d128=1.234567890123456E10dl"
+     gdb_test "p d128=1.234567890123456E100dl" "1.234567890123456E\\+100dl" "p d128=1.234567890123456E100dl"
+     gdb_test "p d128=1.234567890123456E1000dl" "1.234567890123456E\\+1000dl" "p d128=1.234567890123456E1000dl"
+ 
+     # Test that gdb could handle the max, normalized min and subnormalized min.
+     gdb_test "p d128=9.99999999999999999999999999999999E6144dl" "9.99999999999999999999999999999999E\\+6144dl" "p d128=9.99999999999999999999999999999999E6144dl"
+     gdb_test "p d128=1.E-6143dl" "1.E\\-6143dl" "p d128=1.E-6143dl"
+     gdb_test "p d128=1.E-6176dl" "1.E\\-6176dl" "p d128=1.E-6176dl"
+     gdb_test "p d128=0.000000000000000000000000000000001E-6143dl" "1.E\\-6176dl" "p d128=0.000000000000000000000000000000001E-6143dl"
+ 
+     # Test that gdb could detect coefficient/exponent out of range.
+     gdb_test "p d128=1.2345678901234567890123456789012345dl" ".*coefficient is out of range.*" "1.2345678901234567890123456789012345dl is out of range (coefficient)"
+     gdb_test "p d128=9.9999999999999999999999999999999999dl" ".*coefficient is out of range.*" "d128=9.9999999999999999999999999999999999 is out of range (coefficient)"
+     gdb_test "p d128=1.234567890123456E6145dl" ".*exponent is out of range.*" "d128=1.234567890123456E6145dl is out of range (exponent)"
+     gdb_test "p d128=1.E-6177dl" ".*exponent is out of range.*" "d128=1.E-6177dl is out of range (exponent)"
+ 
+     # Test that gdb could detect the errors in the string representation of _Decimal32
+     gdb_test "p d128=12345dl" ".*Invalid number.*" "12345dl is an invalid number"
+     gdb_test "p d128=1.23Edl" ".*Digit expected.*" "p d128=1.23Edl"
+     gdb_test "p d128=1.23E45Adl" ".*Invalid char found.*" "p d128=1.23E45Adl"
+ }
+ 
+ 
+ if $tracelevel {
+     strace $tracelevel
+ }
+ 
+ set testfile "dfp-test"
+ set srcfile ${testfile}.c
+ set binfile ${objdir}/${subdir}/${testfile}
+ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+     untested "Couldn't compile ${srcfile}"
+     return -1
+ }
+ 
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load ${binfile}
+ 
+ if ![runto_main] then {
+     perror "couldn't run to breakpoint"
+     continue
+ }
+ 
+ # Different tests on 32-bits decimal floating point, including the printing 
+ # of finite numbers, infinite and NaN, and also the setting of different
+ # decimal value.
+ 
+ if [gdb_test "next" \
+     ".*Positive infd32.*" \
+     "next after initializing d32"] then { gdb_suppress_tests }
+ gdb_test "print d32" "1.2345df" "d32 is initialized to 1.2345df"
+ 
+ if [gdb_test "next" \
+     ".*Negative infd32.*" \
+     "next after assigning builtin infinity to d32"] then { gdb_suppress_tests }
+ gdb_test "print d32" "Infinity" "d32 is positive Infinity"
+ 
+ if [gdb_test "next" \
+     ".*__builtin_nand32.*" \
+     "next after assigning negative builtin infinity to d32"] then { gdb_suppress_tests }
+ gdb_test "print d32" "-Infinity" "d32 is negative Infinity"
+ 
+ if [gdb_test "next" \
+     ".*d64 = 1.2345dd.*" \
+     "next after assigning builtin NaN to d32"] then { gdb_suppress_tests }
+ gdb_test "print d32" "NaN" "d32 is NaN"
+ 
+ d32_set_tests 
+ 
+ 
+ # Different tests on 64-bits decimal floating point, including the display
+ # of finite number, infinite and NaN, and also the setting of different
+ # decimal value.
+ 
+ if [gdb_test "next" \
+     ".*Positive infd64.*" \
+     "next after initializing d64"] then { gdb_suppress_tests }
+ gdb_test "print d64" "1.2345dd" "d64 is initialized to 1.2345dd"
+ 
+ if [gdb_test "next" \
+     ".*Negative infd64.*" \
+     "next after assigning builtin infinity to d64"] then { gdb_suppress_tests }
+ gdb_test "print d64" "Infinity" "d64 is positive Infinity"
+ 
+ if [gdb_test "next" \
+     ".*__builtin_nand64.*" \
+     "next after assigning negative builtin infinity to d64"] then { gdb_suppress_tests }
+ gdb_test "print d64" "-Infinity" "d64 is negative Infinity"
+ 
+ if [gdb_test "next" \
+     ".*d128 = 1.2345dl.*" \
+     "next after assigning builtin NaN to d64"] then { gdb_suppress_tests }
+ gdb_test "print d64" "NaN" "d64 is NaN"
+ 
+ d64_set_tests 
+ 
+ 
+ # Different tests on 128-bits decimal floating point, including the display
+ # of finite number, infinite and NaN, and also the setting of different
+ # decimal value.
+ 
+ if [gdb_test "next" \
+     ".*Positive infd128.*" \
+     "next after initializing d128"] then { gdb_suppress_tests }
+ gdb_test "print d128" "1.2345dl" "d128 is initialized to 1.2345dl"
+ 
+ d128_set_tests
+ 
+ if [gdb_test "next" \
+     ".*Negative infd128.*" \
+     "next after assigning builtin infinity to d128"] then { gdb_suppress_tests }
+ gdb_test "print d128" "Infinity" "d128 is positive Infinity"
+ 
+ if [gdb_test "next" \
+     ".*__builtin_nand128.*" \
+     "next after assigning negative builtin infinity to d128"] then { gdb_suppress_tests }
+ gdb_test "print d128" "-Infinity" "d128 is negative Infinity"
+ 
+ if [gdb_test "next" \
+     ".*arg0_32.*" \
+     "next after assigning builtin NaN to d128"] then { gdb_suppress_tests }
+ gdb_test "print d128" "NaN" "d128 is NaN"
+ 
+ gdb_breakpoint arg0_32
+ gdb_continue_to_breakpoint "entry to arg0_32"
+ gdb_test "backtrace" ".*arg0_32 \\(arg0=0.df, arg1=1.df, arg2=2.df, arg3=3.df, arg4=4.df, arg5=5.df\\).*" "backtrace at arg0_32"
+ 
+ gdb_breakpoint arg0_64
+ gdb_continue_to_breakpoint "entry to arg0_64"
+ gdb_test "backtrace" ".*arg0_64 \\(arg0=0.dd, arg1=1.dd, arg2=2.dd, arg3=3.dd, arg4=4.dd, arg5=5.dd\\).*" "backtrace at arg0_64"
+ 
+ gdb_breakpoint arg0_128
+ gdb_continue_to_breakpoint "entry to arg0_128"
+ gdb_test "backtrace" ".*arg0_128 \\(arg0=0.dl, arg1=1.dl, arg2=2.dl, arg3=3.dl, arg4=4.dl, arg5=5.dl\\).*" "backtrace at arg0_128"

Regards
- Wu Zhou


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] Decimal Floating Point support for GDB (Part 2: testcase)
  2005-09-28  5:26 [RFC] Decimal Floating Point support for GDB (Part 2: testcase) Wu Zhou
@ 2005-10-02 21:05 ` Daniel Jacobowitz
  2005-10-18 10:17   ` [RFC] Decimal Floating Point support for GDB (Part 2: testcase - Revised) Wu Zhou
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2005-10-02 21:05 UTC (permalink / raw)
  To: Wu Zhou; +Cc: gdb-patches

On Wed, Sep 28, 2005 at 01:28:07PM +0800, Wu Zhou wrote:
> In this testcase, there are totally 83 tests.  Most of them are about 
> displaying and setting of dfp types, which are partitioned into 
> three groups, one for each dfp types (_Decimal32, _Decimal64 and 
> _Decimal128).  In each group, we first begin with the printing of 
> a normal finite dfp value, then Infinity and NaN. Then we call 
> d32_set_tests (d64_set_tests or d128_set_tests) to test that GDB 
> could handle the setting different values of variable d32 (d64 or 
> d128).
> 
> At the end of the testcase, we test that GDB could print out the dfp
> values correctly in the function arguments and backtrace.

Just a few comments on the tests:

- This should be at least two separate tests, since the "p 1.5df" tests
can be run without a GCC which supports DFP, even though dfp-test.c
can't be compiled.

- C files need to have copyright headers.

In this:

> +     gdb_test "p d32=123.45df" "123.45df" "p d32=123.45df"

- The third argument to gdb_test defaults to the first argument, so you
don't need it.

- The second argument should be more specific.  Something like
"\$${decimal} = 123.45df".  I went to look at this test to see if my
understanding of the use of string types was right, and the matching
patterns were so loose I couldn't tell.

Otherwise I'll wait to look at this further until we're agreed on the
GDB support.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RFC] Decimal Floating Point support for GDB (Part 2: testcase - Revised)
  2005-10-02 21:05 ` Daniel Jacobowitz
@ 2005-10-18 10:17   ` Wu Zhou
  0 siblings, 0 replies; 3+ messages in thread
From: Wu Zhou @ 2005-10-18 10:17 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: bje, gdb-patches

Hi Daniel,

Appended is the testcase for newly rewrited DFP patch.  I had seperated 
the testcases into two parts: dfp-exprs.exp which don't need any DFP code 
to be run, dfp-test.exp which need to compile a source file dfp-test.c. 
In dfp-test.exp, I added a few tests to verify that GDB could correctly 
handle the DFP members in C struct and also some tests to handle dfp value 
setting by "dfp1=dfp2".  I had tested it on x86 using dfp-branch gcc.  All 
passed.  And no regression was found with any other testcases too.  

Please review and comment.  Thanks a lot!

2005-10-18  Wu Zhou  <woodzltc@cn.ibm.com>

	* dfp-exprs.exp: New testcase to evaluate simple DFP expressions.
	* dfp-test.exp: New testcase to verify the printing and setting of
	DFP values.
	* dfp-test.c: New source file.

Index: gdb.base/dfp-exprs.exp
===================================================================
RCS file: gdb.base/dfp-exprs.exp
diff -N gdb.base/dfp-exprs.exp
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gdb.base/dfp-exprs.exp	18 Oct 2005 07:52:59 -0000
***************
*** 0 ****
--- 1,65 ----
+ # Copyright (C) 2005 Free Software Foundation, Inc.
+ 
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ # 
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ # 
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+ 
+ # This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
+ 
+ # This file is part of the gdb testsuite.  It contains test for evaluating 
+ # simple decimal floating point (DFP) expression.
+ 
+ if $tracelevel then {
+ 	strace $tracelevel
+ }
+ 
+ proc test_dfp_literals_accepted {} {
+ 
+     # Test various dfp values.
+ 
+     gdb_test "p 1.2df" " = 1.2df"
+     gdb_test "p -1.2df" " = -1.2df"
+     gdb_test "p 1.234567df" " = 1.234567df"
+     gdb_test "p -1.234567df" " = -1.234567df"
+     gdb_test "p 1234567.df" " = 1234567.df"
+     gdb_test "p -1234567.df" " = -1234567.df"
+ 
+     gdb_test "p 1.2dd" " = 1.2dd"
+     gdb_test "p -1.2dd" " = -1.2dd"
+     gdb_test "p 1.234567890123456dd" " = 1.234567890123456dd"
+     gdb_test "p -1.234567890123456dd" " = -1.234567890123456dd"
+     gdb_test "p 1234567890123456.dd" " = 1234567890123456.dd"
+     gdb_test "p -1234567890123456.dd" " = -1234567890123456.dd"
+ 
+     gdb_test "p 1.2dl" " = 1.2dl"
+     gdb_test "p -1.2dl" " = -1.2dl"
+     gdb_test "p 1.234567890123456789012345678901234dl" " = 1.234567890123456789012345678901234dl"
+     gdb_test "p -1.234567890123456789012345678901234dl" " = -1.234567890123456789012345678901234dl"
+     gdb_test "p 1234567890123456789012345678901234.dl" " = 1234567890123456789012345678901234.dl"
+     gdb_test "p -1234567890123456789012345678901234.dl" " = -1234567890123456789012345678901234.dl"
+ 
+ }
+ 
+ proc test_arithmetic_expressions {} {
+ 
+ # Arithmetic operations for DFP types are not yet implemented in GDB.
+ 
+ }
+ 
+ # Start with a fresh gdb.
+ 
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ 
+ test_dfp_literals_accepted
Index: gdb.base/dfp-test.c
===================================================================
RCS file: gdb.base/dfp-test.c
diff -N gdb.base/dfp-test.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gdb.base/dfp-test.c	18 Oct 2005 07:52:59 -0000
***************
*** 0 ****
--- 1,95 ----
+ /* This testcase is part of GDB, the GNU debugger.
+ 
+    Copyright 2005 Free Software Foundation, Inc.
+ 
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+    02111-1307, USA.  */
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+ volatile _Decimal32 d32;
+ volatile _Decimal64 d64;
+ volatile _Decimal128 d128;
+ 
+ struct decstruct
+ {
+   int int4;
+   long long8;
+   _Decimal32 dec32;
+   _Decimal64 dec64;
+   _Decimal128 dec128;
+ } ds;
+ 
+ static _Decimal32
+ arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
+          _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
+ {
+   return arg0;
+ }
+ 
+ static _Decimal64
+ arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
+          _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
+ {
+   return arg0;
+ }
+ 
+ static _Decimal128
+ arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
+          _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
+ {
+   return arg0;
+ }
+ 
+ int main()
+ {
+   /* An finite 32-bits decimal floating point.  */
+   d32 = 1.2345df;		/* Initialize d32.  */
+ 
+   /* Non-finite 32-bits decimal floating point: infinity and NaN.  */
+   d32 = __builtin_infd32();	/* Positive infd32.  */
+   d32 = -__builtin_infd32();	/* Negative infd32.  */
+   d32 = __builtin_nand32("");
+ 
+   /* An finite 64-bits decimal floating point.  */
+   d64 = 1.2345dd;		/* Initialize d64.  */
+ 
+   /* Non-finite 64-bits decimal floating point: infinity and NaN.  */
+   d64 = __builtin_infd64();	/* Positive infd64.  */
+   d64 = -__builtin_infd64();	/* Negative infd64.  */
+   d64 = __builtin_nand64("");
+ 
+   /* An finite 128-bits decimal floating point.  */
+   d128 = 1.2345dl;		/* Initialize d128.  */
+ 
+   /* Non-finite 128-bits decimal floating point: infinity and NaN.  */
+   d128 = __builtin_infd128();	/* Positive infd128.  */
+   d128 = -__builtin_infd128();	/* Negative infd128.  */
+   d128 = __builtin_nand128("");
+ 
+   /* Functions with decimal floating point as parameter and return value.  */
+   d32 = arg0_32 (0.1df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df);
+   d64 = arg0_64 (0.1dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd);
+   d128 = arg0_128 (0.1dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl);
+ 
+   ds.int4 = 1;
+   ds.long8 = 2;
+   ds.dec32 = 1.2345df;
+   ds.dec64 = 1.2345dd;
+   ds.dec128 = 1.2345dl;
+ 
+   return 0;	/* Exit point.  */
+ }
Index: gdb.base/dfp-test.exp
===================================================================
RCS file: gdb.base/dfp-test.exp
diff -N gdb.base/dfp-test.exp
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gdb.base/dfp-test.exp	18 Oct 2005 07:53:00 -0000
***************
*** 0 ****
--- 1,243 ----
+ # Copyright 2005 Free Software Foundation, Inc.
+ 
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+ 
+ #  This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
+ 
+ # This file is part of the gdb testsuite.  It is intended to test that
+ # gdb could correctly handle decimal floating point introduced in IEEE 754R.
+ 
+ proc d32_set_tests {} {
+ 
+     gdb_test "p d32=123.45df" " = 123.45df"
+     gdb_test "p d32=12345.df" " = 12345.df"
+     gdb_test "p d32=12345.67df" " = 12345.67df"
+     gdb_test "p d32=1234567.df" " = 1234567.df"
+ 
+     gdb_test "p d32=1.234567E0df" " = 1.234567df" 
+     gdb_test "p d32=1.234567E10df" " = 1.234567E\\+10df"
+     gdb_test "p d32=1.234567E+96df" " = 1.234567E\\+96df"
+ 
+     # Test that gdb could handle the max, normalized min and subnormalized min.
+     gdb_test "p d32=9.999999E+96df" " = 9.999999E\\+96df"
+     gdb_test "p d32=1.0E-95df" " = 1.E\\-95df"
+     gdb_test "p d32=1.E-101df" " = 1.E\\-101df"
+     gdb_test "p d32=0.000001E-95df" " = 1.E\\-101df"
+ 
+     # Test that gdb could detect coefficient/exponent out of range.
+     gdb_test "p d32=1.2345678df" ".*coefficient is out of range.*" "1.2345678df is out of range (coefficient)"
+     gdb_test "p d32=1.0E-101df" ".*exponent is out of range.*" "1.0E-101df is out of range (exponent)"
+     gdb_test "p d32=1.234567E+97df" ".*exponent is out of range.*" "1.234567E+97df is out of range (exponent)"
+ 
+     # Test that gdb could detect the errors in the string representation of _Decimal32
+     gdb_test "p d32=12345df" ".*Invalid number.*" "12345df is an invalid number"
+     gdb_test "p d32=1.23Edf" ".*Digit expected.*" "p d32=1.23Edf"
+     gdb_test "p d32=1.23E45Adf" ".*Invalid char found.*" "p d32=1.23E45Adf"
+ }
+ 
+ proc d64_set_tests {} {
+ 
+     gdb_test "p d64=123.45dd" " = 123.45dd"
+     gdb_test "p d64=12345.dd" " = 12345.dd"
+     gdb_test "p d64=12345.67dd" " = 12345.67dd"
+     gdb_test "p d64=1.234567890123456dd" " = 1.234567890123456dd"
+ 
+     gdb_test "p d64=1.234567890123456E10dd" " = 12345678901.23456dd"
+     gdb_test "p d64=1.234567890123456E100dd" " = 1.234567890123456E\\+100dd"
+     gdb_test "p d64=1.234567890123456E384dd" " = 1.234567890123456E\\+384dd"
+ 
+     # Test that gdb could handle the max, normalized min and subnormalized min.
+     gdb_test "p d64=9.999999999999999E384dd" " = 9.999999999999999E\\+384dd"
+     gdb_test "p d64=1.E-383dd" " = 1.E\\-383dd"
+     gdb_test "p d64=1.E-398dd" " = 1.E\\-398dd"
+     gdb_test "p d64=0.000000000000001E-383dd" " = 1.E\\-398dd"
+ 
+     # Test that gdb could detect coefficient/exponent out of range.
+     gdb_test "p d64=1.2345678901234567dd" ".*coefficient is out of range.*" "1.2345678901234567dd is out of range (coefficient)"
+     gdb_test "p d64=9.9999999999999999E384dd" ".*coefficient is out of range.*" "d64=9.9999999999999999E384dd is out of range (coefficient)"
+     gdb_test "p d64=1.234567890123456E385dd" ".*exponent is out of range.*" "d64=1.234567890123456E385dd is out of range (exponent)"
+     gdb_test "p d64=1.E-399dd" ".*exponent is out of range.*" "d64=1.E-399dd is out of range (exponent)"
+ 
+     # Test that gdb could detect the errors in the string representation of _Decimal32
+     gdb_test "p d64=12345dd" ".*Invalid number.*" "12345dd is an invalid number"
+     gdb_test "p d64=1.23Edd" ".*Digit expected.*" "p d64=1.23Edd"
+     gdb_test "p d64=1.23E45Add" ".*Invalid char found.*" "p d64=1.23E45Add"
+ }
+ 
+ proc d128_set_tests {} {
+ 
+     gdb_test "p d128=123.45dl" " = 123.45dl"
+     gdb_test "p d128=12345.dl" " = 12345.dl"
+     gdb_test "p d128=12345.67dl" " = 12345.67dl"
+     gdb_test "p d128=1.234567890123456789012345678901234dl" "= 1.234567890123456789012345678901234dl"
+ 
+     gdb_test "p d128=1.234567890123456E10dl" " = 12345678901.23456dl"
+     gdb_test "p d128=1.234567890123456E100dl" " = 1.234567890123456E\\+100dl"
+     gdb_test "p d128=1.234567890123456E1000dl" " = 1.234567890123456E\\+1000dl"
+ 
+     # Test that gdb could handle the max, normalized min and subnormalized min.
+     gdb_test "p d128=9.99999999999999999999999999999999E6144dl" " = 9.99999999999999999999999999999999E\\+6144dl"
+     gdb_test "p d128=1.E-6143dl" " = 1.E\\-6143dl"
+     gdb_test "p d128=1.E-6176dl" " = 1.E\\-6176dl"
+     gdb_test "p d128=0.000000000000000000000000000000001E-6143dl" " = 1.E\\-6176dl"
+ 
+     # Test that gdb could detect coefficient/exponent out of range.
+     gdb_test "p d128=1.2345678901234567890123456789012345dl" ".*coefficient is out of range.*" "1.2345678901234567890123456789012345dl is out of range (coefficient)"
+     gdb_test "p d128=9.9999999999999999999999999999999999dl" ".*coefficient is out of range.*" "d128=9.9999999999999999999999999999999999 is out of range (coefficient)"
+     gdb_test "p d128=1.234567890123456E6145dl" ".*exponent is out of range.*" "d128=1.234567890123456E6145dl is out of range (exponent)"
+     gdb_test "p d128=1.E-6177dl" ".*exponent is out of range.*" "d128=1.E-6177dl is out of range (exponent)"
+ 
+     # Test that gdb could detect the errors in the string representation of _Decimal32
+     gdb_test "p d128=12345dl" ".*Invalid number.*" "12345dl is an invalid number"
+     gdb_test "p d128=1.23Edl" ".*Digit expected.*" "p d128=1.23Edl"
+     gdb_test "p d128=1.23E45Adl" ".*Invalid char found.*" "p d128=1.23E45Adl"
+ }
+ 
+ 
+ if $tracelevel {
+     strace $tracelevel
+ }
+ 
+ set testfile "dfp-test"
+ set srcfile ${testfile}.c
+ set binfile ${objdir}/${subdir}/${testfile}
+ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+     untested "Couldn't compile ${srcfile}"
+     return -1
+ }
+ 
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load ${binfile}
+ 
+ if ![runto_main] then {
+     perror "couldn't run to breakpoint"
+     continue
+ }
+ 
+ # Different tests on 32-bits decimal floating point, including the printing 
+ # of finite numbers, infinite and NaN, and also the setting of different
+ # decimal value.
+ 
+ if [gdb_test "next" \
+     ".*Positive infd32.*" \
+     "next after initializing d32"] then { gdb_suppress_tests }
+ gdb_test "print d32" "1.2345df" "d32 is initialized to 1.2345df"
+ 
+ if [gdb_test "next" \
+     ".*Negative infd32.*" \
+     "next after assigning builtin infinity to d32"] then { gdb_suppress_tests }
+ gdb_test "print d32" "Infinity" "d32 is positive Infinity"
+ 
+ if [gdb_test "next" \
+     ".*__builtin_nand32.*" \
+     "next after assigning negative builtin infinity to d32"] then { gdb_suppress_tests }
+ gdb_test "print d32" "-Infinity" "d32 is negative Infinity"
+ 
+ if [gdb_test "next" \
+     ".*d64 = 1.2345dd.*" \
+     "next after assigning builtin NaN to d32"] then { gdb_suppress_tests }
+ gdb_test "print d32" "NaN" "d32 is NaN"
+ 
+ d32_set_tests 
+ 
+ 
+ # Different tests on 64-bits decimal floating point, including the display
+ # of finite number, infinite and NaN, and also the setting of different
+ # decimal value.
+ 
+ if [gdb_test "next" \
+     ".*Positive infd64.*" \
+     "next after initializing d64"] then { gdb_suppress_tests }
+ gdb_test "print d64" "1.2345dd" "d64 is initialized to 1.2345dd"
+ 
+ if [gdb_test "next" \
+     ".*Negative infd64.*" \
+     "next after assigning builtin infinity to d64"] then { gdb_suppress_tests }
+ gdb_test "print d64" "Infinity" "d64 is positive Infinity"
+ 
+ if [gdb_test "next" \
+     ".*__builtin_nand64.*" \
+     "next after assigning negative builtin infinity to d64"] then { gdb_suppress_tests }
+ gdb_test "print d64" "-Infinity" "d64 is negative Infinity"
+ 
+ if [gdb_test "next" \
+     ".*d128 = 1.2345dl.*" \
+     "next after assigning builtin NaN to d64"] then { gdb_suppress_tests }
+ gdb_test "print d64" "NaN" "d64 is NaN"
+ 
+ d64_set_tests 
+ 
+ 
+ # Different tests on 128-bits decimal floating point, including the display
+ # of finite number, infinite and NaN, and also the setting of different
+ # decimal value.
+ 
+ if [gdb_test "next" \
+     ".*Positive infd128.*" \
+     "next after initializing d128"] then { gdb_suppress_tests }
+ gdb_test "print d128" "1.2345dl" "d128 is initialized to 1.2345dl"
+ 
+ d128_set_tests
+ 
+ if [gdb_test "next" \
+     ".*Negative infd128.*" \
+     "next after assigning builtin infinity to d128"] then { gdb_suppress_tests }
+ gdb_test "print d128" "Infinity" "d128 is positive Infinity"
+ 
+ if [gdb_test "next" \
+     ".*__builtin_nand128.*" \
+     "next after assigning negative builtin infinity to d128"] then { gdb_suppress_tests }
+ gdb_test "print d128" "-Infinity" "d128 is negative Infinity"
+ 
+ if [gdb_test "next" \
+     ".*arg0_32.*" \
+     "next after assigning builtin NaN to d128"] then { gdb_suppress_tests }
+ gdb_test "print d128" "NaN" "d128 is NaN"
+ 
+ # The following tests are intended to verify that gdb can correctly handle 
+ # DFP types in function arguments.
+ 
+ gdb_breakpoint arg0_32
+ gdb_continue_to_breakpoint "entry to arg0_32"
+ gdb_test "backtrace" ".*arg0_32 \\(arg0=0.1df, arg1=1.df, arg2=2.df, arg3=3.df, arg4=4.df, arg5=5.df\\).*" "backtrace at arg0_32"
+ 
+ gdb_breakpoint arg0_64
+ gdb_continue_to_breakpoint "entry to arg0_64"
+ gdb_test "backtrace" ".*arg0_64 \\(arg0=0.1dd, arg1=1.dd, arg2=2.dd, arg3=3.dd, arg4=4.dd, arg5=5.dd\\).*" "backtrace at arg0_64"
+ 
+ gdb_breakpoint arg0_128
+ gdb_continue_to_breakpoint "entry to arg0_128"
+ gdb_test "backtrace" ".*arg0_128 \\(arg0=0.1dl, arg1=1.dl, arg2=2.dl, arg3=3.dl, arg4=4.dl, arg5=5.dl\\).*" "backtrace at arg0_128"
+ 
+ # The following tests are intended to verify that gdb can handle DFP types
+ # correctly in struct.
+ 
+ gdb_breakpoint [gdb_get_line_number "Exit point"]
+ gdb_continue_to_breakpoint "Setting a decimal struct"
+ gdb_test "print ds.dec32" " = 1.2345df"
+ gdb_test "print ds.dec64" " = 1.2345dd"
+ gdb_test "print ds.dec128" " = 1.2345dl"
+ 
+ # The following tests are intended to verify that gdb can handle "dfp1=dfp2"
+ # and "dfp1=-dfp2" correctly.
+ 
+ gdb_test "print ds.dec32=d32" " = 0.1df"
+ gdb_test "print ds.dec64=d64" " = 0.1dd"
+ gdb_test "print ds.dec128=d128" " = 0.1dl"
+ gdb_test "print ds.dec32 = -d32" " = -0.1df"
+ gdb_test "print ds.dec64 = -d64" " = -0.1dd"
+ gdb_test "print ds.dec128 = -d128" " = -0.1dl"


Best Regards
- Wu Zhou


On Sun, 2 Oct 2005, Daniel Jacobowitz wrote:

> On Wed, Sep 28, 2005 at 01:28:07PM +0800, Wu Zhou wrote:
> > In this testcase, there are totally 83 tests.  Most of them are about 
> > displaying and setting of dfp types, which are partitioned into 
> > three groups, one for each dfp types (_Decimal32, _Decimal64 and 
> > _Decimal128).  In each group, we first begin with the printing of 
> > a normal finite dfp value, then Infinity and NaN. Then we call 
> > d32_set_tests (d64_set_tests or d128_set_tests) to test that GDB 
> > could handle the setting different values of variable d32 (d64 or 
> > d128).
> > 
> > At the end of the testcase, we test that GDB could print out the dfp
> > values correctly in the function arguments and backtrace.
> 
> Just a few comments on the tests:
> 
> - This should be at least two separate tests, since the "p 1.5df" tests
> can be run without a GCC which supports DFP, even though dfp-test.c
> can't be compiled.
> 
> - C files need to have copyright headers.
> 
> In this:
> 
> > +     gdb_test "p d32=123.45df" "123.45df" "p d32=123.45df"
> 
> - The third argument to gdb_test defaults to the first argument, so you
> don't need it.
> 
> - The second argument should be more specific.  Something like
> "\$${decimal} = 123.45df".  I went to look at this test to see if my
> understanding of the use of string types was right, and the matching
> patterns were so loose I couldn't tell.
> 
> Otherwise I'll wait to look at this further until we're agreed on the
> GDB support.
> 
> -- 
> Daniel Jacobowitz
> CodeSourcery, LLC
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-10-18 10:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-28  5:26 [RFC] Decimal Floating Point support for GDB (Part 2: testcase) Wu Zhou
2005-10-02 21:05 ` Daniel Jacobowitz
2005-10-18 10:17   ` [RFC] Decimal Floating Point support for GDB (Part 2: testcase - Revised) Wu Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox