1 # Copyright (C) 1998 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
34 # test running programs
39 set testfile "miscexprs"
40 set srcfile ${testfile}.c
41 set binfile ${objdir}/${subdir}/${testfile}
43 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
44 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
50 gdb_reinitialize_dir $srcdir/$subdir
55 # set it up at a breakpoint so we can play with the variable values
57 if ![runto_main] then {
58 perror "couldn't run to breakpoint"
62 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
66 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
69 -re ".*$gdb_prompt $" {}
70 timeout { fail "up from marker1" }
73 -re "$gdb_prompt $" { fail "continue to marker1" }
74 timeout { fail "(timeout) continue to marker1" }
79 send_gdb "print &ibig.i\[0\]\n"
81 -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" {
82 pass "print value of &ibig.i\[0\]"
84 -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" }
85 timeout { fail "(timeout) print value of &ibig.i\[0\]" }
88 send_gdb "print &cbig.c\[0\]\n"
90 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
91 pass "print value of &cbig.c\[0\]"
93 -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
94 timeout { fail "(timeout) print value of &cbig.c\[0\]" }
97 send_gdb "print &fbig.f\[0\]\n"
99 -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" {
100 pass "print value of &fbig.f\[0\]"
102 -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" }
103 timeout { fail "(timeout) print value of &fbig.f\[0\]" }
106 send_gdb "print &dbig.d\[0\]\n"
108 -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" {
109 pass "print value of &dbig.d\[0\]"
111 -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" }
112 timeout { fail "(timeout) print value of &dbig.d\[0\]" }
115 send_gdb "print &sbig.s\[0\]\n"
117 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
118 pass "print value of &sbig.s\[0\]"
120 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
121 pass "print value of &sbig.s\[0\]"
123 -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
124 timeout { fail "(timeout) print value of &sbig.s\[0\]" }
127 send_gdb "print &lbig.l\[0\]\n"
129 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
130 pass "print value of &lbig.l\[0\]"
132 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
133 pass "print value of &lbig.l\[0\]"
135 -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
136 timeout { fail "(timeout) print value of &lbig.l\[0\]" }
140 send_gdb "print ibig.i\[100\] | 1\n"
142 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
143 pass "print value of ibig.i\[100\] | 1"
145 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" }
146 timeout { fail "(timeout) print value of ibig.i\[100\] | 1" }
150 send_gdb "print sbig.s\[90\] & 127\n"
152 -re ".\[0-9\]* = 127.*$gdb_prompt $" {
153 pass "print value of sbig.s\[90\] & 127"
155 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" }
156 timeout { fail "(timeout) print value of sbig.s\[90\] & 127" }
159 send_gdb "print !ibig.i\[100\]\n"
161 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
162 pass "print value of !ibig.i\[100\]"
164 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
165 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
168 send_gdb "print !sbig.s\[90\]\n"
170 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
171 pass "print value of !sbig.s\[90\]"
173 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" }
174 timeout { fail "(timeout) print value of !sbig.s\[90\]" }
178 send_gdb "print !fbig.f\[100\]\n"
180 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
181 pass "print value of !ibig.i\[100\]"
183 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
184 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
187 send_gdb "print !dbig.d\[202\]\n"
189 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
190 pass "print value of !ibig.i\[100\]"
192 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
193 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
198 send_gdb "print sbig.s\[90\] * 10\n"
200 -re ".\[0-9\]* = 2550.*$gdb_prompt $" {
201 pass "print value of !sbig.s\[90\] * 10"
203 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" }
204 timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" }
207 send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
209 -re ".\[0-9\]* = 1275.*$gdb_prompt $" {
210 pass "print value of ibig.i\[100\] * sbig.s\[90\]"
212 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" }
213 timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" }
216 send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
218 -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" {
219 pass "print value of fbig.f\[100\] * dbig.d\[202\]"
221 -re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" }
222 timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" }
225 send_gdb "print !(sbig.s\[90\] * 2)\n"
227 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
228 pass "print value of !(sbig.s\[90\] * 2)"
230 -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" }
231 timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" }
235 send_gdb "print sizeof(sbig)\n"
237 -re ".\[0-9\]* = 800.*$gdb_prompt $" {
238 pass "print value of sizeof(sbig)"
240 -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" }
241 timeout { fail "(timeout) print value of sizeof(sbig)" }
245 send_gdb "print sizeof(cbig)\n"
247 -re ".\[0-9\]* = 100.*$gdb_prompt $" {
248 pass "print value of sizeof(cbig)"
250 -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" }
251 timeout { fail "(timeout) print value of sizeof(cbig)" }
255 send_gdb "print sizeof(lbig)\n"
257 -re ".\[0-9\]* = 3600.*$gdb_prompt $" {
258 pass "print value of sizeof(lbig)"
260 -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)" }
261 timeout { fail "(timeout) print value of sizeof(lbig)" }
264 send_gdb "print ibig.i\[100\] << 2\n"
266 -re ".\[0-9\]* = 20.*$gdb_prompt $" {
267 pass "print value of ibig.i\[100\] << 2"
269 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" }
270 timeout { fail "(timeout) print value of ibig.i\[100\] << 2" }
273 send_gdb "print sbig.s\[90\] >> 4\n"
275 -re ".\[0-9\]* = 15.*$gdb_prompt $" {
276 pass "print value of sbig.s\[90\] >> 4"
278 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" }
279 timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" }
282 send_gdb "print lbig.l\[333\] >> 6\n"
284 -re ".\[0-9\]* = 15624999.*$gdb_prompt $" {
285 pass "print value of lbig.l\[333\] >> 6"
287 -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" }
288 timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" }