2009-07-01 Tristan Gingold <gingold@adacore.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / miscexprs.exp
1 # Copyright 1998, 1999, 2000, 2007, 2008, 2009 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 3 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, see <http://www.gnu.org/licenses/>.
15
16
17 # This file is part of the gdb testsuite
18 # file written by Elena Zannoni (ezannoni@cygnus.com)
19
20 #
21 # tests for expressions with struct/array elements and mixed operator types
22 # with elementary types
23 #
24
25 if $tracelevel then {
26 strace $tracelevel
27 }
28
29 # By default, the datastructures are allocated on the stack. For targets
30 # with very small stack, that will not work. In that case, just set
31 # storage to `-DSTORAGE=static' which changes the datastructures to be
32 # allocated in data segment.
33 set storage "-DSTORAGE="
34 if [target_info exists gdb,small_stack_section] {
35 set storage "-DSTORAGE=static"
36 }
37
38 set additional_flags "additional_flags=${storage}"
39
40 #
41 # test running programs
42 #
43 set prms_id 0
44 set bug_id 0
45
46 set testfile "miscexprs"
47 set srcfile ${testfile}.c
48 set binfile ${objdir}/${subdir}/${testfile}
49
50 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } {
51 untested miscexprs.exp
52 return -1
53 }
54
55 if [get_compiler_info ${binfile}] {
56 return -1;
57 }
58
59 gdb_exit
60 gdb_start
61 gdb_reinitialize_dir $srcdir/$subdir
62 gdb_load ${binfile}
63
64
65 #
66 # set it up at a breakpoint so we can play with the variable values
67 #
68 if ![runto_main] then {
69 perror "couldn't run to breakpoint"
70 continue
71 }
72
73 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
74
75 send_gdb "cont\n"
76 gdb_expect {
77 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
78 send_gdb "up\n"
79 gdb_expect {
80 -re ".*main.*$gdb_prompt $" {
81 pass "up from marker1"
82 }
83 -re ".*$gdb_prompt $" {
84 fail "up from marker1"
85 }
86 timeout { fail "up from marker1 (timeout)" }
87 }
88 }
89 -re "$gdb_prompt $" { fail "continue to marker1" }
90 timeout { fail "(timeout) continue to marker1" }
91 }
92
93 global hex
94
95 send_gdb "print &ibig.i\[0\]\n"
96 gdb_expect {
97 -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" {
98 pass "print value of &ibig.i\[0\]"
99 }
100 -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" }
101 timeout { fail "(timeout) print value of &ibig.i\[0\]" }
102 }
103
104 send_gdb "print &cbig.c\[0\]\n"
105 gdb_expect {
106 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
107 pass "print value of &cbig.c\[0\]"
108 }
109 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
110 pass "print value of &cbig.c\[0\]"
111 }
112 -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
113 timeout { fail "(timeout) print value of &cbig.c\[0\]" }
114 }
115
116 send_gdb "print &fbig.f\[0\]\n"
117 gdb_expect {
118 -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" {
119 pass "print value of &fbig.f\[0\]"
120 }
121 -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" }
122 timeout { fail "(timeout) print value of &fbig.f\[0\]" }
123 }
124
125 send_gdb "print &dbig.d\[0\]\n"
126 gdb_expect {
127 -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" {
128 pass "print value of &dbig.d\[0\]"
129 }
130 -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" }
131 timeout { fail "(timeout) print value of &dbig.d\[0\]" }
132 }
133
134 send_gdb "print &sbig.s\[0\]\n"
135 gdb_expect {
136 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
137 pass "print value of &sbig.s\[0\]"
138 }
139 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
140 pass "print value of &sbig.s\[0\]"
141 }
142 -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
143 timeout { fail "(timeout) print value of &sbig.s\[0\]" }
144 }
145
146 send_gdb "print &lbig.l\[0\]\n"
147 gdb_expect {
148 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
149 pass "print value of &lbig.l\[0\]"
150 }
151 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
152 pass "print value of &lbig.l\[0\]"
153 }
154 -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
155 timeout { fail "(timeout) print value of &lbig.l\[0\]" }
156 }
157
158
159 send_gdb "print ibig.i\[100\] | 1\n"
160 gdb_expect {
161 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
162 pass "print value of ibig.i\[100\] | 1"
163 }
164 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" }
165 timeout { fail "(timeout) print value of ibig.i\[100\] | 1" }
166 }
167
168
169 send_gdb "print sbig.s\[90\] & 127\n"
170 gdb_expect {
171 -re ".\[0-9\]* = 127.*$gdb_prompt $" {
172 pass "print value of sbig.s\[90\] & 127"
173 }
174 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" }
175 timeout { fail "(timeout) print value of sbig.s\[90\] & 127" }
176 }
177
178 send_gdb "print !ibig.i\[100\]\n"
179 gdb_expect {
180 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
181 pass "print value of !ibig.i\[100\]"
182 }
183 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
184 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
185 }
186
187 send_gdb "print !sbig.s\[90\]\n"
188 gdb_expect {
189 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
190 pass "print value of !sbig.s\[90\]"
191 }
192 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" }
193 timeout { fail "(timeout) print value of !sbig.s\[90\]" }
194 }
195
196
197 send_gdb "print !fbig.f\[100\]\n"
198 gdb_expect {
199 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
200 pass "print value of !ibig.i\[100\]"
201 }
202 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
203 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
204 }
205
206 send_gdb "print !dbig.d\[202\]\n"
207 gdb_expect {
208 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
209 pass "print value of !ibig.i\[100\]"
210 }
211 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
212 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
213 }
214
215
216
217 send_gdb "print sbig.s\[90\] * 10\n"
218 gdb_expect {
219 -re ".\[0-9\]* = 2550.*$gdb_prompt $" {
220 pass "print value of !sbig.s\[90\] * 10"
221 }
222 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" }
223 timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" }
224 }
225
226 send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
227 gdb_expect {
228 -re ".\[0-9\]* = 1275.*$gdb_prompt $" {
229 pass "print value of ibig.i\[100\] * sbig.s\[90\]"
230 }
231 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" }
232 timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" }
233 }
234
235 send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
236 gdb_expect {
237 -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" {
238 pass "print value of fbig.f\[100\] * dbig.d\[202\]"
239 }
240 -re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" }
241 timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" }
242 }
243
244 send_gdb "print !(sbig.s\[90\] * 2)\n"
245 gdb_expect {
246 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
247 pass "print value of !(sbig.s\[90\] * 2)"
248 }
249 -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" }
250 timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" }
251 }
252
253
254 send_gdb "print sizeof(sbig)\n"
255 gdb_expect {
256 -re ".\[0-9\]* = 800.*$gdb_prompt $" {
257 pass "print value of sizeof(sbig)"
258 }
259 -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" }
260 timeout { fail "(timeout) print value of sizeof(sbig)" }
261 }
262
263
264 send_gdb "print sizeof(cbig)\n"
265 gdb_expect {
266 -re ".\[0-9\]* = 100.*$gdb_prompt $" {
267 pass "print value of sizeof(cbig)"
268 }
269 -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" }
270 timeout { fail "(timeout) print value of sizeof(cbig)" }
271 }
272
273
274 send_gdb "print sizeof(lbig)/sizeof(long)\n"
275 gdb_expect {
276 -re ".\[0-9\]* = 900.*$gdb_prompt $" {
277 pass "print value of sizeof(lbig)/sizeof(long)"
278 }
279 -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" }
280 timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" }
281 }
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 }
This page took 0.036989 seconds and 4 git commands to generate.