Do not set prms_id/bug_id anymore.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / miscexprs.exp
CommitLineData
4c38e0a4
JB
1# Copyright 1998, 1999, 2000, 2007, 2008, 2009, 2010
2# Free Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c
SS
17
18# This file is part of the gdb testsuite
19# file written by Elena Zannoni (ezannoni@cygnus.com)
20
21#
22# tests for expressions with struct/array elements and mixed operator types
23# with elementary types
24#
25
26if $tracelevel then {
27 strace $tracelevel
28 }
29
aaa68313
CV
30# By default, the datastructures are allocated on the stack. For targets
31# with very small stack, that will not work. In that case, just set
32# storage to `-DSTORAGE=static' which changes the datastructures to be
33# allocated in data segment.
34set storage "-DSTORAGE="
35if [target_info exists gdb,small_stack_section] {
36 set storage "-DSTORAGE=static"
37}
38
fc91c6c2 39set additional_flags "additional_flags=${storage}"
aaa68313 40
c906108c
SS
41#
42# test running programs
43#
c906108c
SS
44
45set testfile "miscexprs"
46set srcfile ${testfile}.c
47set binfile ${objdir}/${subdir}/${testfile}
48
fc91c6c2 49if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } {
b60f0898
JB
50 untested miscexprs.exp
51 return -1
c906108c
SS
52}
53
085dd6e6
JM
54if [get_compiler_info ${binfile}] {
55 return -1;
56}
c906108c
SS
57
58gdb_exit
59gdb_start
60gdb_reinitialize_dir $srcdir/$subdir
61gdb_load ${binfile}
62
63
64#
65# set it up at a breakpoint so we can play with the variable values
66#
67if ![runto_main] then {
68 perror "couldn't run to breakpoint"
69 continue
70}
71
72send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
73
74 send_gdb "cont\n"
75 gdb_expect {
76 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
77 send_gdb "up\n"
78 gdb_expect {
3c077de9
MS
79 -re ".*main.*$gdb_prompt $" {
80 pass "up from marker1"
81 }
660fd469
MS
82 -re ".*$gdb_prompt $" {
83 fail "up from marker1"
84 }
85 timeout { fail "up from marker1 (timeout)" }
c906108c
SS
86 }
87 }
88 -re "$gdb_prompt $" { fail "continue to marker1" }
89 timeout { fail "(timeout) continue to marker1" }
90 }
91
92global hex
93
94send_gdb "print &ibig.i\[0\]\n"
95gdb_expect {
96 -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" {
97 pass "print value of &ibig.i\[0\]"
98 }
99 -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" }
100 timeout { fail "(timeout) print value of &ibig.i\[0\]" }
101 }
102
103send_gdb "print &cbig.c\[0\]\n"
104gdb_expect {
105 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
106 pass "print value of &cbig.c\[0\]"
107 }
085dd6e6
JM
108 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
109 pass "print value of &cbig.c\[0\]"
110 }
c906108c
SS
111 -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
112 timeout { fail "(timeout) print value of &cbig.c\[0\]" }
113 }
114
115send_gdb "print &fbig.f\[0\]\n"
116gdb_expect {
117 -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" {
118 pass "print value of &fbig.f\[0\]"
119 }
120 -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" }
121 timeout { fail "(timeout) print value of &fbig.f\[0\]" }
122 }
123
124send_gdb "print &dbig.d\[0\]\n"
125gdb_expect {
126 -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" {
127 pass "print value of &dbig.d\[0\]"
128 }
129 -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" }
130 timeout { fail "(timeout) print value of &dbig.d\[0\]" }
131 }
132
133send_gdb "print &sbig.s\[0\]\n"
134gdb_expect {
7a292a7a
SS
135 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
136 pass "print value of &sbig.s\[0\]"
137 }
c906108c
SS
138 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
139 pass "print value of &sbig.s\[0\]"
7a292a7a 140 }
c906108c
SS
141 -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
142 timeout { fail "(timeout) print value of &sbig.s\[0\]" }
143 }
144
145send_gdb "print &lbig.l\[0\]\n"
146gdb_expect {
7a292a7a
SS
147 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
148 pass "print value of &lbig.l\[0\]"
149 }
c906108c
SS
150 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
151 pass "print value of &lbig.l\[0\]"
7a292a7a 152 }
c906108c
SS
153 -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
154 timeout { fail "(timeout) print value of &lbig.l\[0\]" }
155 }
156
157
158send_gdb "print ibig.i\[100\] | 1\n"
159gdb_expect {
160 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
161 pass "print value of ibig.i\[100\] | 1"
162 }
163 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" }
164 timeout { fail "(timeout) print value of ibig.i\[100\] | 1" }
165 }
166
167
168send_gdb "print sbig.s\[90\] & 127\n"
169gdb_expect {
170 -re ".\[0-9\]* = 127.*$gdb_prompt $" {
171 pass "print value of sbig.s\[90\] & 127"
172 }
173 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" }
174 timeout { fail "(timeout) print value of sbig.s\[90\] & 127" }
175 }
176
177send_gdb "print !ibig.i\[100\]\n"
178gdb_expect {
085dd6e6 179 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
180 pass "print value of !ibig.i\[100\]"
181 }
182 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
183 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
184 }
185
186send_gdb "print !sbig.s\[90\]\n"
187gdb_expect {
085dd6e6 188 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
189 pass "print value of !sbig.s\[90\]"
190 }
191 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" }
192 timeout { fail "(timeout) print value of !sbig.s\[90\]" }
193 }
194
195
196send_gdb "print !fbig.f\[100\]\n"
197gdb_expect {
085dd6e6 198 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
199 pass "print value of !ibig.i\[100\]"
200 }
201 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
202 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
203 }
204
205send_gdb "print !dbig.d\[202\]\n"
206gdb_expect {
085dd6e6 207 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
208 pass "print value of !ibig.i\[100\]"
209 }
210 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
211 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
212 }
213
214
215
216send_gdb "print sbig.s\[90\] * 10\n"
217gdb_expect {
218 -re ".\[0-9\]* = 2550.*$gdb_prompt $" {
219 pass "print value of !sbig.s\[90\] * 10"
220 }
221 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" }
222 timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" }
223 }
224
225send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
226gdb_expect {
227 -re ".\[0-9\]* = 1275.*$gdb_prompt $" {
228 pass "print value of ibig.i\[100\] * sbig.s\[90\]"
229 }
230 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" }
231 timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" }
232 }
233
234send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
235gdb_expect {
236 -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" {
237 pass "print value of fbig.f\[100\] * dbig.d\[202\]"
238 }
239 -re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" }
240 timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" }
241 }
242
243send_gdb "print !(sbig.s\[90\] * 2)\n"
244gdb_expect {
085dd6e6 245 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
246 pass "print value of !(sbig.s\[90\] * 2)"
247 }
248 -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" }
249 timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" }
250 }
251
252
253send_gdb "print sizeof(sbig)\n"
254gdb_expect {
255 -re ".\[0-9\]* = 800.*$gdb_prompt $" {
256 pass "print value of sizeof(sbig)"
257 }
258 -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" }
259 timeout { fail "(timeout) print value of sizeof(sbig)" }
260 }
261
262
263send_gdb "print sizeof(cbig)\n"
264gdb_expect {
265 -re ".\[0-9\]* = 100.*$gdb_prompt $" {
266 pass "print value of sizeof(cbig)"
267 }
268 -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" }
269 timeout { fail "(timeout) print value of sizeof(cbig)" }
270 }
271
272
b84b7669 273send_gdb "print sizeof(lbig)/sizeof(long)\n"
085dd6e6 274gdb_expect {
b84b7669
MS
275 -re ".\[0-9\]* = 900.*$gdb_prompt $" {
276 pass "print value of sizeof(lbig)/sizeof(long)"
085dd6e6 277 }
b84b7669
MS
278 -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" }
279 timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" }
085dd6e6 280 }
c906108c
SS
281
282send_gdb "print ibig.i\[100\] << 2\n"
283gdb_expect {
284 -re ".\[0-9\]* = 20.*$gdb_prompt $" {
285 pass "print value of ibig.i\[100\] << 2"
286 }
287 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" }
288 timeout { fail "(timeout) print value of ibig.i\[100\] << 2" }
289 }
290
291send_gdb "print sbig.s\[90\] >> 4\n"
292gdb_expect {
293 -re ".\[0-9\]* = 15.*$gdb_prompt $" {
294 pass "print value of sbig.s\[90\] >> 4"
295 }
296 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" }
297 timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" }
298 }
299
300send_gdb "print lbig.l\[333\] >> 6\n"
301gdb_expect {
302 -re ".\[0-9\]* = 15624999.*$gdb_prompt $" {
303 pass "print value of lbig.l\[333\] >> 6"
304 }
305 -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" }
306 timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" }
307 }
This page took 0.978246 seconds and 4 git commands to generate.