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."
47 if [get_compiler_info ${binfile}] {
53 gdb_reinitialize_dir $srcdir/$subdir
58 # set it up at a breakpoint so we can play with the variable values
60 if ![runto_main] then {
61 perror "couldn't run to breakpoint"
65 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
69 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
72 -re ".*main.*$gdb_prompt $" {
73 pass "up from marker1"
75 -re ".*$gdb_prompt $" {
76 fail "up from marker1"
78 timeout { fail "up from marker1 (timeout)" }
81 -re "$gdb_prompt $" { fail "continue to marker1" }
82 timeout { fail "(timeout) continue to marker1" }
87 send_gdb "print &ibig.i\[0\]\n"
89 -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" {
90 pass "print value of &ibig.i\[0\]"
92 -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" }
93 timeout { fail "(timeout) print value of &ibig.i\[0\]" }
96 send_gdb "print &cbig.c\[0\]\n"
98 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
99 pass "print value of &cbig.c\[0\]"
101 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
102 pass "print value of &cbig.c\[0\]"
104 -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
105 timeout { fail "(timeout) print value of &cbig.c\[0\]" }
108 send_gdb "print &fbig.f\[0\]\n"
110 -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" {
111 pass "print value of &fbig.f\[0\]"
113 -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" }
114 timeout { fail "(timeout) print value of &fbig.f\[0\]" }
117 send_gdb "print &dbig.d\[0\]\n"
119 -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" {
120 pass "print value of &dbig.d\[0\]"
122 -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" }
123 timeout { fail "(timeout) print value of &dbig.d\[0\]" }
126 send_gdb "print &sbig.s\[0\]\n"
128 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
129 pass "print value of &sbig.s\[0\]"
131 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
132 pass "print value of &sbig.s\[0\]"
134 -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
135 timeout { fail "(timeout) print value of &sbig.s\[0\]" }
138 send_gdb "print &lbig.l\[0\]\n"
140 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
141 pass "print value of &lbig.l\[0\]"
143 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
144 pass "print value of &lbig.l\[0\]"
146 -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
147 timeout { fail "(timeout) print value of &lbig.l\[0\]" }
151 send_gdb "print ibig.i\[100\] | 1\n"
153 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
154 pass "print value of ibig.i\[100\] | 1"
156 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" }
157 timeout { fail "(timeout) print value of ibig.i\[100\] | 1" }
161 send_gdb "print sbig.s\[90\] & 127\n"
163 -re ".\[0-9\]* = 127.*$gdb_prompt $" {
164 pass "print value of sbig.s\[90\] & 127"
166 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" }
167 timeout { fail "(timeout) print value of sbig.s\[90\] & 127" }
170 send_gdb "print !ibig.i\[100\]\n"
172 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
173 pass "print value of !ibig.i\[100\]"
175 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
176 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
179 send_gdb "print !sbig.s\[90\]\n"
181 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
182 pass "print value of !sbig.s\[90\]"
184 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" }
185 timeout { fail "(timeout) print value of !sbig.s\[90\]" }
189 send_gdb "print !fbig.f\[100\]\n"
191 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
192 pass "print value of !ibig.i\[100\]"
194 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
195 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
198 send_gdb "print !dbig.d\[202\]\n"
200 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
201 pass "print value of !ibig.i\[100\]"
203 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
204 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
209 send_gdb "print sbig.s\[90\] * 10\n"
211 -re ".\[0-9\]* = 2550.*$gdb_prompt $" {
212 pass "print value of !sbig.s\[90\] * 10"
214 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" }
215 timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" }
218 send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
220 -re ".\[0-9\]* = 1275.*$gdb_prompt $" {
221 pass "print value of ibig.i\[100\] * sbig.s\[90\]"
223 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" }
224 timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" }
227 send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
229 -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" {
230 pass "print value of fbig.f\[100\] * dbig.d\[202\]"
232 -re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" }
233 timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" }
236 send_gdb "print !(sbig.s\[90\] * 2)\n"
238 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
239 pass "print value of !(sbig.s\[90\] * 2)"
241 -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" }
242 timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" }
246 send_gdb "print sizeof(sbig)\n"
248 -re ".\[0-9\]* = 800.*$gdb_prompt $" {
249 pass "print value of sizeof(sbig)"
251 -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" }
252 timeout { fail "(timeout) print value of sizeof(sbig)" }
256 send_gdb "print sizeof(cbig)\n"
258 -re ".\[0-9\]* = 100.*$gdb_prompt $" {
259 pass "print value of sizeof(cbig)"
261 -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" }
262 timeout { fail "(timeout) print value of sizeof(cbig)" }
266 send_gdb "print sizeof(lbig)/sizeof(long)\n"
268 -re ".\[0-9\]* = 900.*$gdb_prompt $" {
269 pass "print value of sizeof(lbig)/sizeof(long)"
271 -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" }
272 timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" }
275 send_gdb "print ibig.i\[100\] << 2\n"
277 -re ".\[0-9\]* = 20.*$gdb_prompt $" {
278 pass "print value of ibig.i\[100\] << 2"
280 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" }
281 timeout { fail "(timeout) print value of ibig.i\[100\] << 2" }
284 send_gdb "print sbig.s\[90\] >> 4\n"
286 -re ".\[0-9\]* = 15.*$gdb_prompt $" {
287 pass "print value of sbig.s\[90\] >> 4"
289 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" }
290 timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" }
293 send_gdb "print lbig.l\[333\] >> 6\n"
295 -re ".\[0-9\]* = 15624999.*$gdb_prompt $" {
296 pass "print value of lbig.l\[333\] >> 6"
298 -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" }
299 timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" }