Commit | Line | Data |
---|---|---|
1903502c | 1 | # Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 |
f2dd3617 | 2 | # Free Software Foundation, Inc. |
c906108c SS |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
17 | ||
c906108c SS |
18 | # long_long.exp Test printing of 64-bit things in 32-bit gdb. |
19 | # Also test differnet kinds of formats. | |
20 | # | |
21 | if $tracelevel then { | |
22 | strace $tracelevel | |
23 | } | |
24 | ||
fc33412a DT |
25 | if [target_info exists no_long_long] { |
26 | return 0 | |
27 | } | |
28 | ||
c906108c | 29 | set testfile long_long |
f2dd3617 | 30 | set srcfile ${testfile}.c |
c906108c SS |
31 | set binfile ${objdir}/${subdir}/${testfile} |
32 | ||
33 | # What compiler are we using? | |
34 | # | |
35 | if [get_compiler_info ${binfile}] { | |
36 | return -1 | |
37 | } | |
38 | ||
085dd6e6 JM |
39 | if {$hp_cc_compiler} { |
40 | set flag "+e" | |
c906108c | 41 | } else { |
085dd6e6 | 42 | set flag "" |
c906108c SS |
43 | } |
44 | ||
f2dd3617 | 45 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug "additional_flags=$flag -w"]] != "" } { |
085dd6e6 | 46 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
c906108c SS |
47 | } |
48 | ||
49 | # use this to debug: | |
50 | #log_user 1 | |
51 | ||
52 | gdb_exit | |
53 | gdb_start | |
54 | gdb_reinitialize_dir $srcdir/$subdir | |
55 | gdb_load ${binfile} | |
56 | ||
57 | if { ![runto known_types] } then { | |
58 | fail "run to known_types" | |
59 | return | |
60 | } | |
61 | ||
96baa820 JM |
62 | set target_bigendian_p 1 |
63 | send_gdb "show endian\n" | |
64 | gdb_expect { | |
65 | -re ".*little endian.*$gdb_prompt $" { set target_bigendian_p 0 } | |
66 | -re ".*big endian.*$gdb_prompt $" { } | |
67 | -re ".*$gdb_prompt $" { | |
68 | fail "getting target endian" | |
69 | } | |
70 | default { fail "(timeout) getting target endian" } | |
71 | } | |
72 | ||
cff3e48b JM |
73 | # Detect targets with 2-byte integers. Yes, it's not general to assume |
74 | # that all others have 4-byte ints, but don't worry about it until one | |
75 | # actually exists. | |
76 | ||
77 | set sizeof_int 4 | |
78 | send_gdb "print sizeof(int)\n" | |
79 | gdb_expect { | |
80 | -re ".* = 2.*$gdb_prompt $" { set sizeof_int 2 } | |
81 | -re ".*$gdb_prompt $" { } | |
82 | default { } | |
83 | } | |
84 | ||
7e5a9322 SC |
85 | # Detect targets with 2-byte pointers. Assume all others use 4-bytes. |
86 | set sizeof_ptr 4 | |
87 | send_gdb "print sizeof(void*)\n" | |
88 | gdb_expect { | |
89 | -re ".* = 2.*$gdb_prompt $" { set sizeof_ptr 2 } | |
90 | -re ".*$gdb_prompt $" { } | |
91 | default { } | |
92 | } | |
93 | ||
2caa35cb MS |
94 | # Detect targets with 4-byte shorts. Assume all others use 2-bytes. |
95 | ||
96 | set sizeof_short 2 | |
97 | send_gdb "print sizeof(short)\n" | |
98 | gdb_expect { | |
99 | -re ".* = 4.*$gdb_prompt $" { set sizeof_short 4 } | |
100 | -re ".*$gdb_prompt $" { } | |
101 | default { } | |
102 | } | |
103 | ||
cff3e48b JM |
104 | # Detect targets with 4-byte doubles. |
105 | ||
106 | set sizeof_double 8 | |
107 | send_gdb "print sizeof(double)\n" | |
108 | gdb_expect { | |
109 | -re ".* = 4.*$gdb_prompt $" { set sizeof_double 4 } | |
110 | -re ".*$gdb_prompt $" { } | |
111 | default { } | |
112 | } | |
113 | ||
c15b0d21 MS |
114 | set sizeof_long_double 8 |
115 | send_gdb "print sizeof(long double)\n" | |
116 | gdb_expect { | |
117 | -re ".* = 4.*$gdb_prompt $" { set sizeof_long_double 4 } | |
118 | -re ".*$gdb_prompt $" { } | |
119 | default { } | |
120 | } | |
121 | ||
1903502c MC |
122 | gdb_breakpoint [gdb_get_line_number "Stop here and look"] |
123 | gdb_continue_to_breakpoint "Stop here and look" | |
c906108c SS |
124 | |
125 | # Check the hack for long long prints. | |
126 | # | |
085dd6e6 JM |
127 | gdb_test "p/x hex" ".*0x0*0.*" "hex print p/x" |
128 | gdb_test "p/x dec" ".*0xab54a98ceb1f0ad2.*" "decimal print p/x" | |
129 | # see if 'p/<code>' is handled same as 'p /<code>' | |
130 | # | |
131 | gdb_test "p /x dec" ".*0xab54a98ceb1f0ad2.*" "default print dec" | |
132 | gdb_test "p /x bin" ".*0x0*123456789abcdef.*" "default print bin" | |
133 | gdb_test "p /x oct" ".*0xa72ee53977053977.*" "default print oct" | |
134 | gdb_test "p hex" ".*= 0*x*0*0.*" "default print hex" | |
135 | ||
136 | gdb_test "p/u dec" ".*12345678901234567890.*" "decimal print p/u" | |
137 | gdb_test "p/t bin" ".*0*100100011010001010110011110001001101010111100110111101111.*" "binary print" | |
c906108c | 138 | gdb_test "p/o oct" ".*01234567123456701234567.*" "octal print" |
085dd6e6 JM |
139 | gdb_test "p /d bin" ".*81985529216486895.*" "print +ve long long" |
140 | gdb_test "p/d dec" ".*-6101065172474983726.*" "decimal print p/d" | |
c906108c SS |
141 | |
142 | # Try all the combinations to bump up coverage. | |
143 | # | |
a0b3c4fd JM |
144 | gdb_test "p/d oct" ".*-6399925985474168457.*" |
145 | gdb_test "p/u oct" ".*12046818088235383159.*" | |
146 | gdb_test "p/o oct" ".*.*" | |
147 | gdb_test "p/t oct" ".*1010011100101110111001010011100101110111000001010011100101110111.*" | |
7e5a9322 SC |
148 | if { $sizeof_ptr == 2 } { |
149 | gdb_test "p/a oct" ".*0x.*3977.*" | |
150 | } else { | |
151 | gdb_test "p/a oct" ".*0x.*77053977.*" | |
152 | } | |
a0b3c4fd | 153 | gdb_test "p/c oct" ".*'w'.*" |
cff3e48b | 154 | |
c15b0d21 MS |
155 | if { $sizeof_double == 8 || $sizeof_long_double == 8 } { |
156 | # ARM floating point numbers are not strictly little endian or big endian, | |
157 | # but a hybrid. They are in little endian format with the two words | |
158 | # swapped in big endian format. | |
f1a6b754 | 159 | |
35928259 | 160 | if { [istarget "arm*-*-*"] || \ |
377daeed | 161 | [istarget "xscale*-*-*"] || \ |
35928259 | 162 | [istarget "strongarm*-*-*"] } then { |
fedfc8e6 MS |
163 | # assume the long long represents a floating point double in ARM format |
164 | gdb_test "p/f oct" ".*2.1386676354387559e\\+265.*" | |
165 | } else { | |
166 | # assume the long long represents a floating point double in little | |
167 | # endian format | |
168 | gdb_test "p/f oct" ".*-5.9822653797615723e-120.*" | |
169 | } | |
f1a6b754 | 170 | |
cff3e48b JM |
171 | } else { |
172 | ||
173 | gdb_test "p/f oct" ".*-2.42716126e-15.*" | |
f1a6b754 | 174 | |
cff3e48b | 175 | } |
a0b3c4fd | 176 | |
96baa820 JM |
177 | if { $target_bigendian_p } { |
178 | ||
cff3e48b JM |
179 | if { $sizeof_int == 4 } { |
180 | ||
181 | gdb_test "p/d *(int *)&oct" ".*-1490098887.*" | |
182 | gdb_test "p/u *(int *)&oct" ".*2804868409.*" | |
183 | gdb_test "p/o *(int *)&oct" ".*024713562471.*" | |
184 | gdb_test "p/t *(int *)&oct" ".*10100111001011101110010100111001.*" | |
7e5a9322 SC |
185 | |
186 | if { $sizeof_ptr == 2 } { | |
187 | gdb_test "p/a *(int *)&oct" ".*0xe539.*" | |
188 | } else { | |
189 | gdb_test "p/a *(int *)&oct" ".*0xf*a72ee539.*" | |
190 | } | |
191 | ||
cff3e48b JM |
192 | gdb_test "p/c *(int *)&oct" ".*57 '9'.*" |
193 | gdb_test "p/f *(int *)&oct" ".*-2.42716126e-15.*" | |
194 | ||
195 | } else { | |
196 | ||
197 | gdb_test "p/d *(int *)&oct" ".*-22738.*" | |
198 | gdb_test "p/u *(int *)&oct" ".*42798.*" | |
199 | gdb_test "p/o *(int *)&oct" ".*0123456.*" | |
200 | gdb_test "p/t *(int *)&oct" ".*1010011100101110.*" | |
7e5a9322 SC |
201 | |
202 | if { $sizeof_ptr == 2 } { | |
203 | gdb_test "p/a *(int *)&oct" ".*0xa72e.*" | |
204 | } else { | |
205 | gdb_test "p/a *(int *)&oct" ".*0xffffa72e.*" | |
206 | } | |
cff3e48b JM |
207 | gdb_test "p/c *(int *)&oct" ".*46 '.'.*" |
208 | gdb_test "p/f *(int *)&oct" ".*-22738.*" | |
209 | ||
210 | } | |
96baa820 | 211 | |
2caa35cb MS |
212 | if { $sizeof_short == 2 } { |
213 | gdb_test "p/d *(short *)&oct" ".*-22738.*" | |
214 | gdb_test "p/u *(short *)&oct" ".*42798.*" | |
215 | gdb_test "p/o *(short *)&oct" ".*0123456.*" | |
216 | gdb_test "p/t *(short *)&oct" ".*1010011100101110.*" | |
7e5a9322 SC |
217 | if { $sizeof_ptr == 2 } { |
218 | gdb_test "p/a *(short *)&oct" ".*0xa72e.*" | |
219 | } else { | |
220 | gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*" | |
221 | } | |
2caa35cb MS |
222 | gdb_test "p/c *(short *)&oct" ".* 46 '.'.*" |
223 | gdb_test "p/f *(short *)&oct" ".*-22738.*" | |
224 | } else { | |
225 | gdb_test "p/d *(short *)&oct" ".*-1490098887.*" | |
226 | gdb_test "p/u *(short *)&oct" ".*2804868409.*" | |
227 | gdb_test "p/o *(short *)&oct" ".*024713562471.*" | |
228 | gdb_test "p/t *(short *)&oct" ".*10100111001011101110010100111001.*" | |
229 | gdb_test "p/a *(short *)&oct" ".*0xf*a72ee539.*" | |
230 | gdb_test "p/c *(short *)&oct" ".* 57 '9'.*" | |
231 | gdb_test "p/f *(short *)&oct" ".*-2.42716126e-15.*" | |
232 | } | |
96baa820 JM |
233 | |
234 | gdb_test "x/x &oct" ".*0xa72ee539.*" | |
235 | gdb_test "x/d &oct" ".*.-1490098887*" | |
236 | gdb_test "x/u &oct" ".*2804868409.*" | |
237 | gdb_test "x/o &oct" ".*024713562471.*" | |
238 | gdb_test "x/t &oct" ".*10100111001011101110010100111001.*" | |
7e5a9322 SC |
239 | if { $sizeof_ptr == 2 } { |
240 | gdb_test "x/a &oct" ".*0xa72e.*" | |
241 | } else { | |
242 | gdb_test "x/a &oct" ".*0xa72ee539.*" | |
243 | } | |
96baa820 JM |
244 | gdb_test "x/c &oct" ".*-89 .*" |
245 | # FIXME GDB's output is correct, but this longer match fails. | |
246 | # gdb_test "x/c &oct" ".*-89 '\\\\247'.*" | |
c15b0d21 | 247 | if { $sizeof_double == 8 || $sizeof_long_double == 8 } { |
cff3e48b JM |
248 | gdb_test "x/f &oct" ".*-5.9822653797615723e-120.*" |
249 | } else { | |
250 | gdb_test "x/f &oct" ".*-2.42716126e-15.*" | |
251 | } | |
96baa820 JM |
252 | |
253 | # FIXME Fill in the results for all the following tests. (But be careful | |
254 | # about looking at locations with unspecified contents!) | |
255 | ||
256 | gdb_test "x/2x &oct" ".*0xa72ee53977053977.*" | |
257 | gdb_test "x/2d &oct" ".*-6399925985474168457.*" | |
258 | gdb_test "x/2u &oct" ".*.*" | |
259 | gdb_test "x/2o &oct" ".*.*" | |
260 | gdb_test "x/2t &oct" ".*.*" | |
261 | gdb_test "x/2a &oct" ".*.*" | |
262 | gdb_test "x/2c &oct" ".*.*" | |
263 | gdb_test "x/2f &oct" ".*.*" | |
264 | ||
265 | gdb_test "x/2bx &oct" ".*.*" | |
266 | gdb_test "x/2bd &oct" ".*.*" | |
267 | gdb_test "x/2bu &oct" ".*.*" | |
268 | gdb_test "x/2bo &oct" ".*.*" | |
269 | gdb_test "x/2bt &oct" ".*.*" | |
270 | gdb_test "x/2ba &oct" ".*.*" | |
271 | gdb_test "x/2bc &oct" ".*.*" | |
272 | gdb_test "x/2bf &oct" ".*.*" | |
273 | ||
274 | gdb_test "x/2hx &oct" ".*.*" | |
275 | gdb_test "x/2hd &oct" ".*.*" | |
276 | gdb_test "x/2hu &oct" ".*.*" | |
277 | gdb_test "x/2ho &oct" ".*.*" | |
278 | gdb_test "x/2ht &oct" ".*.*" | |
279 | gdb_test "x/2ha &oct" ".*.*" | |
280 | gdb_test "x/2hc &oct" ".*.*" | |
281 | gdb_test "x/2hf &oct" ".*.*" | |
282 | ||
283 | gdb_test "x/2wx &oct" ".*.*" | |
284 | gdb_test "x/2wd &oct" ".*.*" | |
285 | gdb_test "x/2wu &oct" ".*.*" | |
286 | gdb_test "x/2wo &oct" ".*.*" | |
287 | gdb_test "x/2wt &oct" ".*.*" | |
288 | gdb_test "x/2wa &oct" ".*.*" | |
289 | gdb_test "x/2wc &oct" ".*.*" | |
290 | gdb_test "x/2wf &oct" ".*.*" | |
291 | ||
292 | gdb_test "x/2gx &oct" ".*.*" | |
293 | gdb_test "x/2gd &oct" ".*.*" | |
294 | gdb_test "x/2gu &oct" ".*.*" | |
295 | gdb_test "x/2go &oct" ".*.*" | |
296 | gdb_test "x/2gt &oct" ".*.*" | |
297 | gdb_test "x/2ga &oct" ".*.*" | |
298 | gdb_test "x/2gc &oct" ".*.*" | |
299 | gdb_test "x/2gf &oct" ".*.*" | |
300 | ||
301 | } else { | |
302 | ||
303 | # FIXME Add little-endian versions of these tests, or define a | |
304 | # gdb_test_bi with two strings to match on. | |
305 | ||
306 | } | |
c906108c SS |
307 | |
308 | gdb_exit | |
309 | return 0 |