Update/correct copyright notices.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / miscexprs.exp
1 # Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
2
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.
12 #
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.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20
21 # This file is part of the gdb testsuite
22 # file written by Elena Zannoni (ezannoni@cygnus.com)
23
24 #
25 # tests for expressions with struct/array elements and mixed operator types
26 # with elementary types
27 #
28
29 if $tracelevel then {
30 strace $tracelevel
31 }
32
33 #
34 # test running programs
35 #
36 set prms_id 0
37 set bug_id 0
38
39 set testfile "miscexprs"
40 set srcfile ${testfile}.c
41 set binfile ${objdir}/${subdir}/${testfile}
42
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."
45 }
46
47 if [get_compiler_info ${binfile}] {
48 return -1;
49 }
50
51 gdb_exit
52 gdb_start
53 gdb_reinitialize_dir $srcdir/$subdir
54 gdb_load ${binfile}
55
56
57 #
58 # set it up at a breakpoint so we can play with the variable values
59 #
60 if ![runto_main] then {
61 perror "couldn't run to breakpoint"
62 continue
63 }
64
65 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
66
67 send_gdb "cont\n"
68 gdb_expect {
69 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
70 send_gdb "up\n"
71 gdb_expect {
72 -re ".*main.*$gdb_prompt $" {
73 pass "up from marker1"
74 }
75 -re ".*$gdb_prompt $" {
76 fail "up from marker1"
77 }
78 timeout { fail "up from marker1 (timeout)" }
79 }
80 }
81 -re "$gdb_prompt $" { fail "continue to marker1" }
82 timeout { fail "(timeout) continue to marker1" }
83 }
84
85 global hex
86
87 send_gdb "print &ibig.i\[0\]\n"
88 gdb_expect {
89 -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" {
90 pass "print value of &ibig.i\[0\]"
91 }
92 -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" }
93 timeout { fail "(timeout) print value of &ibig.i\[0\]" }
94 }
95
96 send_gdb "print &cbig.c\[0\]\n"
97 gdb_expect {
98 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
99 pass "print value of &cbig.c\[0\]"
100 }
101 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
102 pass "print value of &cbig.c\[0\]"
103 }
104 -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
105 timeout { fail "(timeout) print value of &cbig.c\[0\]" }
106 }
107
108 send_gdb "print &fbig.f\[0\]\n"
109 gdb_expect {
110 -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" {
111 pass "print value of &fbig.f\[0\]"
112 }
113 -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" }
114 timeout { fail "(timeout) print value of &fbig.f\[0\]" }
115 }
116
117 send_gdb "print &dbig.d\[0\]\n"
118 gdb_expect {
119 -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" {
120 pass "print value of &dbig.d\[0\]"
121 }
122 -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" }
123 timeout { fail "(timeout) print value of &dbig.d\[0\]" }
124 }
125
126 send_gdb "print &sbig.s\[0\]\n"
127 gdb_expect {
128 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
129 pass "print value of &sbig.s\[0\]"
130 }
131 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
132 pass "print value of &sbig.s\[0\]"
133 }
134 -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
135 timeout { fail "(timeout) print value of &sbig.s\[0\]" }
136 }
137
138 send_gdb "print &lbig.l\[0\]\n"
139 gdb_expect {
140 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
141 pass "print value of &lbig.l\[0\]"
142 }
143 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
144 pass "print value of &lbig.l\[0\]"
145 }
146 -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
147 timeout { fail "(timeout) print value of &lbig.l\[0\]" }
148 }
149
150
151 send_gdb "print ibig.i\[100\] | 1\n"
152 gdb_expect {
153 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
154 pass "print value of ibig.i\[100\] | 1"
155 }
156 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" }
157 timeout { fail "(timeout) print value of ibig.i\[100\] | 1" }
158 }
159
160
161 send_gdb "print sbig.s\[90\] & 127\n"
162 gdb_expect {
163 -re ".\[0-9\]* = 127.*$gdb_prompt $" {
164 pass "print value of sbig.s\[90\] & 127"
165 }
166 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" }
167 timeout { fail "(timeout) print value of sbig.s\[90\] & 127" }
168 }
169
170 send_gdb "print !ibig.i\[100\]\n"
171 gdb_expect {
172 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
173 pass "print value of !ibig.i\[100\]"
174 }
175 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
176 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
177 }
178
179 send_gdb "print !sbig.s\[90\]\n"
180 gdb_expect {
181 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
182 pass "print value of !sbig.s\[90\]"
183 }
184 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" }
185 timeout { fail "(timeout) print value of !sbig.s\[90\]" }
186 }
187
188
189 send_gdb "print !fbig.f\[100\]\n"
190 gdb_expect {
191 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
192 pass "print value of !ibig.i\[100\]"
193 }
194 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
195 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
196 }
197
198 send_gdb "print !dbig.d\[202\]\n"
199 gdb_expect {
200 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
201 pass "print value of !ibig.i\[100\]"
202 }
203 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
204 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
205 }
206
207
208
209 send_gdb "print sbig.s\[90\] * 10\n"
210 gdb_expect {
211 -re ".\[0-9\]* = 2550.*$gdb_prompt $" {
212 pass "print value of !sbig.s\[90\] * 10"
213 }
214 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" }
215 timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" }
216 }
217
218 send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
219 gdb_expect {
220 -re ".\[0-9\]* = 1275.*$gdb_prompt $" {
221 pass "print value of ibig.i\[100\] * sbig.s\[90\]"
222 }
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\]" }
225 }
226
227 send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
228 gdb_expect {
229 -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" {
230 pass "print value of fbig.f\[100\] * dbig.d\[202\]"
231 }
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\]" }
234 }
235
236 send_gdb "print !(sbig.s\[90\] * 2)\n"
237 gdb_expect {
238 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
239 pass "print value of !(sbig.s\[90\] * 2)"
240 }
241 -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" }
242 timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" }
243 }
244
245
246 send_gdb "print sizeof(sbig)\n"
247 gdb_expect {
248 -re ".\[0-9\]* = 800.*$gdb_prompt $" {
249 pass "print value of sizeof(sbig)"
250 }
251 -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" }
252 timeout { fail "(timeout) print value of sizeof(sbig)" }
253 }
254
255
256 send_gdb "print sizeof(cbig)\n"
257 gdb_expect {
258 -re ".\[0-9\]* = 100.*$gdb_prompt $" {
259 pass "print value of sizeof(cbig)"
260 }
261 -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" }
262 timeout { fail "(timeout) print value of sizeof(cbig)" }
263 }
264
265
266 send_gdb "print sizeof(lbig)/sizeof(long)\n"
267 gdb_expect {
268 -re ".\[0-9\]* = 900.*$gdb_prompt $" {
269 pass "print value of sizeof(lbig)/sizeof(long)"
270 }
271 -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" }
272 timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" }
273 }
274
275 send_gdb "print ibig.i\[100\] << 2\n"
276 gdb_expect {
277 -re ".\[0-9\]* = 20.*$gdb_prompt $" {
278 pass "print value of ibig.i\[100\] << 2"
279 }
280 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" }
281 timeout { fail "(timeout) print value of ibig.i\[100\] << 2" }
282 }
283
284 send_gdb "print sbig.s\[90\] >> 4\n"
285 gdb_expect {
286 -re ".\[0-9\]* = 15.*$gdb_prompt $" {
287 pass "print value of sbig.s\[90\] >> 4"
288 }
289 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" }
290 timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" }
291 }
292
293 send_gdb "print lbig.l\[333\] >> 6\n"
294 gdb_expect {
295 -re ".\[0-9\]* = 15624999.*$gdb_prompt $" {
296 pass "print value of lbig.l\[333\] >> 6"
297 }
298 -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" }
299 timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" }
300 }
This page took 0.03593 seconds and 5 git commands to generate.