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# tests expressions with bitwise operators, and some
24# logical operators
25# Does not use a target program
26#
27
28
29if $tracelevel then {
30        strace $tracelevel
31        }
32
33#
34# test running programs
35#
36set prms_id 0
37set bug_id 0
38
39
40gdb_exit
41gdb_start
42gdb_reinitialize_dir $srcdir/$subdir
43
44
45send_gdb "print !1\n"
46gdb_expect {
47    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
48        pass "print value of !1"
49      }
50    -re ".*$gdb_prompt $" { fail "print value of !1" }
51    timeout           { fail "(timeout) print value of !1" }
52  }
53
54
55send_gdb "print !0\n"
56gdb_expect {
57    -re ".\[0-9\]* = 1.*$gdb_prompt $" {
58        pass "print value of !0"
59      }
60    -re ".*$gdb_prompt $" { fail "print value of !0" }
61    timeout           { fail "(timeout) print value of !0" }
62  }
63
64
65send_gdb "print !100\n"
66gdb_expect {
67    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
68        pass "print value of !100"
69      }
70    -re ".*$gdb_prompt $" { fail "print value of !100" }
71    timeout           { fail "(timeout) print value of !100" }
72  }
73
74
75send_gdb "print !1000\n"
76gdb_expect {
77    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
78        pass "print value of !1000"
79      }
80    -re ".*$gdb_prompt $" { fail "print value of !1000" }
81    timeout           { fail "(timeout) print value of !1000" }
82  }
83
84
85send_gdb "print !10\n"
86gdb_expect {
87    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
88        pass "print value of !10"
89      }
90    -re ".*$gdb_prompt $" { fail "print value of !10" }
91    timeout           { fail "(timeout) print value of !10" }
92  }
93
94
95send_gdb "print !2\n"
96gdb_expect {
97    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
98        pass "print value of !2 "
99      }
100    -re ".*$gdb_prompt $" { fail "print value of !2" }
101    timeout           { fail "(timeout) print value of !2" }
102  }
103
104
105send_gdb "print 10 | 5\n"
106gdb_expect {
107    -re ".\[0-9\]* = 15.*$gdb_prompt $" {
108        pass "print value of 10 | 5"
109      }
110    -re ".*$gdb_prompt $" { fail "print value of 10 | 5" }
111    timeout           { fail "(timeout) print value of 10 | 5" }
112  }
113
114
115send_gdb "print 10 & 5\n"
116gdb_expect {
117    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
118        pass "print value of 10 & 5"
119      }
120    -re ".*$gdb_prompt $" { fail "print value of 10 & 5" }
121    timeout           { fail "(timeout) print value of 10 & 5" }
122  }
123
124
125send_gdb "print 10 ^ 5\n"
126gdb_expect {
127    -re ".\[0-9\]* = 15.*$gdb_prompt $" {
128        pass "print value of 10 ^ 5"
129      }
130    -re ".*$gdb_prompt $" { fail "print value of 10 ^ 5" }
131    timeout           { fail "(timeout) print value of 10 ^ 5" }
132  }
133
134
135send_gdb "print -!0\n"
136gdb_expect {
137    -re ".\[0-9\]* = -1.*$gdb_prompt $" {
138        pass "print value of -!0"
139      }
140    -re ".*$gdb_prompt $" { fail "print value of -!0" }
141    timeout           { fail "(timeout) print value of -!0" }
142  }
143
144
145send_gdb "print ~-!0\n"
146gdb_expect {
147    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
148        pass "print value of ~-!0"
149      }
150    -re ".*$gdb_prompt $" { fail "print value of ~-!0" }
151    timeout           { fail "(timeout) print value of ~-!0" }
152  }
153
154
155
156send_gdb "print 3 * 2 / 4.0 * 2.0\n"
157gdb_expect {
158    -re ".\[0-9\]* = 3.*$gdb_prompt $" {
159        pass "print value of 3 * 2 / 4.0 * 2.0"
160      }
161    -re ".*$gdb_prompt $" { fail "print value of 3 * 2 / 4.0 * 2.0" }
162    timeout           { fail "(timeout) print value of 3 * 2 / 4.0 * 2.0" }
163  }
164
165
166send_gdb "print 8 << 2 >> 4\n"
167gdb_expect {
168    -re ".\[0-9\]* = 2.*$gdb_prompt $" {
169        pass "print value of 8 << 2 >> 4"
170      }
171    -re ".*$gdb_prompt $" { fail "print value of 8 << 2 >> 4" }
172    timeout           { fail "(timeout) print value of 8 << 2 >> 4" }
173  }
174
175
176send_gdb "print -1 < 0 > 1\n"
177gdb_expect {
178    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
179        pass "print value of -1 < 0 > 1"
180      }
181    -re ".*$gdb_prompt $" { fail "print value of -1 < 0 > 1" }
182    timeout           { fail "(timeout) print value of -1 < 0 > 1" }
183  }
184
185
186send_gdb "print 15 ^ 10 ^ 5 ^ 7\n"
187gdb_expect {
188    -re ".\[0-9\]* = 7.*$gdb_prompt $" {
189        pass "print value of 15 ^ 10 ^ 5 ^ 7"
190      }
191    -re ".*$gdb_prompt $" { fail "print value of 15 ^ 10 ^ 5 ^ 7" }
192    timeout           { fail "(timeout) print value of 15 ^ 10 ^ 5 ^ 7" }
193  }
194
195
196send_gdb "print 3.5 < 4.0\n"
197gdb_expect {
198    -re ".\[0-9\]* = 1.*$gdb_prompt $" {
199        pass "print value of 3.5 < 4.0"
200      }
201    -re ".*$gdb_prompt $" { fail "print value of 3.5 < 4.0" }
202    timeout           { fail "(timeout) print value of 3.5 < 4.0" }
203  }
204
205
206send_gdb "print 3.5 < -4.0\n"
207gdb_expect {
208    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
209        pass "print value of 3.5 < -4.0"
210      }
211    -re ".*$gdb_prompt $" { fail "print value of 3.5 < -4.0" }
212    timeout           { fail "(timeout) print value of 3.5 < -4.0" }
213  }
214
215
216send_gdb "print 2 > -3\n"
217gdb_expect {
218    -re ".\[0-9\]* = 1.*$gdb_prompt $" {
219        pass "print value of 2 > -3"
220      }
221    -re ".*$gdb_prompt $" { fail "print value of 2 > -3" }
222    timeout           { fail "(timeout) print value of 2 > -3" }
223  }
224
225
226send_gdb "print -3>4\n"
227gdb_expect {
228    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
229        pass "print value of -3>4"
230      }
231    -re ".*$gdb_prompt $" { fail "print value of -3>4" }
232    timeout           { fail "(timeout) print value of -3>4" }
233  }
234
235
236send_gdb "print (-3 > 4)\n"
237gdb_expect {
238    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
239        pass "print value of (-3 > 4)"
240      }
241    -re ".*$gdb_prompt $" { fail "print value of (-3 > 4)" }
242    timeout           { fail "(timeout) print value of (-3 > 4)" }
243  }
244
245
246send_gdb "print 3>=2.5\n"
247gdb_expect {
248    -re ".\[0-9\]* = 1.*$gdb_prompt $" {
249        pass "print value of 3>=2.5"
250      }
251    -re ".*$gdb_prompt $" { fail "print value of 3>=2.5" }
252    timeout           { fail "(timeout) print value of 3>=2.5" }
253  }
254
255
256send_gdb "print 3>=4.5\n"
257gdb_expect {
258    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
259        pass "print value of 3>=4.5"
260      }
261    -re ".*$gdb_prompt $" { fail "print value of 3>=4.5" }
262    timeout           { fail "(timeout) print value of 3>=4.5" }
263  }
264
265
266send_gdb "print 3==3.0\n"
267gdb_expect {
268    -re ".\[0-9\]* = 1.*$gdb_prompt $" {
269        pass "print value of 3==3.0"
270      }
271    -re ".*$gdb_prompt $" { fail "print value of 3==3.0" }
272    timeout           { fail "(timeout) print value of 3==3.0" }
273  }
274
275
276send_gdb "print 3==4.0\n"
277gdb_expect {
278    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
279        pass "print value of 3==4.0"
280      }
281    -re ".*$gdb_prompt $" { fail "print value of 3==4.0" }
282    timeout           { fail "(timeout) print value of 3==4.0" }
283  }
284
285
286send_gdb "print 3!=3.0\n"
287gdb_expect {
288    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
289        pass "print value of 3!=3.0"
290      }
291    -re ".*$gdb_prompt $" { fail "print value of 3!=3.0" }
292    timeout           { fail "(timeout) print value of 3!=3.0" }
293  }
294
295
296send_gdb "print 3!=5.0\n"
297gdb_expect {
298    -re ".\[0-9\]* = 1.*$gdb_prompt $" {
299        pass "print value of 3!=5.0"
300      }
301    -re ".*$gdb_prompt $" { fail "print value of 3!=5.0" }
302    timeout           { fail "(timeout) print value of 3!=5.0" }
303  }
304
305
306send_gdb "print 0 || 1 && 0 | 0 ^ 0 == 8 > 128 >>1 +2 *2\n"
307gdb_expect {
308    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
309        pass "print value of 0 || 1 && 0 | 0 ^ 0 == 8 > 128 >>1 +2 *2"
310      }
311    -re ".*$gdb_prompt $" { fail "print value of 0 || 1 && 0 | 0 ^ 0 == 8 > 128 >>1 +2 *2" }
312    timeout           { fail "(timeout) print value of 0 || 1 && 0 | 0 ^ 0 == 8 > 128 >>1 +2 *2" }
313  }
314
315
316send_gdb "print 1.0 || 0\n"
317gdb_expect {
318    -re ".\[0-9\]* = 1.*$gdb_prompt $" {
319        pass "print value of 1.0 || 0"
320      }
321    -re ".*$gdb_prompt $" { fail "print value of 1.0 || 0" }
322    timeout           { fail "(timeout) print value of 1.0 || 0" }
323  }
324
325
326send_gdb "print 0.0 || 1.0\n"
327gdb_expect {
328    -re ".\[0-9\]* = 1.*$gdb_prompt $" {
329        pass "print value of 0.0 || 1.0"
330      }
331    -re ".*$gdb_prompt $" { fail "print value of 0.0 || 1.0" }
332    timeout           { fail "(timeout) print value of 0.0 || 1.0" }
333  }
334
335
336send_gdb "print 0.0 || 0\n"
337gdb_expect {
338    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
339        pass "print value of 0.0 || 0"
340      }
341    -re ".*$gdb_prompt $" { fail "print value of 0.0 || 0" }
342    timeout           { fail "(timeout) print value of 0.0 || 0" }
343  }
344
345
346send_gdb "print 0 || 1 && 0 | 0 ^ 0 == 8\n"
347gdb_expect {
348    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
349        pass "print value of 0 || 1 && 0 | 0 ^ 0 == 8"
350      }
351    -re ".*$gdb_prompt $" { fail "print value of 0 || 1 && 0 | 0 ^ 0 == 8" }
352    timeout           { fail "(timeout) print value of 0 || 1 && 0 | 0 ^ 0 == 8" }
353  }
354
355
356send_gdb "print 0 == 8 > 128 >> 1 + 2 * 2\n"
357gdb_expect {
358    -re ".\[0-9\]* = 0.*$gdb_prompt $" {
359        pass "print value of 0 == 8 > 128 >> 1 + 2 * 2"
360      }
361    -re ".*$gdb_prompt $" { fail "print value of 0 == 8 > 128 >> 1 + 2 * 2" }
362    timeout           { fail "(timeout) print value of 0 == 8 > 128 >> 1 + 2 * 2" }
363  }
364
365