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