Commit | Line | Data |
---|---|---|
c906108c SS |
1 | # Copyright (C) 1998 Free Software Foundation, Inc. |
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 | # This file is part of the gdb testsuite | |
22 | # file written by Elena Zannoni (ezannoni@cygnus.com) | |
23 | ||
24 | # | |
25 | # tests for expressions with struct/array elements and mixed operator types | |
26 | # with elementary types | |
27 | # | |
28 | ||
29 | if $tracelevel then { | |
30 | strace $tracelevel | |
31 | } | |
32 | ||
33 | # | |
34 | # test running programs | |
35 | # | |
36 | set prms_id 0 | |
37 | set bug_id 0 | |
38 | ||
39 | set testfile "miscexprs" | |
40 | set srcfile ${testfile}.c | |
41 | set binfile ${objdir}/${subdir}/${testfile} | |
42 | ||
43 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { | |
44 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
45 | } | |
46 | ||
085dd6e6 JM |
47 | if [get_compiler_info ${binfile}] { |
48 | return -1; | |
49 | } | |
c906108c SS |
50 | |
51 | gdb_exit | |
52 | gdb_start | |
53 | gdb_reinitialize_dir $srcdir/$subdir | |
54 | gdb_load ${binfile} | |
55 | ||
56 | ||
57 | # | |
58 | # set it up at a breakpoint so we can play with the variable values | |
59 | # | |
60 | if ![runto_main] then { | |
61 | perror "couldn't run to breakpoint" | |
62 | continue | |
63 | } | |
64 | ||
65 | send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" | |
66 | ||
67 | send_gdb "cont\n" | |
68 | gdb_expect { | |
69 | -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" { | |
70 | send_gdb "up\n" | |
71 | gdb_expect { | |
72 | -re ".*$gdb_prompt $" {} | |
73 | timeout { fail "up from marker1" } | |
74 | } | |
75 | } | |
76 | -re "$gdb_prompt $" { fail "continue to marker1" } | |
77 | timeout { fail "(timeout) continue to marker1" } | |
78 | } | |
79 | ||
80 | global hex | |
81 | ||
82 | send_gdb "print &ibig.i\[0\]\n" | |
83 | gdb_expect { | |
84 | -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" { | |
85 | pass "print value of &ibig.i\[0\]" | |
86 | } | |
87 | -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" } | |
88 | timeout { fail "(timeout) print value of &ibig.i\[0\]" } | |
89 | } | |
90 | ||
91 | send_gdb "print &cbig.c\[0\]\n" | |
92 | gdb_expect { | |
93 | -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" { | |
94 | pass "print value of &cbig.c\[0\]" | |
95 | } | |
085dd6e6 JM |
96 | -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" { |
97 | pass "print value of &cbig.c\[0\]" | |
98 | } | |
c906108c SS |
99 | -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" } |
100 | timeout { fail "(timeout) print value of &cbig.c\[0\]" } | |
101 | } | |
102 | ||
103 | send_gdb "print &fbig.f\[0\]\n" | |
104 | gdb_expect { | |
105 | -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" { | |
106 | pass "print value of &fbig.f\[0\]" | |
107 | } | |
108 | -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" } | |
109 | timeout { fail "(timeout) print value of &fbig.f\[0\]" } | |
110 | } | |
111 | ||
112 | send_gdb "print &dbig.d\[0\]\n" | |
113 | gdb_expect { | |
114 | -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" { | |
115 | pass "print value of &dbig.d\[0\]" | |
116 | } | |
117 | -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" } | |
118 | timeout { fail "(timeout) print value of &dbig.d\[0\]" } | |
119 | } | |
120 | ||
121 | send_gdb "print &sbig.s\[0\]\n" | |
122 | gdb_expect { | |
7a292a7a SS |
123 | -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" { |
124 | pass "print value of &sbig.s\[0\]" | |
125 | } | |
c906108c SS |
126 | -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" { |
127 | pass "print value of &sbig.s\[0\]" | |
7a292a7a | 128 | } |
c906108c SS |
129 | -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" } |
130 | timeout { fail "(timeout) print value of &sbig.s\[0\]" } | |
131 | } | |
132 | ||
133 | send_gdb "print &lbig.l\[0\]\n" | |
134 | gdb_expect { | |
7a292a7a SS |
135 | -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" { |
136 | pass "print value of &lbig.l\[0\]" | |
137 | } | |
c906108c SS |
138 | -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" { |
139 | pass "print value of &lbig.l\[0\]" | |
7a292a7a | 140 | } |
c906108c SS |
141 | -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" } |
142 | timeout { fail "(timeout) print value of &lbig.l\[0\]" } | |
143 | } | |
144 | ||
145 | ||
146 | send_gdb "print ibig.i\[100\] | 1\n" | |
147 | gdb_expect { | |
148 | -re ".\[0-9\]* = 5.*$gdb_prompt $" { | |
149 | pass "print value of ibig.i\[100\] | 1" | |
150 | } | |
151 | -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" } | |
152 | timeout { fail "(timeout) print value of ibig.i\[100\] | 1" } | |
153 | } | |
154 | ||
155 | ||
156 | send_gdb "print sbig.s\[90\] & 127\n" | |
157 | gdb_expect { | |
158 | -re ".\[0-9\]* = 127.*$gdb_prompt $" { | |
159 | pass "print value of sbig.s\[90\] & 127" | |
160 | } | |
161 | -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" } | |
162 | timeout { fail "(timeout) print value of sbig.s\[90\] & 127" } | |
163 | } | |
164 | ||
165 | send_gdb "print !ibig.i\[100\]\n" | |
166 | gdb_expect { | |
085dd6e6 | 167 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
168 | pass "print value of !ibig.i\[100\]" |
169 | } | |
170 | -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" } | |
171 | timeout { fail "(timeout) print value of !ibig.i\[100\]" } | |
172 | } | |
173 | ||
174 | send_gdb "print !sbig.s\[90\]\n" | |
175 | gdb_expect { | |
085dd6e6 | 176 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
177 | pass "print value of !sbig.s\[90\]" |
178 | } | |
179 | -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" } | |
180 | timeout { fail "(timeout) print value of !sbig.s\[90\]" } | |
181 | } | |
182 | ||
183 | ||
184 | send_gdb "print !fbig.f\[100\]\n" | |
185 | gdb_expect { | |
085dd6e6 | 186 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
187 | pass "print value of !ibig.i\[100\]" |
188 | } | |
189 | -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" } | |
190 | timeout { fail "(timeout) print value of !ibig.i\[100\]" } | |
191 | } | |
192 | ||
193 | send_gdb "print !dbig.d\[202\]\n" | |
194 | gdb_expect { | |
085dd6e6 | 195 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
196 | pass "print value of !ibig.i\[100\]" |
197 | } | |
198 | -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" } | |
199 | timeout { fail "(timeout) print value of !ibig.i\[100\]" } | |
200 | } | |
201 | ||
202 | ||
203 | ||
204 | send_gdb "print sbig.s\[90\] * 10\n" | |
205 | gdb_expect { | |
206 | -re ".\[0-9\]* = 2550.*$gdb_prompt $" { | |
207 | pass "print value of !sbig.s\[90\] * 10" | |
208 | } | |
209 | -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" } | |
210 | timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" } | |
211 | } | |
212 | ||
213 | send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n" | |
214 | gdb_expect { | |
215 | -re ".\[0-9\]* = 1275.*$gdb_prompt $" { | |
216 | pass "print value of ibig.i\[100\] * sbig.s\[90\]" | |
217 | } | |
218 | -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" } | |
219 | timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" } | |
220 | } | |
221 | ||
222 | send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n" | |
223 | gdb_expect { | |
224 | -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" { | |
225 | pass "print value of fbig.f\[100\] * dbig.d\[202\]" | |
226 | } | |
227 | -re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" } | |
228 | timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" } | |
229 | } | |
230 | ||
231 | send_gdb "print !(sbig.s\[90\] * 2)\n" | |
232 | gdb_expect { | |
085dd6e6 | 233 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
234 | pass "print value of !(sbig.s\[90\] * 2)" |
235 | } | |
236 | -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" } | |
237 | timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" } | |
238 | } | |
239 | ||
240 | ||
241 | send_gdb "print sizeof(sbig)\n" | |
242 | gdb_expect { | |
243 | -re ".\[0-9\]* = 800.*$gdb_prompt $" { | |
244 | pass "print value of sizeof(sbig)" | |
245 | } | |
246 | -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" } | |
247 | timeout { fail "(timeout) print value of sizeof(sbig)" } | |
248 | } | |
249 | ||
250 | ||
251 | send_gdb "print sizeof(cbig)\n" | |
252 | gdb_expect { | |
253 | -re ".\[0-9\]* = 100.*$gdb_prompt $" { | |
254 | pass "print value of sizeof(cbig)" | |
255 | } | |
256 | -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" } | |
257 | timeout { fail "(timeout) print value of sizeof(cbig)" } | |
258 | } | |
259 | ||
260 | ||
085dd6e6 JM |
261 | if [istarget "hppa2.0w*-*-*"] then { |
262 | send_gdb "print sizeof(lbig)\n" | |
263 | gdb_expect { | |
264 | -re ".\[0-9\]* = 7200.*$gdb_prompt $" { | |
265 | pass "print value of sizeof(lbig)" | |
266 | } | |
267 | -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)" } | |
268 | timeout { fail "(timeout) print value of sizeof(lbig)" } | |
269 | } | |
270 | } | |
271 | ||
272 | if ![istarget "hppa2.0w*-*-*"] then { | |
c906108c SS |
273 | send_gdb "print sizeof(lbig)\n" |
274 | gdb_expect { | |
275 | -re ".\[0-9\]* = 3600.*$gdb_prompt $" { | |
276 | pass "print value of sizeof(lbig)" | |
277 | } | |
278 | -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)" } | |
279 | timeout { fail "(timeout) print value of sizeof(lbig)" } | |
280 | } | |
085dd6e6 | 281 | } |
c906108c SS |
282 | |
283 | send_gdb "print ibig.i\[100\] << 2\n" | |
284 | gdb_expect { | |
285 | -re ".\[0-9\]* = 20.*$gdb_prompt $" { | |
286 | pass "print value of ibig.i\[100\] << 2" | |
287 | } | |
288 | -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" } | |
289 | timeout { fail "(timeout) print value of ibig.i\[100\] << 2" } | |
290 | } | |
291 | ||
292 | send_gdb "print sbig.s\[90\] >> 4\n" | |
293 | gdb_expect { | |
294 | -re ".\[0-9\]* = 15.*$gdb_prompt $" { | |
295 | pass "print value of sbig.s\[90\] >> 4" | |
296 | } | |
297 | -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" } | |
298 | timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" } | |
299 | } | |
300 | ||
301 | send_gdb "print lbig.l\[333\] >> 6\n" | |
302 | gdb_expect { | |
303 | -re ".\[0-9\]* = 15624999.*$gdb_prompt $" { | |
304 | pass "print value of lbig.l\[333\] >> 6" | |
305 | } | |
306 | -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" } | |
307 | timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" } | |
308 | } |