Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 1998, 1999, 2000, 2007 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 | # 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 | ||
aaa68313 CV |
33 | # By default, the datastructures are allocated on the stack. For targets |
34 | # with very small stack, that will not work. In that case, just set | |
35 | # storage to `-DSTORAGE=static' which changes the datastructures to be | |
36 | # allocated in data segment. | |
37 | set storage "-DSTORAGE=" | |
38 | if [target_info exists gdb,small_stack_section] { | |
39 | set storage "-DSTORAGE=static" | |
40 | } | |
41 | ||
fc91c6c2 | 42 | set additional_flags "additional_flags=${storage}" |
aaa68313 | 43 | |
c906108c SS |
44 | # |
45 | # test running programs | |
46 | # | |
47 | set prms_id 0 | |
48 | set bug_id 0 | |
49 | ||
50 | set testfile "miscexprs" | |
51 | set srcfile ${testfile}.c | |
52 | set binfile ${objdir}/${subdir}/${testfile} | |
53 | ||
fc91c6c2 | 54 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } { |
b60f0898 JB |
55 | untested miscexprs.exp |
56 | return -1 | |
c906108c SS |
57 | } |
58 | ||
085dd6e6 JM |
59 | if [get_compiler_info ${binfile}] { |
60 | return -1; | |
61 | } | |
c906108c SS |
62 | |
63 | gdb_exit | |
64 | gdb_start | |
65 | gdb_reinitialize_dir $srcdir/$subdir | |
66 | gdb_load ${binfile} | |
67 | ||
68 | ||
69 | # | |
70 | # set it up at a breakpoint so we can play with the variable values | |
71 | # | |
72 | if ![runto_main] then { | |
73 | perror "couldn't run to breakpoint" | |
74 | continue | |
75 | } | |
76 | ||
77 | send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" | |
78 | ||
79 | send_gdb "cont\n" | |
80 | gdb_expect { | |
81 | -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" { | |
82 | send_gdb "up\n" | |
83 | gdb_expect { | |
3c077de9 MS |
84 | -re ".*main.*$gdb_prompt $" { |
85 | pass "up from marker1" | |
86 | } | |
660fd469 MS |
87 | -re ".*$gdb_prompt $" { |
88 | fail "up from marker1" | |
89 | } | |
90 | timeout { fail "up from marker1 (timeout)" } | |
c906108c SS |
91 | } |
92 | } | |
93 | -re "$gdb_prompt $" { fail "continue to marker1" } | |
94 | timeout { fail "(timeout) continue to marker1" } | |
95 | } | |
96 | ||
97 | global hex | |
98 | ||
99 | send_gdb "print &ibig.i\[0\]\n" | |
100 | gdb_expect { | |
101 | -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" { | |
102 | pass "print value of &ibig.i\[0\]" | |
103 | } | |
104 | -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" } | |
105 | timeout { fail "(timeout) print value of &ibig.i\[0\]" } | |
106 | } | |
107 | ||
108 | send_gdb "print &cbig.c\[0\]\n" | |
109 | gdb_expect { | |
110 | -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" { | |
111 | pass "print value of &cbig.c\[0\]" | |
112 | } | |
085dd6e6 JM |
113 | -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" { |
114 | pass "print value of &cbig.c\[0\]" | |
115 | } | |
c906108c SS |
116 | -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" } |
117 | timeout { fail "(timeout) print value of &cbig.c\[0\]" } | |
118 | } | |
119 | ||
120 | send_gdb "print &fbig.f\[0\]\n" | |
121 | gdb_expect { | |
122 | -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" { | |
123 | pass "print value of &fbig.f\[0\]" | |
124 | } | |
125 | -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" } | |
126 | timeout { fail "(timeout) print value of &fbig.f\[0\]" } | |
127 | } | |
128 | ||
129 | send_gdb "print &dbig.d\[0\]\n" | |
130 | gdb_expect { | |
131 | -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" { | |
132 | pass "print value of &dbig.d\[0\]" | |
133 | } | |
134 | -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" } | |
135 | timeout { fail "(timeout) print value of &dbig.d\[0\]" } | |
136 | } | |
137 | ||
138 | send_gdb "print &sbig.s\[0\]\n" | |
139 | gdb_expect { | |
7a292a7a SS |
140 | -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" { |
141 | pass "print value of &sbig.s\[0\]" | |
142 | } | |
c906108c SS |
143 | -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" { |
144 | pass "print value of &sbig.s\[0\]" | |
7a292a7a | 145 | } |
c906108c SS |
146 | -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" } |
147 | timeout { fail "(timeout) print value of &sbig.s\[0\]" } | |
148 | } | |
149 | ||
150 | send_gdb "print &lbig.l\[0\]\n" | |
151 | gdb_expect { | |
7a292a7a SS |
152 | -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" { |
153 | pass "print value of &lbig.l\[0\]" | |
154 | } | |
c906108c SS |
155 | -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" { |
156 | pass "print value of &lbig.l\[0\]" | |
7a292a7a | 157 | } |
c906108c SS |
158 | -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" } |
159 | timeout { fail "(timeout) print value of &lbig.l\[0\]" } | |
160 | } | |
161 | ||
162 | ||
163 | send_gdb "print ibig.i\[100\] | 1\n" | |
164 | gdb_expect { | |
165 | -re ".\[0-9\]* = 5.*$gdb_prompt $" { | |
166 | pass "print value of ibig.i\[100\] | 1" | |
167 | } | |
168 | -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" } | |
169 | timeout { fail "(timeout) print value of ibig.i\[100\] | 1" } | |
170 | } | |
171 | ||
172 | ||
173 | send_gdb "print sbig.s\[90\] & 127\n" | |
174 | gdb_expect { | |
175 | -re ".\[0-9\]* = 127.*$gdb_prompt $" { | |
176 | pass "print value of sbig.s\[90\] & 127" | |
177 | } | |
178 | -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" } | |
179 | timeout { fail "(timeout) print value of sbig.s\[90\] & 127" } | |
180 | } | |
181 | ||
182 | send_gdb "print !ibig.i\[100\]\n" | |
183 | gdb_expect { | |
085dd6e6 | 184 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
185 | pass "print value of !ibig.i\[100\]" |
186 | } | |
187 | -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" } | |
188 | timeout { fail "(timeout) print value of !ibig.i\[100\]" } | |
189 | } | |
190 | ||
191 | send_gdb "print !sbig.s\[90\]\n" | |
192 | gdb_expect { | |
085dd6e6 | 193 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
194 | pass "print value of !sbig.s\[90\]" |
195 | } | |
196 | -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" } | |
197 | timeout { fail "(timeout) print value of !sbig.s\[90\]" } | |
198 | } | |
199 | ||
200 | ||
201 | send_gdb "print !fbig.f\[100\]\n" | |
202 | gdb_expect { | |
085dd6e6 | 203 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
204 | pass "print value of !ibig.i\[100\]" |
205 | } | |
206 | -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" } | |
207 | timeout { fail "(timeout) print value of !ibig.i\[100\]" } | |
208 | } | |
209 | ||
210 | send_gdb "print !dbig.d\[202\]\n" | |
211 | gdb_expect { | |
085dd6e6 | 212 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
213 | pass "print value of !ibig.i\[100\]" |
214 | } | |
215 | -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" } | |
216 | timeout { fail "(timeout) print value of !ibig.i\[100\]" } | |
217 | } | |
218 | ||
219 | ||
220 | ||
221 | send_gdb "print sbig.s\[90\] * 10\n" | |
222 | gdb_expect { | |
223 | -re ".\[0-9\]* = 2550.*$gdb_prompt $" { | |
224 | pass "print value of !sbig.s\[90\] * 10" | |
225 | } | |
226 | -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" } | |
227 | timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" } | |
228 | } | |
229 | ||
230 | send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n" | |
231 | gdb_expect { | |
232 | -re ".\[0-9\]* = 1275.*$gdb_prompt $" { | |
233 | pass "print value of ibig.i\[100\] * sbig.s\[90\]" | |
234 | } | |
235 | -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" } | |
236 | timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" } | |
237 | } | |
238 | ||
239 | send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n" | |
240 | gdb_expect { | |
241 | -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" { | |
242 | pass "print value of fbig.f\[100\] * dbig.d\[202\]" | |
243 | } | |
244 | -re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" } | |
245 | timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" } | |
246 | } | |
247 | ||
248 | send_gdb "print !(sbig.s\[90\] * 2)\n" | |
249 | gdb_expect { | |
085dd6e6 | 250 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
251 | pass "print value of !(sbig.s\[90\] * 2)" |
252 | } | |
253 | -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" } | |
254 | timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" } | |
255 | } | |
256 | ||
257 | ||
258 | send_gdb "print sizeof(sbig)\n" | |
259 | gdb_expect { | |
260 | -re ".\[0-9\]* = 800.*$gdb_prompt $" { | |
261 | pass "print value of sizeof(sbig)" | |
262 | } | |
263 | -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" } | |
264 | timeout { fail "(timeout) print value of sizeof(sbig)" } | |
265 | } | |
266 | ||
267 | ||
268 | send_gdb "print sizeof(cbig)\n" | |
269 | gdb_expect { | |
270 | -re ".\[0-9\]* = 100.*$gdb_prompt $" { | |
271 | pass "print value of sizeof(cbig)" | |
272 | } | |
273 | -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" } | |
274 | timeout { fail "(timeout) print value of sizeof(cbig)" } | |
275 | } | |
276 | ||
277 | ||
b84b7669 | 278 | send_gdb "print sizeof(lbig)/sizeof(long)\n" |
085dd6e6 | 279 | gdb_expect { |
b84b7669 MS |
280 | -re ".\[0-9\]* = 900.*$gdb_prompt $" { |
281 | pass "print value of sizeof(lbig)/sizeof(long)" | |
085dd6e6 | 282 | } |
b84b7669 MS |
283 | -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" } |
284 | timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" } | |
085dd6e6 | 285 | } |
c906108c SS |
286 | |
287 | send_gdb "print ibig.i\[100\] << 2\n" | |
288 | gdb_expect { | |
289 | -re ".\[0-9\]* = 20.*$gdb_prompt $" { | |
290 | pass "print value of ibig.i\[100\] << 2" | |
291 | } | |
292 | -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" } | |
293 | timeout { fail "(timeout) print value of ibig.i\[100\] << 2" } | |
294 | } | |
295 | ||
296 | send_gdb "print sbig.s\[90\] >> 4\n" | |
297 | gdb_expect { | |
298 | -re ".\[0-9\]* = 15.*$gdb_prompt $" { | |
299 | pass "print value of sbig.s\[90\] >> 4" | |
300 | } | |
301 | -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" } | |
302 | timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" } | |
303 | } | |
304 | ||
305 | send_gdb "print lbig.l\[333\] >> 6\n" | |
306 | gdb_expect { | |
307 | -re ".\[0-9\]* = 15624999.*$gdb_prompt $" { | |
308 | pass "print value of lbig.l\[333\] >> 6" | |
309 | } | |
310 | -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" } | |
311 | timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" } | |
312 | } |