Updated copyright notices for most files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / dfp-test.exp
CommitLineData
9b254dd1 1# Copyright (C) 2007, 2008 Free Software Foundation, Inc.
93004d61
TJB
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16# This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
17
18# This file is part of the gdb testsuite. It is intended to test that
19# gdb could correctly handle decimal floating point introduced in IEEE 754R.
20
21proc d32_set_tests {} {
22
23 gdb_test "p d32=123.45df" " = 123.45"
24 gdb_test "p d32=12345.df" " = 12345"
25 gdb_test "p d32=12345.67df" " = 12345.67"
26 gdb_test "p d32=1234567.df" " = 1234567"
27
28 gdb_test "p d32=1.234567E0df" " = 1.234567"
29 gdb_test "p d32=1.234567E10df" " = 1.234567E\\+10"
30 gdb_test "p d32=1.234567E+96df" " = 1.234567E\\+96"
31
32 # Test that gdb could handle the max, normalized min and subnormalized min.
33 gdb_test "p d32=9.999999E96df" " = 9.999999E\\+96"
34 gdb_test "p d32=1.0E-95df" " = 1.0E\\-95"
35 gdb_test "p d32=1.E-101df" " = 1E\\-101"
36 gdb_test "p d32=0.000001E-95df" " = 1E\\-101"
37
38 # Test that gdb could detect coefficient/exponent out of range.
39 # The coefficient out of range will be rounded to its nearest value.
40 # And the exponent out of range will be handled as infinity.
41 gdb_test "p d32=1.2345678df" " = 1.234568" "1.2345678 is rounded to 1.234568"
42 gdb_test "p d32=1.0E-101df" " = 1E-101" "1.0E-101 is rounded to 1E-101"
43 gdb_test "p d32=1.234567E+97df" " = Infinity" "1.234567E+97 is Infinity"
44
45 # Test that gdb could detect the errors in the string representation of _Decimal32
46 gdb_test "p d32=12345.df" " = 12345" "12345. is an valid number"
47 gdb_test "p d32=12345df" ".*Invalid number.*" "12345 is an invalid number"
48 gdb_test "p d32=1.23Edf" " = NaN" "1.23E is NaN (not a number)"
49 gdb_test "p d32=1.23E45Adf" " = NaN" "1.23E45A is NaN (not a number)"
50}
51
52proc d64_set_tests {} {
53
54 gdb_test "p d64=123.45dd" " = 123.45"
55 gdb_test "p d64=12345.dd" " = 12345"
56 gdb_test "p d64=12345.67dd" " = 12345.67"
57 gdb_test "p d64=1.234567890123456dd" " = 1.234567890123456"
58
59 gdb_test "p d64=1.234567890123456E10dd" " = 12345678901.23456"
60 gdb_test "p d64=1.234567890123456E100dd" " = 1.234567890123456E\\+100"
61 gdb_test "p d64=1.234567890123456E384dd" " = 1.234567890123456E\\+384"
62
63 # Test that gdb could handle the max, normalized min and subnormalized min.
64 gdb_test "p d64=9.999999999999999E384dd" " = 9.999999999999999E\\+384"
65 gdb_test "p d64=1.E-383dd" " = 1E\\-383"
66 gdb_test "p d64=1.E-398dd" " = 1E\\-398"
67 gdb_test "p d64=0.000000000000001E-383dd" " = 1E\\-398"
68
69 # Test that gdb could detect coefficient/exponent out of range.
70 # The coefficient out of range will be rounded to its nearest value.
71 # And the exponent out of range will be handled as infinity.
72 gdb_test "p d64=1.2345678901234567dd" " = 1.234567890123457" "1.2345678901234567 is rounded to 1.234567890123457"
73 gdb_test "p d64=9.9999999999999999E384dd" " = Infinity" "d64=9.9999999999999999E384 is Infinity"
74 gdb_test "p d64=1.234567890123456E385dd" " = Infinity" "d64=1.234567890123456E385 is Infinity"
75
76 # Test that gdb could detect the errors in the string representation of _Decimal64
77 gdb_test "p d64=12345dd" ".*Invalid number.*" "12345dd is an invalid number"
78 gdb_test "p d64=1.23Edd" " = NaN" "1.23E is NaN (not a number)"
79 gdb_test "p d64=1.23E45Add" "= NaN" "1.23E45A is NaN (not a number)"
80}
81
82proc d128_set_tests {} {
83
84 gdb_test "p d128=123.45dl" " = 123.45"
85 gdb_test "p d128=12345.dl" " = 12345"
86 gdb_test "p d128=12345.67dl" " = 12345.67"
87 gdb_test "p d128=1.234567890123456789012345678901234dl" " = 1.234567890123456789012345678901234"
88
89 gdb_test "p d128=1.234567890123456E10dl" " = 12345678901.23456"
90 gdb_test "p d128=1.234567890123456E100dl" " = 1.234567890123456E\\+100"
91 gdb_test "p d128=1.234567890123456E1000dl" " = 1.234567890123456E\\+1000"
92
93 # Test that gdb could handle the max, normalized min and subnormalized min.
94 gdb_test "p d128=9.999999999999999999999999999999999E6144dl" " = 9.999999999999999999999999999999999E\\+6144"
95 gdb_test "p d128=1.E-6143dl" " = 1E\\-6143"
96 gdb_test "p d128=1.E-6176dl" " = 1E\\-6176"
97 gdb_test "p d128=0.000000000000000000000000000000001E-6143dl" " = 1E\\-6176"
98
99 # Test that gdb could detect coefficient/exponent out of range.
100 # The coefficient out of range will be rounded to its nearest value.
101 # And the exponent out of range will be handled as infinity.
102 gdb_test "p d128=1.2345678901234567890123456789012345dl" "1.234567890123456789012345678901234" "1.2345678901234567890123456789012345 is rounded to 1.234567890123456789012345678901234"
103 gdb_test "p d128=1.234567890123456E6145dl" "Infinity" "d128=1.234567890123456E6145 is Infinity"
104
105 # Test that gdb could detect the errors in the string representation of _Decimal128
106 gdb_test "p d128=12345dl" ".*Invalid number.*" "12345dl is an invalid number"
107 gdb_test "p d128=1.23Edl" " = NaN" "1.23E is NaN (not a number)"
108 gdb_test "p d128=1.23E45Adl" "= NaN" "1.23E45A is NaN (not a number)"
109}
110
111
112if $tracelevel {
113 strace $tracelevel
114}
115
116set testfile "dfp-test"
117set srcfile ${testfile}.c
118set binfile ${objdir}/${subdir}/${testfile}
ae0d01ff
UW
119# Try to compile the test case. If we can't, assume the
120# toolchain does not yet provide DFP support and bail out.
121if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quiet debug}] != "" } {
122 verbose "Skipping DFP tests."
93004d61
TJB
123 return -1
124}
125
126gdb_exit
127gdb_start
128gdb_reinitialize_dir $srcdir/$subdir
129gdb_load ${binfile}
130
131if ![runto_main] then {
132 perror "couldn't run to breakpoint"
133 continue
134}
135
136# Different tests on 32-bits decimal floating point, including the printing
137# of finite numbers, infinite and NaN, and also the setting of different
138# decimal value.
139
140if [gdb_test "next" \
141 ".*Positive infd32.*" \
142 "next after initializing d32"] then { gdb_suppress_tests }
143gdb_test "print d32" "1.2345" "d32 is initialized to 1.2345"
144
145if [gdb_test "next" \
146 ".*Negative infd32.*" \
147 "next after assigning builtin infinity to d32"] then { gdb_suppress_tests }
148gdb_test "print d32" "Infinity" "d32 is positive Infinity"
149
150if [gdb_test "next" \
151 ".*__builtin_nand32.*" \
152 "next after assigning negative builtin infinity to d32"] then { gdb_suppress_tests }
153gdb_test "print d32" "-Infinity" "d32 is negative Infinity"
154
155if [gdb_test "next" \
156 ".*d64 = 1.2345.*" \
157 "next after assigning builtin NaN to d32"] then { gdb_suppress_tests }
158gdb_test "print d32" "NaN" "d32 is NaN"
159
160d32_set_tests
161
162
163# Different tests on 64-bits decimal floating point, including the display
164# of finite number, infinite and NaN, and also the setting of different
165# decimal value.
166
167if [gdb_test "next" \
168 ".*Positive infd64.*" \
169 "next after initializing d64"] then { gdb_suppress_tests }
170gdb_test "print d64" "1.2345" "d64 is initialized to 1.2345"
171
172if [gdb_test "next" \
173 ".*Negative infd64.*" \
174 "next after assigning builtin infinity to d64"] then { gdb_suppress_tests }
175gdb_test "print d64" "Infinity" "d64 is positive Infinity"
176
177if [gdb_test "next" \
178 ".*__builtin_nand64.*" \
179 "next after assigning negative builtin infinity to d64"] then { gdb_suppress_tests }
180gdb_test "print d64" "-Infinity" "d64 is negative Infinity"
181
182if [gdb_test "next" \
183 ".*d128 = 1.2345.*" \
184 "next after assigning builtin NaN to d64"] then { gdb_suppress_tests }
185gdb_test "print d64" "NaN" "d64 is NaN"
186
187d64_set_tests
188
189
190# Different tests on 128-bits decimal floating point, including the display
191# of finite number, infinite and NaN, and also the setting of different
192# decimal value.
193
194if [gdb_test "next" \
195 ".*Positive infd128.*" \
196 "next after initializing d128"] then { gdb_suppress_tests }
197gdb_test "print d128" "1.2345" "d128 is initialized to 1.2345"
198
199d128_set_tests
200
201if [gdb_test "next" \
202 ".*Negative infd128.*" \
203 "next after assigning builtin infinity to d128"] then { gdb_suppress_tests }
204gdb_test "print d128" "Infinity" "d128 is positive Infinity"
205
206if [gdb_test "next" \
207 ".*__builtin_nand128.*" \
208 "next after assigning negative builtin infinity to d128"] then { gdb_suppress_tests }
209gdb_test "print d128" "-Infinity" "d128 is negative Infinity"
210
211if [gdb_test "next" \
212 ".*arg0_32.*" \
213 "next after assigning builtin NaN to d128"] then { gdb_suppress_tests }
214gdb_test "print d128" "NaN" "d128 is NaN"
215
216# The following tests are intended to verify that gdb can correctly handle
217# DFP types in function arguments.
218
219gdb_breakpoint arg0_32
220gdb_continue_to_breakpoint "entry to arg0_32"
221gdb_test "backtrace" ".*arg0_32 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=4.0, arg5=5.0\\).*" "backtrace at arg0_32"
222
223gdb_breakpoint arg0_64
224gdb_continue_to_breakpoint "entry to arg0_64"
225gdb_test "backtrace" ".*arg0_64 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=4.0, arg5=5.0\\).*" "backtrace at arg0_64"
226
227gdb_breakpoint arg0_128
228gdb_continue_to_breakpoint "entry to arg0_128"
229gdb_test "backtrace" ".*arg0_128 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=4.0, arg5=5.0\\).*" "backtrace at arg0_128"
230
231# The following tests are intended to verify that gdb can handle DFP types
232# correctly in struct.
233
234gdb_breakpoint [gdb_get_line_number "Exit point"]
235gdb_continue_to_breakpoint "Setting a decimal struct"
236gdb_test "print ds.dec32" " = 1.2345"
237gdb_test "print ds.dec64" " = 1.2345"
238gdb_test "print ds.dec128" " = 1.2345"
239
240# The following tests are intended to verify that gdb can handle "d1=d2"
241# and "d1=-d2" correctly.
242
243gdb_test "print ds.dec32=d32" " = 0.1"
244gdb_test "print ds.dec64=d64" " = 0.1"
245gdb_test "print ds.dec128=d128" " = 0.1"
246gdb_test "print ds.dec32 = -d32" " = -0.1"
247gdb_test "print ds.dec64 = -d64" " = -0.1"
248gdb_test "print ds.dec128 = -d128" " = -0.1"
This page took 0.048745 seconds and 4 git commands to generate.