]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/eval-skip.exp
bcd1674f2d9ec4974199edc46ba67dcedf52091a
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / eval-skip.exp
1 # Copyright 1998, 1999, 2007 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 3 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, see <http://www.gnu.org/licenses/>.
15
16 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@prep.ai.mit.edu
18
19 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
20
21 # This file is part of the gdb testsuite
22
23 #
24 # tests to cover evaluate_subexp_standard with the EVAL_SKIP flag set.
25 # this happens for instance when there is short circuit evaluation in the && and ||
26 # operators, or in the non returned part of a (x ? y: z) expression.
27 # the part that is not evaluated is parsed and evaluated anyway, but with
28 # the EVAL_SKIP flag set
29 #
30 # source file "int-type.c"
31 #
32
33
34 if $tracelevel then {
35 strace $tracelevel
36 }
37
38 # Check to see if we have an executable to test. If not, then either we
39 # haven't tried to compile one, or the compilation failed for some reason.
40 # In either case, just notify the user and skip the tests in this file.
41
42 set testfile "int-type"
43 set srcfile ${testfile}.c
44 set binfile ${objdir}/${subdir}/${testfile}
45
46 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
47 untested eval-skip.exp
48 return -1
49 }
50
51 if [get_compiler_info $binfile] {
52 return -1
53 }
54
55 gdb_exit
56 gdb_start
57 gdb_reinitialize_dir $srcdir/$subdir
58 gdb_load ${binfile}
59
60
61 if ![runto_main] then {
62 perror "couldn't run to breakpoint"
63 continue
64 }
65
66 gdb_test "set variable x=14" "" "set variable x=14"
67 gdb_test "set variable y=2" "" "set variable y=2"
68 gdb_test "set variable z=2" "" "set variable z=2"
69 gdb_test "set variable w=3" "" "set variable w=3"
70
71 send_gdb "print (0 && (x+y))\n"
72 gdb_expect {
73 -re ".$decimal = $false\r\n$gdb_prompt $" {
74 pass "print value of (0 && (x+y))"
75 }
76 -re ".*$gdb_prompt $" { fail "print value of (0 && (x+y))" }
77 timeout { fail "(timeout) print value of (0 && (x+y))" }
78 }
79
80
81 send_gdb "print (0 && (x-y))\n"
82 gdb_expect {
83 -re ".$decimal = $false\r\n$gdb_prompt $" {
84 pass "print value of (0 && (x-y))"
85 }
86 -re ".*$gdb_prompt $" { fail "print value of (0 && (x-y))" }
87 timeout { fail "(timeout) print value of (0 && (x-y))" }
88 }
89
90
91 send_gdb "print (0 && (x*y))\n"
92 gdb_expect {
93 -re ".$decimal = $false\r\n$gdb_prompt $" {
94 pass "print value of (0 && (x*y))"
95 }
96 -re ".*$gdb_prompt $" { fail "print value of (0 && (x*y))" }
97 timeout { fail "(timeout) print value of (0 && (x*y))" }
98 }
99
100
101
102 send_gdb "print (0 && (x/y))\n"
103 gdb_expect {
104 -re ".$decimal = $false\r\n$gdb_prompt $" {
105 pass "print value of (0 && (x/y))"
106 }
107 -re ".*$gdb_prompt $" { fail "print value of (0 && (x/y))" }
108 timeout { fail "(timeout) print value of (0 && (x/y))" }
109 }
110
111
112 send_gdb "print (0 && (x%y))\n"
113 gdb_expect {
114 -re ".$decimal = $false\r\n$gdb_prompt $" {
115 pass "print value of (0 && (x%y))"
116 }
117 -re ".*$gdb_prompt $" { fail "print value of (0 && (x%y))" }
118 timeout { fail "(timeout) print value of (0 && (x%y))" }
119 }
120
121
122 send_gdb "print (0 && (x&&y))\n"
123 gdb_expect {
124 -re ".$decimal = $false\r\n$gdb_prompt $" {
125 pass "print value of (0 && (x&&y))"
126 }
127 -re ".*$gdb_prompt $" { fail "print value of (0 && (x&&y))" }
128 timeout { fail "(timeout) print value of (0 && (x&&y))" }
129 }
130
131
132
133 send_gdb "print (0 && (x||y))\n"
134 gdb_expect {
135 -re ".$decimal = $false\r\n$gdb_prompt $" {
136 pass "print value of (0 && (x||y))"
137 }
138 -re ".*$gdb_prompt $" { fail "print value of (0 && (x||y))" }
139 timeout { fail "(timeout) print value of (0 && (x||y))" }
140 }
141
142
143
144 send_gdb "print (0 && (x&y))\n"
145 gdb_expect {
146 -re ".$decimal = $false\r\n$gdb_prompt $" {
147 pass "print value of (0 && (x&y))"
148 }
149 -re ".*$gdb_prompt $" { fail "print value of (0 && (x&y))" }
150 timeout { fail "(timeout) print value of (0 && (x&y))" }
151 }
152
153
154 send_gdb "print (0 && (x|y))\n"
155 gdb_expect {
156 -re ".$decimal = $false\r\n$gdb_prompt $" {
157 pass "print value of (0 && (x|y))"
158 }
159 -re ".*$gdb_prompt $" { fail "print value of (0 && (x|y))" }
160 timeout { fail "(timeout) print value of (0 && (x|y))" }
161 }
162
163
164 send_gdb "print (0 && (x^y))\n"
165 gdb_expect {
166 -re ".$decimal = $false\r\n$gdb_prompt $" {
167 pass "print value of (0 && (x^y))"
168 }
169 -re ".*$gdb_prompt $" { fail "print value of (0 && (x^y))" }
170 timeout { fail "(timeout) print value of (0 && (x^y))" }
171 }
172
173
174
175 send_gdb "print (0 && (x < y))\n"
176 gdb_expect {
177 -re ".$decimal = $false\r\n$gdb_prompt $" {
178 pass "print value of (0 && (x < y))"
179 }
180 -re ".*$gdb_prompt $" { fail "print value of (0 && (x < y))" }
181 timeout { fail "(timeout) print value of (0 && (x < y))" }
182 }
183
184
185 send_gdb "print (0 && (x <= y))\n"
186 gdb_expect {
187 -re ".$decimal = $false\r\n$gdb_prompt $" {
188 pass "print value of (0 && (x <= y))"
189 }
190 -re ".*$gdb_prompt $" { fail "print value of (0 && (x <= y))" }
191 timeout { fail "(timeout) print value of (0 && (x <= y))" }
192 }
193
194
195
196 send_gdb "print (0 && (x>y))\n"
197 gdb_expect {
198 -re ".$decimal = $false\r\n$gdb_prompt $" {
199 pass "print value of (0 && (x>y))"
200 }
201 -re ".*$gdb_prompt $" { fail "print value of (0 && (x>y))" }
202 timeout { fail "(timeout) print value of (0 && (x>y))" }
203 }
204
205
206 send_gdb "print (0 && (x>=y))\n"
207 gdb_expect {
208 -re ".$decimal = $false\r\n$gdb_prompt $" {
209 pass "print value of (0 && (x>=y))"
210 }
211 -re ".*$gdb_prompt $" { fail "print value of (0 && (x>=y))" }
212 timeout { fail "(timeout) print value of (0 && (x>=y))" }
213 }
214
215
216
217 send_gdb "print (0 && (x==y))\n"
218 gdb_expect {
219 -re ".$decimal = $false\r\n$gdb_prompt $" {
220 pass "print value of (0 && (x==y))"
221 }
222 -re ".*$gdb_prompt $" { fail "print value of (0 && (x==y))" }
223 timeout { fail "(timeout) print value of (0 && (x==y))" }
224 }
225
226
227 send_gdb "print (0 && (x!=y))\n"
228 gdb_expect {
229 -re ".$decimal = $false\r\n$gdb_prompt $" {
230 pass "print value of (0 && (x!=y))"
231 }
232 -re ".*$gdb_prompt $" { fail "print value of (0 && (x!=y))" }
233 timeout { fail "(timeout) print value of (0 && (x!=y))" }
234 }
235
236
237 send_gdb "print (0 && (x<<31))\n"
238 gdb_expect {
239 -re ".$decimal = $false\r\n$gdb_prompt $" {
240 pass "print value of (0 && (x<<31))"
241 }
242 -re ".*$gdb_prompt $" { fail "print value of (0 && (x<<31))" }
243 timeout { fail "(timeout) print value of (0 && (x<<31))" }
244 }
245
246
247 send_gdb "print (0 && (x>>31))\n"
248 gdb_expect {
249 -re ".$decimal = $false\r\n$gdb_prompt $" {
250 pass "print value of (0 && (x>>31))"
251 }
252 -re ".*$gdb_prompt $" { fail "print value of (0 && (x>>31))" }
253 timeout { fail "(timeout) print value of (0 && (x>>31))" }
254 }
255
256
257
258 send_gdb "print (0 && (!x))\n"
259 gdb_expect {
260 -re ".$decimal = $false\r\n$gdb_prompt $" {
261 pass "print value of (0 && (!x))"
262 }
263 -re ".*$gdb_prompt $" { fail "print value of (0 && (!x))" }
264 timeout { fail "(timeout) print value of (0 && (!x))" }
265 }
266
267
268 send_gdb "print (0 && (~x))\n"
269 gdb_expect {
270 -re ".$decimal = $false\r\n$gdb_prompt $" {
271 pass "print value of (0 && (~x))"
272 }
273 -re ".*$gdb_prompt $" { fail "print value of (0 && (~x))" }
274 timeout { fail "(timeout) print value of (0 && (~x))" }
275 }
276
277 send_gdb "print (0 && (-x))\n"
278 gdb_expect {
279 -re ".$decimal = $false\r\n$gdb_prompt $" {
280 pass "print value of (0 && (-x))"
281 }
282 -re ".*$gdb_prompt $" { fail "print value of (0 && (-x))" }
283 timeout { fail "(timeout) print value of (0 && (-x))" }
284 }
285
286
287 send_gdb "print (0 && (x++))\n"
288 gdb_expect {
289 -re ".$decimal = $false\r\n$gdb_prompt $" {
290 pass "print value of (0 && (x++))"
291 }
292 -re ".*$gdb_prompt $" { fail "print value of (0 && (x++))" }
293 timeout { fail "(timeout) print value of (0 && (x++))" }
294 }
295
296
297 send_gdb "print (0 && (++x))\n"
298 gdb_expect {
299 -re ".$decimal = $false\r\n$gdb_prompt $" {
300 pass "print value of (0 && (++x))"
301 }
302 -re ".*$gdb_prompt $" { fail "print value of (0 && (++x))" }
303 timeout { fail "(timeout) print value of (0 && (++x))" }
304 }
305
306
307 send_gdb "print (0 && (x--))\n"
308 gdb_expect {
309 -re ".$decimal = $false\r\n$gdb_prompt $" {
310 pass "print value of (0 && (x--))"
311 }
312 -re ".*$gdb_prompt $" { fail "print value of (0 && (x--))" }
313 timeout { fail "(timeout) print value of (0 && (x--))" }
314 }
315
316
317 send_gdb "print (0 && (--x))\n"
318 gdb_expect {
319 -re ".$decimal = $false\r\n$gdb_prompt $" {
320 pass "print value of (0 && (--x))"
321 }
322 -re ".*$gdb_prompt $" { fail "print value of (0 && (--x))" }
323 timeout { fail "(timeout) print value of (0 && (--x))" }
324 }
325
326 send_gdb "print (0 && (x+=7))\n"
327 gdb_expect {
328 -re ".$decimal = $false\r\n$gdb_prompt $" {
329 pass "print value of (0 && (x+=7))"
330 }
331 -re ".*$gdb_prompt $" { fail "print value of (0 && (x+=7))" }
332 timeout { fail "(timeout) print value of (0 && (x+=7))" }
333 }
334
335 send_gdb "print (0 && (x=y))\n"
336 gdb_expect {
337 -re ".$decimal = $false\r\n$gdb_prompt $" {
338 pass "print value of (0 && (x=y))"
339 }
340 -re ".*$gdb_prompt $" { fail "print value of (0 && (x=y))" }
341 timeout { fail "(timeout) print value of (0 && (x=y))" }
342 }
343
344 gdb_exit
345 return 0
346
347
348
349
350
351
352