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 ".*$gdb_prompt $" {}
73 timeout { fail "up from marker1" }
76 -re "$gdb_prompt $" { fail "continue to marker1" }
77 timeout { fail "(timeout) continue to marker1" }
82 send_gdb "print &ibig.i\[0\]\n"
84 -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" {
85 pass "print value of &ibig.i\[0\]"
87 -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" }
88 timeout { fail "(timeout) print value of &ibig.i\[0\]" }
91 send_gdb "print &cbig.c\[0\]\n"
93 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
94 pass "print value of &cbig.c\[0\]"
96 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
97 pass "print value of &cbig.c\[0\]"
99 -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
100 timeout { fail "(timeout) print value of &cbig.c\[0\]" }
103 send_gdb "print &fbig.f\[0\]\n"
105 -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" {
106 pass "print value of &fbig.f\[0\]"
108 -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" }
109 timeout { fail "(timeout) print value of &fbig.f\[0\]" }
112 send_gdb "print &dbig.d\[0\]\n"
114 -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" {
115 pass "print value of &dbig.d\[0\]"
117 -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" }
118 timeout { fail "(timeout) print value of &dbig.d\[0\]" }
121 send_gdb "print &sbig.s\[0\]\n"
123 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
124 pass "print value of &sbig.s\[0\]"
126 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
127 pass "print value of &sbig.s\[0\]"
129 -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
130 timeout { fail "(timeout) print value of &sbig.s\[0\]" }
133 send_gdb "print &lbig.l\[0\]\n"
135 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
136 pass "print value of &lbig.l\[0\]"
138 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
139 pass "print value of &lbig.l\[0\]"
141 -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
142 timeout { fail "(timeout) print value of &lbig.l\[0\]" }
146 send_gdb "print ibig.i\[100\] | 1\n"
148 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
149 pass "print value of ibig.i\[100\] | 1"
151 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" }
152 timeout { fail "(timeout) print value of ibig.i\[100\] | 1" }
156 send_gdb "print sbig.s\[90\] & 127\n"
158 -re ".\[0-9\]* = 127.*$gdb_prompt $" {
159 pass "print value of sbig.s\[90\] & 127"
161 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" }
162 timeout { fail "(timeout) print value of sbig.s\[90\] & 127" }
165 send_gdb "print !ibig.i\[100\]\n"
167 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
168 pass "print value of !ibig.i\[100\]"
170 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
171 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
174 send_gdb "print !sbig.s\[90\]\n"
176 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
177 pass "print value of !sbig.s\[90\]"
179 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" }
180 timeout { fail "(timeout) print value of !sbig.s\[90\]" }
184 send_gdb "print !fbig.f\[100\]\n"
186 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
187 pass "print value of !ibig.i\[100\]"
189 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
190 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
193 send_gdb "print !dbig.d\[202\]\n"
195 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
196 pass "print value of !ibig.i\[100\]"
198 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
199 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
204 send_gdb "print sbig.s\[90\] * 10\n"
206 -re ".\[0-9\]* = 2550.*$gdb_prompt $" {
207 pass "print value of !sbig.s\[90\] * 10"
209 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" }
210 timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" }
213 send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
215 -re ".\[0-9\]* = 1275.*$gdb_prompt $" {
216 pass "print value of ibig.i\[100\] * sbig.s\[90\]"
218 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" }
219 timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" }
222 send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
224 -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" {
225 pass "print value of fbig.f\[100\] * dbig.d\[202\]"
227 -re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" }
228 timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" }
231 send_gdb "print !(sbig.s\[90\] * 2)\n"
233 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
234 pass "print value of !(sbig.s\[90\] * 2)"
236 -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" }
237 timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" }
241 send_gdb "print sizeof(sbig)\n"
243 -re ".\[0-9\]* = 800.*$gdb_prompt $" {
244 pass "print value of sizeof(sbig)"
246 -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" }
247 timeout { fail "(timeout) print value of sizeof(sbig)" }
251 send_gdb "print sizeof(cbig)\n"
253 -re ".\[0-9\]* = 100.*$gdb_prompt $" {
254 pass "print value of sizeof(cbig)"
256 -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" }
257 timeout { fail "(timeout) print value of sizeof(cbig)" }
261 send_gdb "print sizeof(lbig)/sizeof(long)\n"
263 -re ".\[0-9\]* = 900.*$gdb_prompt $" {
264 pass "print value of sizeof(lbig)/sizeof(long)"
266 -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" }
267 timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" }
270 send_gdb "print ibig.i\[100\] << 2\n"
272 -re ".\[0-9\]* = 20.*$gdb_prompt $" {
273 pass "print value of ibig.i\[100\] << 2"
275 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" }
276 timeout { fail "(timeout) print value of ibig.i\[100\] << 2" }
279 send_gdb "print sbig.s\[90\] >> 4\n"
281 -re ".\[0-9\]* = 15.*$gdb_prompt $" {
282 pass "print value of sbig.s\[90\] >> 4"
284 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" }
285 timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" }
288 send_gdb "print lbig.l\[333\] >> 6\n"
290 -re ".\[0-9\]* = 15624999.*$gdb_prompt $" {
291 pass "print value of lbig.l\[333\] >> 6"
293 -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" }
294 timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" }