1 # Copyright 1998, 1999, 2000, 2007 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.
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
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
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 untested miscexprs.exp
59 if [get_compiler_info ${binfile}] {
65 gdb_reinitialize_dir $srcdir/$subdir
70 # set it up at a breakpoint so we can play with the variable values
72 if ![runto_main] then {
73 perror "couldn't run to breakpoint"
77 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
81 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
84 -re ".*main.*$gdb_prompt $" {
85 pass "up from marker1"
87 -re ".*$gdb_prompt $" {
88 fail "up from marker1"
90 timeout { fail "up from marker1 (timeout)" }
93 -re "$gdb_prompt $" { fail "continue to marker1" }
94 timeout { fail "(timeout) continue to marker1" }
99 send_gdb "print &ibig.i\[0\]\n"
101 -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" {
102 pass "print value of &ibig.i\[0\]"
104 -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" }
105 timeout { fail "(timeout) print value of &ibig.i\[0\]" }
108 send_gdb "print &cbig.c\[0\]\n"
110 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
111 pass "print value of &cbig.c\[0\]"
113 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
114 pass "print value of &cbig.c\[0\]"
116 -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
117 timeout { fail "(timeout) print value of &cbig.c\[0\]" }
120 send_gdb "print &fbig.f\[0\]\n"
122 -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" {
123 pass "print value of &fbig.f\[0\]"
125 -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" }
126 timeout { fail "(timeout) print value of &fbig.f\[0\]" }
129 send_gdb "print &dbig.d\[0\]\n"
131 -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" {
132 pass "print value of &dbig.d\[0\]"
134 -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" }
135 timeout { fail "(timeout) print value of &dbig.d\[0\]" }
138 send_gdb "print &sbig.s\[0\]\n"
140 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
141 pass "print value of &sbig.s\[0\]"
143 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
144 pass "print value of &sbig.s\[0\]"
146 -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
147 timeout { fail "(timeout) print value of &sbig.s\[0\]" }
150 send_gdb "print &lbig.l\[0\]\n"
152 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
153 pass "print value of &lbig.l\[0\]"
155 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
156 pass "print value of &lbig.l\[0\]"
158 -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
159 timeout { fail "(timeout) print value of &lbig.l\[0\]" }
163 send_gdb "print ibig.i\[100\] | 1\n"
165 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
166 pass "print value of ibig.i\[100\] | 1"
168 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" }
169 timeout { fail "(timeout) print value of ibig.i\[100\] | 1" }
173 send_gdb "print sbig.s\[90\] & 127\n"
175 -re ".\[0-9\]* = 127.*$gdb_prompt $" {
176 pass "print value of sbig.s\[90\] & 127"
178 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" }
179 timeout { fail "(timeout) print value of sbig.s\[90\] & 127" }
182 send_gdb "print !ibig.i\[100\]\n"
184 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
185 pass "print value of !ibig.i\[100\]"
187 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
188 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
191 send_gdb "print !sbig.s\[90\]\n"
193 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
194 pass "print value of !sbig.s\[90\]"
196 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" }
197 timeout { fail "(timeout) print value of !sbig.s\[90\]" }
201 send_gdb "print !fbig.f\[100\]\n"
203 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
204 pass "print value of !ibig.i\[100\]"
206 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
207 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
210 send_gdb "print !dbig.d\[202\]\n"
212 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
213 pass "print value of !ibig.i\[100\]"
215 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
216 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
221 send_gdb "print sbig.s\[90\] * 10\n"
223 -re ".\[0-9\]* = 2550.*$gdb_prompt $" {
224 pass "print value of !sbig.s\[90\] * 10"
226 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" }
227 timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" }
230 send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
232 -re ".\[0-9\]* = 1275.*$gdb_prompt $" {
233 pass "print value of ibig.i\[100\] * sbig.s\[90\]"
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\]" }
239 send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
241 -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" {
242 pass "print value of fbig.f\[100\] * dbig.d\[202\]"
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\]" }
248 send_gdb "print !(sbig.s\[90\] * 2)\n"
250 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
251 pass "print value of !(sbig.s\[90\] * 2)"
253 -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" }
254 timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" }
258 send_gdb "print sizeof(sbig)\n"
260 -re ".\[0-9\]* = 800.*$gdb_prompt $" {
261 pass "print value of sizeof(sbig)"
263 -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" }
264 timeout { fail "(timeout) print value of sizeof(sbig)" }
268 send_gdb "print sizeof(cbig)\n"
270 -re ".\[0-9\]* = 100.*$gdb_prompt $" {
271 pass "print value of sizeof(cbig)"
273 -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" }
274 timeout { fail "(timeout) print value of sizeof(cbig)" }
278 send_gdb "print sizeof(lbig)/sizeof(long)\n"
280 -re ".\[0-9\]* = 900.*$gdb_prompt $" {
281 pass "print value of sizeof(lbig)/sizeof(long)"
283 -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" }
284 timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" }
287 send_gdb "print ibig.i\[100\] << 2\n"
289 -re ".\[0-9\]* = 20.*$gdb_prompt $" {
290 pass "print value of ibig.i\[100\] << 2"
292 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" }
293 timeout { fail "(timeout) print value of ibig.i\[100\] << 2" }
296 send_gdb "print sbig.s\[90\] >> 4\n"
298 -re ".\[0-9\]* = 15.*$gdb_prompt $" {
299 pass "print value of sbig.s\[90\] >> 4"
301 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" }
302 timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" }
305 send_gdb "print lbig.l\[333\] >> 6\n"
307 -re ".\[0-9\]* = 15624999.*$gdb_prompt $" {
308 pass "print value of lbig.l\[333\] >> 6"
310 -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" }
311 timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" }