Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.base / miscexprs.exp
blob6fe071fa7d2aa55a051abc28c855219295dd3b9f
1 # Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
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.
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.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
21 # This file is part of the gdb testsuite
22 # file written by Elena Zannoni (ezannoni@cygnus.com)
25 # tests for expressions with struct/array elements and mixed operator types
26 # with elementary types
29 if $tracelevel then {
30 strace $tracelevel
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"
42 set additional_flags "additional_flags=${storage}"
45 # test running programs
47 set prms_id 0
48 set bug_id 0
50 set testfile "miscexprs"
51 set srcfile ${testfile}.c
52 set binfile ${objdir}/${subdir}/${testfile}
54 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } {
55 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
58 if [get_compiler_info ${binfile}] {
59 return -1;
62 gdb_exit
63 gdb_start
64 gdb_reinitialize_dir $srcdir/$subdir
65 gdb_load ${binfile}
69 # set it up at a breakpoint so we can play with the variable values
71 if ![runto_main] then {
72 perror "couldn't run to breakpoint"
73 continue
76 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
78 send_gdb "cont\n"
79 gdb_expect {
80 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
81 send_gdb "up\n"
82 gdb_expect {
83 -re ".*main.*$gdb_prompt $" {
84 pass "up from marker1"
86 -re ".*$gdb_prompt $" {
87 fail "up from marker1"
89 timeout { fail "up from marker1 (timeout)" }
92 -re "$gdb_prompt $" { fail "continue to marker1" }
93 timeout { fail "(timeout) continue to marker1" }
96 global hex
98 send_gdb "print &ibig.i\[0\]\n"
99 gdb_expect {
100 -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" {
101 pass "print value of &ibig.i\[0\]"
103 -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" }
104 timeout { fail "(timeout) print value of &ibig.i\[0\]" }
107 send_gdb "print &cbig.c\[0\]\n"
108 gdb_expect {
109 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
110 pass "print value of &cbig.c\[0\]"
112 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
113 pass "print value of &cbig.c\[0\]"
115 -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
116 timeout { fail "(timeout) print value of &cbig.c\[0\]" }
119 send_gdb "print &fbig.f\[0\]\n"
120 gdb_expect {
121 -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" {
122 pass "print value of &fbig.f\[0\]"
124 -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" }
125 timeout { fail "(timeout) print value of &fbig.f\[0\]" }
128 send_gdb "print &dbig.d\[0\]\n"
129 gdb_expect {
130 -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" {
131 pass "print value of &dbig.d\[0\]"
133 -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" }
134 timeout { fail "(timeout) print value of &dbig.d\[0\]" }
137 send_gdb "print &sbig.s\[0\]\n"
138 gdb_expect {
139 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
140 pass "print value of &sbig.s\[0\]"
142 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
143 pass "print value of &sbig.s\[0\]"
145 -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
146 timeout { fail "(timeout) print value of &sbig.s\[0\]" }
149 send_gdb "print &lbig.l\[0\]\n"
150 gdb_expect {
151 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
152 pass "print value of &lbig.l\[0\]"
154 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
155 pass "print value of &lbig.l\[0\]"
157 -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
158 timeout { fail "(timeout) print value of &lbig.l\[0\]" }
162 send_gdb "print ibig.i\[100\] | 1\n"
163 gdb_expect {
164 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
165 pass "print value of ibig.i\[100\] | 1"
167 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" }
168 timeout { fail "(timeout) print value of ibig.i\[100\] | 1" }
172 send_gdb "print sbig.s\[90\] & 127\n"
173 gdb_expect {
174 -re ".\[0-9\]* = 127.*$gdb_prompt $" {
175 pass "print value of sbig.s\[90\] & 127"
177 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" }
178 timeout { fail "(timeout) print value of sbig.s\[90\] & 127" }
181 send_gdb "print !ibig.i\[100\]\n"
182 gdb_expect {
183 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
184 pass "print value of !ibig.i\[100\]"
186 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
187 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
190 send_gdb "print !sbig.s\[90\]\n"
191 gdb_expect {
192 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
193 pass "print value of !sbig.s\[90\]"
195 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" }
196 timeout { fail "(timeout) print value of !sbig.s\[90\]" }
200 send_gdb "print !fbig.f\[100\]\n"
201 gdb_expect {
202 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
203 pass "print value of !ibig.i\[100\]"
205 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
206 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
209 send_gdb "print !dbig.d\[202\]\n"
210 gdb_expect {
211 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
212 pass "print value of !ibig.i\[100\]"
214 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
215 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
220 send_gdb "print sbig.s\[90\] * 10\n"
221 gdb_expect {
222 -re ".\[0-9\]* = 2550.*$gdb_prompt $" {
223 pass "print value of !sbig.s\[90\] * 10"
225 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" }
226 timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" }
229 send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
230 gdb_expect {
231 -re ".\[0-9\]* = 1275.*$gdb_prompt $" {
232 pass "print value of ibig.i\[100\] * sbig.s\[90\]"
234 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" }
235 timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" }
238 send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
239 gdb_expect {
240 -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" {
241 pass "print value of fbig.f\[100\] * dbig.d\[202\]"
243 -re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" }
244 timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" }
247 send_gdb "print !(sbig.s\[90\] * 2)\n"
248 gdb_expect {
249 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
250 pass "print value of !(sbig.s\[90\] * 2)"
252 -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" }
253 timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" }
257 send_gdb "print sizeof(sbig)\n"
258 gdb_expect {
259 -re ".\[0-9\]* = 800.*$gdb_prompt $" {
260 pass "print value of sizeof(sbig)"
262 -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" }
263 timeout { fail "(timeout) print value of sizeof(sbig)" }
267 send_gdb "print sizeof(cbig)\n"
268 gdb_expect {
269 -re ".\[0-9\]* = 100.*$gdb_prompt $" {
270 pass "print value of sizeof(cbig)"
272 -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" }
273 timeout { fail "(timeout) print value of sizeof(cbig)" }
277 send_gdb "print sizeof(lbig)/sizeof(long)\n"
278 gdb_expect {
279 -re ".\[0-9\]* = 900.*$gdb_prompt $" {
280 pass "print value of sizeof(lbig)/sizeof(long)"
282 -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" }
283 timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" }
286 send_gdb "print ibig.i\[100\] << 2\n"
287 gdb_expect {
288 -re ".\[0-9\]* = 20.*$gdb_prompt $" {
289 pass "print value of ibig.i\[100\] << 2"
291 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" }
292 timeout { fail "(timeout) print value of ibig.i\[100\] << 2" }
295 send_gdb "print sbig.s\[90\] >> 4\n"
296 gdb_expect {
297 -re ".\[0-9\]* = 15.*$gdb_prompt $" {
298 pass "print value of sbig.s\[90\] >> 4"
300 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" }
301 timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" }
304 send_gdb "print lbig.l\[333\] >> 6\n"
305 gdb_expect {
306 -re ".\[0-9\]* = 15624999.*$gdb_prompt $" {
307 pass "print value of lbig.l\[333\] >> 6"
309 -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" }
310 timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" }