Commit | Line | Data |
---|---|---|
b6ba6518 | 1 | # Copyright 1997, 1998, 1999, 2000 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 | ||
28 | set testfile long_long | |
29 | set srcfile ${srcdir}/${subdir}/${testfile}.c | |
30 | set binfile ${objdir}/${subdir}/${testfile} | |
31 | ||
32 | # What compiler are we using? | |
33 | # | |
34 | if [get_compiler_info ${binfile}] { | |
35 | return -1 | |
36 | } | |
37 | ||
085dd6e6 JM |
38 | if {$hp_cc_compiler} { |
39 | set flag "+e" | |
c906108c | 40 | } else { |
085dd6e6 | 41 | set flag "" |
c906108c SS |
42 | } |
43 | ||
085dd6e6 JM |
44 | if { [gdb_compile "${srcfile}" "${binfile}" executable [concat debug "additional_flags=$flag -w"]] != "" } { |
45 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
c906108c SS |
46 | } |
47 | ||
48 | # use this to debug: | |
49 | #log_user 1 | |
50 | ||
51 | gdb_exit | |
52 | gdb_start | |
53 | gdb_reinitialize_dir $srcdir/$subdir | |
54 | gdb_load ${binfile} | |
55 | ||
56 | if { ![runto known_types] } then { | |
57 | fail "run to known_types" | |
58 | return | |
59 | } | |
60 | ||
96baa820 JM |
61 | set target_bigendian_p 1 |
62 | send_gdb "show endian\n" | |
63 | gdb_expect { | |
64 | -re ".*little endian.*$gdb_prompt $" { set target_bigendian_p 0 } | |
65 | -re ".*big endian.*$gdb_prompt $" { } | |
66 | -re ".*$gdb_prompt $" { | |
67 | fail "getting target endian" | |
68 | } | |
69 | default { fail "(timeout) getting target endian" } | |
70 | } | |
71 | ||
cff3e48b JM |
72 | # Detect targets with 2-byte integers. Yes, it's not general to assume |
73 | # that all others have 4-byte ints, but don't worry about it until one | |
74 | # actually exists. | |
75 | ||
76 | set sizeof_int 4 | |
77 | send_gdb "print sizeof(int)\n" | |
78 | gdb_expect { | |
79 | -re ".* = 2.*$gdb_prompt $" { set sizeof_int 2 } | |
80 | -re ".*$gdb_prompt $" { } | |
81 | default { } | |
82 | } | |
83 | ||
84 | # Detect targets with 4-byte doubles. | |
85 | ||
86 | set sizeof_double 8 | |
87 | send_gdb "print sizeof(double)\n" | |
88 | gdb_expect { | |
89 | -re ".* = 4.*$gdb_prompt $" { set sizeof_double 4 } | |
90 | -re ".*$gdb_prompt $" { } | |
91 | default { } | |
92 | } | |
93 | ||
085dd6e6 | 94 | gdb_test "n 4" ".*38.*" "get to known place" |
c906108c SS |
95 | |
96 | # Check the hack for long long prints. | |
97 | # | |
085dd6e6 JM |
98 | gdb_test "p/x hex" ".*0x0*0.*" "hex print p/x" |
99 | gdb_test "p/x dec" ".*0xab54a98ceb1f0ad2.*" "decimal print p/x" | |
100 | # see if 'p/<code>' is handled same as 'p /<code>' | |
101 | # | |
102 | gdb_test "p /x dec" ".*0xab54a98ceb1f0ad2.*" "default print dec" | |
103 | gdb_test "p /x bin" ".*0x0*123456789abcdef.*" "default print bin" | |
104 | gdb_test "p /x oct" ".*0xa72ee53977053977.*" "default print oct" | |
105 | gdb_test "p hex" ".*= 0*x*0*0.*" "default print hex" | |
106 | ||
107 | gdb_test "p/u dec" ".*12345678901234567890.*" "decimal print p/u" | |
108 | gdb_test "p/t bin" ".*0*100100011010001010110011110001001101010111100110111101111.*" "binary print" | |
c906108c | 109 | gdb_test "p/o oct" ".*01234567123456701234567.*" "octal print" |
085dd6e6 JM |
110 | gdb_test "p /d bin" ".*81985529216486895.*" "print +ve long long" |
111 | gdb_test "p/d dec" ".*-6101065172474983726.*" "decimal print p/d" | |
c906108c SS |
112 | |
113 | # Try all the combinations to bump up coverage. | |
114 | # | |
a0b3c4fd JM |
115 | gdb_test "p/d oct" ".*-6399925985474168457.*" |
116 | gdb_test "p/u oct" ".*12046818088235383159.*" | |
117 | gdb_test "p/o oct" ".*.*" | |
118 | gdb_test "p/t oct" ".*1010011100101110111001010011100101110111000001010011100101110111.*" | |
119 | gdb_test "p/a oct" ".*0x.*77053977.*" | |
120 | gdb_test "p/c oct" ".*'w'.*" | |
cff3e48b JM |
121 | |
122 | if { $sizeof_double == 8 } { | |
123 | ||
f1a6b754 SB |
124 | # ARM floating point numbers are not strictly little endian or big endian, |
125 | # but a hybrid. They are in little endian format with the two words | |
126 | # swapped in big endian format. | |
127 | ||
128 | if [ istarget "arm*-*-*" ] then { | |
129 | ||
130 | # assume the long long represents a floating point double in ARM format | |
131 | gdb_test "p/f oct" ".*2.1386676354387559e\\+265.*" | |
132 | ||
133 | } else { | |
134 | ||
135 | # assume the long long represents a floating point double in little | |
136 | # endian format | |
cff3e48b JM |
137 | gdb_test "p/f oct" ".*-5.9822653797615723e-120.*" |
138 | ||
f1a6b754 SB |
139 | } |
140 | ||
cff3e48b JM |
141 | } else { |
142 | ||
143 | gdb_test "p/f oct" ".*-2.42716126e-15.*" | |
f1a6b754 | 144 | |
cff3e48b | 145 | } |
a0b3c4fd | 146 | |
96baa820 JM |
147 | if { $target_bigendian_p } { |
148 | ||
cff3e48b JM |
149 | if { $sizeof_int == 4 } { |
150 | ||
151 | gdb_test "p/d *(int *)&oct" ".*-1490098887.*" | |
152 | gdb_test "p/u *(int *)&oct" ".*2804868409.*" | |
153 | gdb_test "p/o *(int *)&oct" ".*024713562471.*" | |
154 | gdb_test "p/t *(int *)&oct" ".*10100111001011101110010100111001.*" | |
155 | gdb_test "p/a *(int *)&oct" ".*0xf*a72ee539.*" | |
156 | gdb_test "p/c *(int *)&oct" ".*57 '9'.*" | |
157 | gdb_test "p/f *(int *)&oct" ".*-2.42716126e-15.*" | |
158 | ||
159 | } else { | |
160 | ||
161 | gdb_test "p/d *(int *)&oct" ".*-22738.*" | |
162 | gdb_test "p/u *(int *)&oct" ".*42798.*" | |
163 | gdb_test "p/o *(int *)&oct" ".*0123456.*" | |
164 | gdb_test "p/t *(int *)&oct" ".*1010011100101110.*" | |
165 | gdb_test "p/a *(int *)&oct" ".*0xffffa72e.*" | |
166 | gdb_test "p/c *(int *)&oct" ".*46 '.'.*" | |
167 | gdb_test "p/f *(int *)&oct" ".*-22738.*" | |
168 | ||
169 | } | |
96baa820 JM |
170 | |
171 | gdb_test "p/d *(short *)&oct" ".*-22738.*" | |
172 | gdb_test "p/u *(short *)&oct" ".*42798.*" | |
173 | gdb_test "p/o *(short *)&oct" ".*0123456.*" | |
174 | gdb_test "p/t *(short *)&oct" ".*1010011100101110.*" | |
175 | gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*" | |
176 | gdb_test "p/c *(short *)&oct" ".* 46 '.'.*" | |
177 | gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*" | |
178 | gdb_test "p/f *(short *)&oct" ".*-22738.*" | |
179 | ||
180 | gdb_test "x/x &oct" ".*0xa72ee539.*" | |
181 | gdb_test "x/d &oct" ".*.-1490098887*" | |
182 | gdb_test "x/u &oct" ".*2804868409.*" | |
183 | gdb_test "x/o &oct" ".*024713562471.*" | |
184 | gdb_test "x/t &oct" ".*10100111001011101110010100111001.*" | |
185 | gdb_test "x/a &oct" ".*0xa72ee539.*" | |
186 | gdb_test "x/c &oct" ".*-89 .*" | |
187 | # FIXME GDB's output is correct, but this longer match fails. | |
188 | # gdb_test "x/c &oct" ".*-89 '\\\\247'.*" | |
cff3e48b JM |
189 | if { $sizeof_double == 8 } { |
190 | gdb_test "x/f &oct" ".*-5.9822653797615723e-120.*" | |
191 | } else { | |
192 | gdb_test "x/f &oct" ".*-2.42716126e-15.*" | |
193 | } | |
96baa820 JM |
194 | |
195 | # FIXME Fill in the results for all the following tests. (But be careful | |
196 | # about looking at locations with unspecified contents!) | |
197 | ||
198 | gdb_test "x/2x &oct" ".*0xa72ee53977053977.*" | |
199 | gdb_test "x/2d &oct" ".*-6399925985474168457.*" | |
200 | gdb_test "x/2u &oct" ".*.*" | |
201 | gdb_test "x/2o &oct" ".*.*" | |
202 | gdb_test "x/2t &oct" ".*.*" | |
203 | gdb_test "x/2a &oct" ".*.*" | |
204 | gdb_test "x/2c &oct" ".*.*" | |
205 | gdb_test "x/2f &oct" ".*.*" | |
206 | ||
207 | gdb_test "x/2bx &oct" ".*.*" | |
208 | gdb_test "x/2bd &oct" ".*.*" | |
209 | gdb_test "x/2bu &oct" ".*.*" | |
210 | gdb_test "x/2bo &oct" ".*.*" | |
211 | gdb_test "x/2bt &oct" ".*.*" | |
212 | gdb_test "x/2ba &oct" ".*.*" | |
213 | gdb_test "x/2bc &oct" ".*.*" | |
214 | gdb_test "x/2bf &oct" ".*.*" | |
215 | ||
216 | gdb_test "x/2hx &oct" ".*.*" | |
217 | gdb_test "x/2hd &oct" ".*.*" | |
218 | gdb_test "x/2hu &oct" ".*.*" | |
219 | gdb_test "x/2ho &oct" ".*.*" | |
220 | gdb_test "x/2ht &oct" ".*.*" | |
221 | gdb_test "x/2ha &oct" ".*.*" | |
222 | gdb_test "x/2hc &oct" ".*.*" | |
223 | gdb_test "x/2hf &oct" ".*.*" | |
224 | ||
225 | gdb_test "x/2wx &oct" ".*.*" | |
226 | gdb_test "x/2wd &oct" ".*.*" | |
227 | gdb_test "x/2wu &oct" ".*.*" | |
228 | gdb_test "x/2wo &oct" ".*.*" | |
229 | gdb_test "x/2wt &oct" ".*.*" | |
230 | gdb_test "x/2wa &oct" ".*.*" | |
231 | gdb_test "x/2wc &oct" ".*.*" | |
232 | gdb_test "x/2wf &oct" ".*.*" | |
233 | ||
234 | gdb_test "x/2gx &oct" ".*.*" | |
235 | gdb_test "x/2gd &oct" ".*.*" | |
236 | gdb_test "x/2gu &oct" ".*.*" | |
237 | gdb_test "x/2go &oct" ".*.*" | |
238 | gdb_test "x/2gt &oct" ".*.*" | |
239 | gdb_test "x/2ga &oct" ".*.*" | |
240 | gdb_test "x/2gc &oct" ".*.*" | |
241 | gdb_test "x/2gf &oct" ".*.*" | |
242 | ||
243 | } else { | |
244 | ||
245 | # FIXME Add little-endian versions of these tests, or define a | |
246 | # gdb_test_bi with two strings to match on. | |
247 | ||
248 | } | |
c906108c SS |
249 | |
250 | gdb_exit | |
251 | return 0 |