ChangeLog:
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / miscexprs.exp
CommitLineData
0fb0cc75 1# Copyright 1998, 1999, 2000, 2007, 2008, 2009 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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 15
c906108c
SS
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
25if $tracelevel then {
26 strace $tracelevel
27 }
28
aaa68313
CV
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.
33set storage "-DSTORAGE="
34if [target_info exists gdb,small_stack_section] {
35 set storage "-DSTORAGE=static"
36}
37
fc91c6c2 38set additional_flags "additional_flags=${storage}"
aaa68313 39
c906108c
SS
40#
41# test running programs
42#
43set prms_id 0
44set bug_id 0
45
46set testfile "miscexprs"
47set srcfile ${testfile}.c
48set binfile ${objdir}/${subdir}/${testfile}
49
fc91c6c2 50if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } {
b60f0898
JB
51 untested miscexprs.exp
52 return -1
c906108c
SS
53}
54
085dd6e6
JM
55if [get_compiler_info ${binfile}] {
56 return -1;
57}
c906108c
SS
58
59gdb_exit
60gdb_start
61gdb_reinitialize_dir $srcdir/$subdir
62gdb_load ${binfile}
63
64
65#
66# set it up at a breakpoint so we can play with the variable values
67#
68if ![runto_main] then {
69 perror "couldn't run to breakpoint"
70 continue
71}
72
73send_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 {
3c077de9
MS
80 -re ".*main.*$gdb_prompt $" {
81 pass "up from marker1"
82 }
660fd469
MS
83 -re ".*$gdb_prompt $" {
84 fail "up from marker1"
85 }
86 timeout { fail "up from marker1 (timeout)" }
c906108c
SS
87 }
88 }
89 -re "$gdb_prompt $" { fail "continue to marker1" }
90 timeout { fail "(timeout) continue to marker1" }
91 }
92
93global hex
94
95send_gdb "print &ibig.i\[0\]\n"
96gdb_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
104send_gdb "print &cbig.c\[0\]\n"
105gdb_expect {
106 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
107 pass "print value of &cbig.c\[0\]"
108 }
085dd6e6
JM
109 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
110 pass "print value of &cbig.c\[0\]"
111 }
c906108c
SS
112 -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
113 timeout { fail "(timeout) print value of &cbig.c\[0\]" }
114 }
115
116send_gdb "print &fbig.f\[0\]\n"
117gdb_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
125send_gdb "print &dbig.d\[0\]\n"
126gdb_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
134send_gdb "print &sbig.s\[0\]\n"
135gdb_expect {
7a292a7a
SS
136 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
137 pass "print value of &sbig.s\[0\]"
138 }
c906108c
SS
139 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
140 pass "print value of &sbig.s\[0\]"
7a292a7a 141 }
c906108c
SS
142 -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
143 timeout { fail "(timeout) print value of &sbig.s\[0\]" }
144 }
145
146send_gdb "print &lbig.l\[0\]\n"
147gdb_expect {
7a292a7a
SS
148 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
149 pass "print value of &lbig.l\[0\]"
150 }
c906108c
SS
151 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
152 pass "print value of &lbig.l\[0\]"
7a292a7a 153 }
c906108c
SS
154 -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
155 timeout { fail "(timeout) print value of &lbig.l\[0\]" }
156 }
157
158
159send_gdb "print ibig.i\[100\] | 1\n"
160gdb_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
169send_gdb "print sbig.s\[90\] & 127\n"
170gdb_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
178send_gdb "print !ibig.i\[100\]\n"
179gdb_expect {
085dd6e6 180 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
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
187send_gdb "print !sbig.s\[90\]\n"
188gdb_expect {
085dd6e6 189 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
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
197send_gdb "print !fbig.f\[100\]\n"
198gdb_expect {
085dd6e6 199 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
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
206send_gdb "print !dbig.d\[202\]\n"
207gdb_expect {
085dd6e6 208 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
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
217send_gdb "print sbig.s\[90\] * 10\n"
218gdb_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
226send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
227gdb_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
235send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
236gdb_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
244send_gdb "print !(sbig.s\[90\] * 2)\n"
245gdb_expect {
085dd6e6 246 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
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
254send_gdb "print sizeof(sbig)\n"
255gdb_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
264send_gdb "print sizeof(cbig)\n"
265gdb_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
b84b7669 274send_gdb "print sizeof(lbig)/sizeof(long)\n"
085dd6e6 275gdb_expect {
b84b7669
MS
276 -re ".\[0-9\]* = 900.*$gdb_prompt $" {
277 pass "print value of sizeof(lbig)/sizeof(long)"
085dd6e6 278 }
b84b7669
MS
279 -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" }
280 timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" }
085dd6e6 281 }
c906108c
SS
282
283send_gdb "print ibig.i\[100\] << 2\n"
284gdb_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
292send_gdb "print sbig.s\[90\] >> 4\n"
293gdb_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
301send_gdb "print lbig.l\[333\] >> 6\n"
302gdb_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.865231 seconds and 4 git commands to generate.