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