1 # Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
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 2 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
21 # long_long.exp Test printing of 64-bit things in 32-bit gdb.
22 # Also test differnet kinds of formats.
28 if [target_info exists no_long_long] {
32 set testfile long_long
33 set srcfile ${srcdir}/${subdir}/${testfile}.c
34 set binfile ${objdir}/${subdir}/${testfile}
36 # What compiler are we using?
38 if [get_compiler_info ${binfile}] {
42 if {$hp_cc_compiler} {
48 if { [gdb_compile "${srcfile}" "${binfile}" executable [concat debug "additional_flags=$flag -w"]] != "" } {
49 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
57 gdb_reinitialize_dir $srcdir/$subdir
60 if { ![runto known_types] } then {
61 fail "run to known_types"
65 set target_bigendian_p 1
66 send_gdb "show endian\n"
68 -re ".*little endian.*$gdb_prompt $" { set target_bigendian_p 0 }
69 -re ".*big endian.*$gdb_prompt $" { }
70 -re ".*$gdb_prompt $" {
71 fail "getting target endian"
73 default { fail "(timeout) getting target endian" }
76 # Detect targets with 2-byte integers. Yes, it's not general to assume
77 # that all others have 4-byte ints, but don't worry about it until one
81 send_gdb "print sizeof(int)\n"
83 -re ".* = 2.*$gdb_prompt $" { set sizeof_int 2 }
84 -re ".*$gdb_prompt $" { }
88 # Detect targets with 4-byte shorts. Assume all others use 2-bytes.
91 send_gdb "print sizeof(short)\n"
93 -re ".* = 4.*$gdb_prompt $" { set sizeof_short 4 }
94 -re ".*$gdb_prompt $" { }
98 # Detect targets with 4-byte doubles.
101 send_gdb "print sizeof(double)\n"
103 -re ".* = 4.*$gdb_prompt $" { set sizeof_double 4 }
104 -re ".*$gdb_prompt $" { }
108 gdb_test "n 4" ".*38.*" "get to known place"
110 # Check the hack for long long prints.
112 gdb_test "p/x hex" ".*0x0*0.*" "hex print p/x"
113 gdb_test "p/x dec" ".*0xab54a98ceb1f0ad2.*" "decimal print p/x"
114 # see if 'p/<code>' is handled same as 'p /<code>'
116 gdb_test "p /x dec" ".*0xab54a98ceb1f0ad2.*" "default print dec"
117 gdb_test "p /x bin" ".*0x0*123456789abcdef.*" "default print bin"
118 gdb_test "p /x oct" ".*0xa72ee53977053977.*" "default print oct"
119 gdb_test "p hex" ".*= 0*x*0*0.*" "default print hex"
121 gdb_test "p/u dec" ".*12345678901234567890.*" "decimal print p/u"
122 gdb_test "p/t bin" ".*0*100100011010001010110011110001001101010111100110111101111.*" "binary print"
123 gdb_test "p/o oct" ".*01234567123456701234567.*" "octal print"
124 gdb_test "p /d bin" ".*81985529216486895.*" "print +ve long long"
125 gdb_test "p/d dec" ".*-6101065172474983726.*" "decimal print p/d"
127 # Try all the combinations to bump up coverage.
129 gdb_test "p/d oct" ".*-6399925985474168457.*"
130 gdb_test "p/u oct" ".*12046818088235383159.*"
131 gdb_test "p/o oct" ".*.*"
132 gdb_test "p/t oct" ".*1010011100101110111001010011100101110111000001010011100101110111.*"
133 gdb_test "p/a oct" ".*0x.*77053977.*"
134 gdb_test "p/c oct" ".*'w'.*"
136 if { $sizeof_double == 8 } {
138 # ARM floating point numbers are not strictly little endian or big endian,
139 # but a hybrid. They are in little endian format with the two words
140 # swapped in big endian format.
142 if [ istarget "arm*-*-*" ] then {
144 # assume the long long represents a floating point double in ARM format
145 gdb_test "p/f oct" ".*2.1386676354387559e\\+265.*"
149 # assume the long long represents a floating point double in little
151 gdb_test "p/f oct" ".*-5.9822653797615723e-120.*"
157 gdb_test "p/f oct" ".*-2.42716126e-15.*"
161 if { $target_bigendian_p } {
163 if { $sizeof_int == 4 } {
165 gdb_test "p/d *(int *)&oct" ".*-1490098887.*"
166 gdb_test "p/u *(int *)&oct" ".*2804868409.*"
167 gdb_test "p/o *(int *)&oct" ".*024713562471.*"
168 gdb_test "p/t *(int *)&oct" ".*10100111001011101110010100111001.*"
169 gdb_test "p/a *(int *)&oct" ".*0xf*a72ee539.*"
170 gdb_test "p/c *(int *)&oct" ".*57 '9'.*"
171 gdb_test "p/f *(int *)&oct" ".*-2.42716126e-15.*"
175 gdb_test "p/d *(int *)&oct" ".*-22738.*"
176 gdb_test "p/u *(int *)&oct" ".*42798.*"
177 gdb_test "p/o *(int *)&oct" ".*0123456.*"
178 gdb_test "p/t *(int *)&oct" ".*1010011100101110.*"
179 gdb_test "p/a *(int *)&oct" ".*0xffffa72e.*"
180 gdb_test "p/c *(int *)&oct" ".*46 '.'.*"
181 gdb_test "p/f *(int *)&oct" ".*-22738.*"
185 if { $sizeof_short == 2 } {
186 gdb_test "p/d *(short *)&oct" ".*-22738.*"
187 gdb_test "p/u *(short *)&oct" ".*42798.*"
188 gdb_test "p/o *(short *)&oct" ".*0123456.*"
189 gdb_test "p/t *(short *)&oct" ".*1010011100101110.*"
190 gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*"
191 gdb_test "p/c *(short *)&oct" ".* 46 '.'.*"
192 gdb_test "p/f *(short *)&oct" ".*-22738.*"
194 gdb_test "p/d *(short *)&oct" ".*-1490098887.*"
195 gdb_test "p/u *(short *)&oct" ".*2804868409.*"
196 gdb_test "p/o *(short *)&oct" ".*024713562471.*"
197 gdb_test "p/t *(short *)&oct" ".*10100111001011101110010100111001.*"
198 gdb_test "p/a *(short *)&oct" ".*0xf*a72ee539.*"
199 gdb_test "p/c *(short *)&oct" ".* 57 '9'.*"
200 gdb_test "p/f *(short *)&oct" ".*-2.42716126e-15.*"
203 gdb_test "x/x &oct" ".*0xa72ee539.*"
204 gdb_test "x/d &oct" ".*.-1490098887*"
205 gdb_test "x/u &oct" ".*2804868409.*"
206 gdb_test "x/o &oct" ".*024713562471.*"
207 gdb_test "x/t &oct" ".*10100111001011101110010100111001.*"
208 gdb_test "x/a &oct" ".*0xa72ee539.*"
209 gdb_test "x/c &oct" ".*-89 .*"
210 # FIXME GDB's output is correct, but this longer match fails.
211 # gdb_test "x/c &oct" ".*-89 '\\\\247'.*"
212 if { $sizeof_double == 8 } {
213 gdb_test "x/f &oct" ".*-5.9822653797615723e-120.*"
215 gdb_test "x/f &oct" ".*-2.42716126e-15.*"
218 # FIXME Fill in the results for all the following tests. (But be careful
219 # about looking at locations with unspecified contents!)
221 gdb_test "x/2x &oct" ".*0xa72ee53977053977.*"
222 gdb_test "x/2d &oct" ".*-6399925985474168457.*"
223 gdb_test "x/2u &oct" ".*.*"
224 gdb_test "x/2o &oct" ".*.*"
225 gdb_test "x/2t &oct" ".*.*"
226 gdb_test "x/2a &oct" ".*.*"
227 gdb_test "x/2c &oct" ".*.*"
228 gdb_test "x/2f &oct" ".*.*"
230 gdb_test "x/2bx &oct" ".*.*"
231 gdb_test "x/2bd &oct" ".*.*"
232 gdb_test "x/2bu &oct" ".*.*"
233 gdb_test "x/2bo &oct" ".*.*"
234 gdb_test "x/2bt &oct" ".*.*"
235 gdb_test "x/2ba &oct" ".*.*"
236 gdb_test "x/2bc &oct" ".*.*"
237 gdb_test "x/2bf &oct" ".*.*"
239 gdb_test "x/2hx &oct" ".*.*"
240 gdb_test "x/2hd &oct" ".*.*"
241 gdb_test "x/2hu &oct" ".*.*"
242 gdb_test "x/2ho &oct" ".*.*"
243 gdb_test "x/2ht &oct" ".*.*"
244 gdb_test "x/2ha &oct" ".*.*"
245 gdb_test "x/2hc &oct" ".*.*"
246 gdb_test "x/2hf &oct" ".*.*"
248 gdb_test "x/2wx &oct" ".*.*"
249 gdb_test "x/2wd &oct" ".*.*"
250 gdb_test "x/2wu &oct" ".*.*"
251 gdb_test "x/2wo &oct" ".*.*"
252 gdb_test "x/2wt &oct" ".*.*"
253 gdb_test "x/2wa &oct" ".*.*"
254 gdb_test "x/2wc &oct" ".*.*"
255 gdb_test "x/2wf &oct" ".*.*"
257 gdb_test "x/2gx &oct" ".*.*"
258 gdb_test "x/2gd &oct" ".*.*"
259 gdb_test "x/2gu &oct" ".*.*"
260 gdb_test "x/2go &oct" ".*.*"
261 gdb_test "x/2gt &oct" ".*.*"
262 gdb_test "x/2ga &oct" ".*.*"
263 gdb_test "x/2gc &oct" ".*.*"
264 gdb_test "x/2gf &oct" ".*.*"
268 # FIXME Add little-endian versions of these tests, or define a
269 # gdb_test_bi with two strings to match on.