OSDN Git Service

b7787c27600f2be49888f569e9b710fbc8520d76
[pf3gnuchains/pf3gnuchains3x.git] / gdb / testsuite / gdb.base / all-bin.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 # tests for arithmetic, logical and relational operators
24 # with mixed types
25
26
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 "all-types"
40 set srcfile ${testfile}.c
41 set binfile ${objdir}/${subdir}/${testfile}
42
43 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
44     untested all-bin.exp
45     return -1
46     }
47
48 if [get_compiler_info ${binfile}] {
49     return -1
50 }
51
52 gdb_exit
53 gdb_start
54 gdb_reinitialize_dir $srcdir/$subdir
55 gdb_load ${binfile}
56
57
58 #
59 # set it up at a breakpoint so we can play with the variable values
60 #
61
62 if ![runto_main] then {
63     perror "couldn't run to breakpoint"
64     continue
65 }
66
67 gdb_test "next" "return 0;" "continuing after dummy()"
68
69 send_gdb "print v_int+v_char\n"
70 gdb_expect {
71     -re ".*71.*$gdb_prompt $" {
72         pass "print value of v_int+v_char"
73       }
74     -re ".*$gdb_prompt $" { fail "print value of v_int+v_char" }
75     timeout           { fail "(timeout) print value of v_int+v_char" }    
76   }
77
78 send_gdb "print v_int+v_short\n"
79 gdb_expect {
80     -re ".*9.*$gdb_prompt $" {
81         pass "print value of v_int+v_short"
82       }
83     -re ".*$gdb_prompt $" { fail "print value of v_int+v_short" }
84     timeout           { fail "(timeout) print value of v_int+v_short" }    
85   }
86
87
88 send_gdb "print v_int+v_signed_char\n"
89 gdb_expect {
90     -re ".*72.*$gdb_prompt $" {
91         pass "print value of v_int+v_signed_char"
92       }
93     -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_char" }
94     timeout           { fail "(timeout) print value of v_int+v_signed_char" }    
95   }
96
97
98 send_gdb "print v_int+v_unsigned_char\n"
99 gdb_expect {
100     -re ".*73.*$gdb_prompt $" {
101         pass "print value of v_int+v_unsigned_char"
102       }
103     -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_char" }
104     timeout           { fail "(timeout) print value of v_int+v_unsigned_char" }    
105   }
106
107
108 send_gdb "print v_int+v_signed_short\n"
109 gdb_expect {
110     -re ".*10.*$gdb_prompt $" {
111         pass "print value of v_int+v_signed_short"
112       }
113     -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_short" }
114     timeout           { fail "(timeout) print value of v_int+v_signed_short" }    
115   }
116
117
118 send_gdb "print v_int+v_unsigned_short\n"
119 gdb_expect {
120     -re ".*11.*$gdb_prompt $" {
121         pass "print value of v_int+v_unsigned_short"
122       }
123     -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_short" }
124     timeout           { fail "(timeout) print value of v_int+v_unsigned_short" }    
125   }
126
127
128 send_gdb "print v_int+v_signed_int\n"
129 gdb_expect {
130     -re ".*13.*$gdb_prompt $" {
131         pass "print value of v_int+v_signed_int"
132       }
133     -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_int" }
134     timeout           { fail "(timeout) print value of v_int+v_signed_int" }    
135   }
136
137
138 send_gdb "print v_int+v_unsigned_int\n"
139 gdb_expect {
140     -re ".*14.*$gdb_prompt $" {
141         pass "print value of v_int+v_unsigned_int"
142       }
143     -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_int" }
144     timeout           { fail "(timeout) print value of v_int+v_unsigned_int" }    
145   }
146
147
148 send_gdb "print v_int+v_long\n"
149 gdb_expect {
150     -re ".*15.*$gdb_prompt $" {
151         pass "print value of v_int+v_long"
152       }
153     -re ".*$gdb_prompt $" { fail "print value of v_int+v_long" }
154     timeout           { fail "(timeout) print value of v_int+v_long" }    
155   }
156
157
158 send_gdb "print v_int+v_signed_long\n"
159 gdb_expect {
160     -re ".*16.*$gdb_prompt $" {
161         pass "print value of v_int+v_signed_long"
162       }
163     -re ".*$gdb_prompt $" { fail "print value of v_int+v_signed_long" }
164     timeout           { fail "(timeout) print value of v_int+v_signed_long" }    
165   }
166
167
168 send_gdb "print v_int+v_unsigned_long\n"
169 gdb_expect {
170     -re ".*17.*$gdb_prompt $" {
171         pass "print value of v_int+v_unsigned_long"
172       }
173     -re ".*$gdb_prompt $" { fail "print value of v_int+v_unsigned_long" }
174     timeout           { fail "(timeout) print value of v_int+v_unsigned_long" }    
175   }
176
177
178 send_gdb "print v_int+v_float\n"
179 gdb_expect {
180     -re ".*106.34343.*$gdb_prompt $" {
181         pass "print value of v_int+v_float"
182       }
183     -re ".*$gdb_prompt $" { fail "print value of v_int+v_float" }
184     timeout           { fail "(timeout) print value of v_int+v_float" }    
185   }
186
187
188 send_gdb "print v_int+v_double\n"
189 gdb_expect {
190     -re ".*206.565.*$gdb_prompt $" {
191         pass "print value of v_int+v_double"
192     }
193     -re ".*$gdb_prompt $" { fail "print value of v_int+v_double" }
194     timeout     { fail "(timeout) print value of v_int+v_double" }
195 }
196
197
198 #
199 # test the relational operators with mixed types
200 #
201
202 send_gdb "print v_int <= v_char\n"
203 gdb_expect {
204     -re ".*1.*$gdb_prompt $" {
205         pass "print value of v_int<=v_char"
206       }
207     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_char" }
208     timeout           { fail "(timeout) print value of v_int<=v_char" }    
209   }
210
211 send_gdb "print v_int <= v_short\n"
212 gdb_expect {
213     -re ".*$false.*$gdb_prompt $" {
214         pass "print value of v_int<=v_short"
215       }
216     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_short" }
217     timeout           { fail "(timeout) print value of v_int<=v_short" }    
218   }
219
220
221 send_gdb "print v_int <= v_signed_char\n"
222 gdb_expect {
223     -re ".*1.*$gdb_prompt $" {
224         pass "print value of v_int<=v_signed_char"
225       }
226     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_char" }
227     timeout           { fail "(timeout) print value of v_int<=v_signed_char" }    
228   }
229
230
231 send_gdb "print v_int <= v_unsigned_char\n"
232 gdb_expect {
233     -re ".*1.*$gdb_prompt $" {
234         pass "print value of v_int<=v_unsigned_char"
235       }
236     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_char" }
237     timeout           { fail "(timeout) print value of v_int<=v_unsigned_char" }    
238   }
239
240
241 send_gdb "print v_int <= v_signed_short\n"
242 gdb_expect {
243     -re ".*$false.*$gdb_prompt $" {
244         pass "print value of v_int<=v_signed_short"
245       }
246     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_short" }
247     timeout           { fail "(timeout) print value of v_int<=v_signed_short" }    
248   }
249
250
251 send_gdb "print v_int <= v_unsigned_short\n"
252 gdb_expect {
253     -re ".*$false.*$gdb_prompt $" {
254         pass "print value of v_int<=v_unsigned_short"
255       }
256     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_short" }
257     timeout           { fail "(timeout) print value of v_int<=v_unsigned_short" }    
258   }
259
260
261 send_gdb "print v_int <= v_signed_int\n"
262 gdb_expect {
263     -re ".*$true.*$gdb_prompt $" {
264         pass "print value of v_int<=v_signed_int"
265       }
266     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_int" }
267     timeout           { fail "(timeout) print value of v_int<=v_signed_int" }    
268   }
269
270
271 send_gdb "print v_int <= v_unsigned_int\n"
272 gdb_expect {
273     -re ".*$true.*$gdb_prompt $" {
274         pass "print value of v_int<=v_unsigned_int"
275       }
276     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_int" }
277     timeout           { fail "(timeout) print value of v_int<=v_unsigned_int" }    
278   }
279
280
281 send_gdb "print v_int <= v_long\n"
282 gdb_expect {
283     -re ".*$true.*$gdb_prompt $" {
284         pass "print value of v_int<=v_long"
285       }
286     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_long" }
287     timeout           { fail "(timeout) print value of v_int<=v_long" }    
288   }
289
290
291 send_gdb "print v_int <= v_signed_long\n"
292 gdb_expect {
293     -re ".*$true.*$gdb_prompt $" {
294         pass "print value of v_int<=v_signed_long"
295       }
296     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_signed_long" }
297     timeout           { fail "(timeout) print value of v_int<=v_signed_long" }    
298   }
299
300
301 send_gdb "print v_int <= v_unsigned_long\n"
302 gdb_expect {
303     -re ".*$true.*$gdb_prompt $" {
304         pass "print value of v_int<=v_unsigned_long"
305       }
306     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_unsigned_long" }
307     timeout           { fail "(timeout) print value of v_int<=v_unsigned_long" }    
308   }
309
310
311 send_gdb "print v_int <= v_float\n"
312 gdb_expect {
313     -re ".*$true.*$gdb_prompt $" {
314         pass "print value of v_int<=v_float"
315       }
316     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_float" }
317     timeout           { fail "(timeout) print value of v_int<=v_float" }    
318   }
319
320
321 send_gdb "print v_int <= v_double\n"
322 gdb_expect {
323     -re ".*$true.*$gdb_prompt $" {
324         pass "print value of v_int<=v_double"
325       }
326     -re ".*$gdb_prompt $" { fail "print value of v_int<=v_double" }
327     timeout           { fail "(timeout) print value of v_int<=v_double" }    
328   }
329
330
331
332 #
333 # test the logical operators with mixed types
334 #
335
336 gdb_test "set variable v_char=0" "" "set v_char=0"
337 gdb_test "set variable v_double=0.0" "" "set v_double=0"
338 gdb_test "set variable v_unsigned_long=0" "" "set v_unsigned_long=0"
339
340 send_gdb "print v_int && v_char\n"
341 gdb_expect {
342     -re ".*$false.*$gdb_prompt $" {
343         pass "print value of v_int&&v_char"
344       }
345     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_char" }
346     timeout           { fail "(timeout) print value of v_int&&v_char" }    
347   }
348
349 send_gdb "print v_int && v_short\n"
350 gdb_expect {
351     -re ".*$true.*$gdb_prompt $" {
352         pass "print value of v_int&&v_short"
353       }
354     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_short" }
355     timeout           { fail "(timeout) print value of v_int&&v_short" }    
356   }
357
358
359 send_gdb "print v_int && v_signed_char\n"
360 gdb_expect {
361     -re ".*$true.*$gdb_prompt $" {
362         pass "print value of v_int&&v_signed_char"
363       }
364     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_char" }
365     timeout           { fail "(timeout) print value of v_int&&v_signed_char" }    
366   }
367
368
369 send_gdb "print v_int && v_unsigned_char\n"
370 gdb_expect {
371     -re ".*$true.*$gdb_prompt $" {
372         pass "print value of v_int&&v_unsigned_char"
373       }
374     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_char" }
375     timeout           { fail "(timeout) print value of v_int&&v_unsigned_char" }    
376   }
377
378
379 send_gdb "print v_int && v_signed_short\n"
380 gdb_expect {
381     -re ".*$true.*$gdb_prompt $" {
382         pass "print value of v_int&&v_signed_short"
383       }
384     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_short" }
385     timeout           { fail "(timeout) print value of v_int&&v_signed_short" }    
386   }
387
388
389 send_gdb "print v_int && v_unsigned_short\n"
390 gdb_expect {
391     -re ".*$true.*$gdb_prompt $" {
392         pass "print value of v_int&&v_unsigned_short"
393       }
394     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_short" }
395     timeout           { fail "(timeout) print value of v_int&&v_unsigned_short" }    
396   }
397
398
399 send_gdb "print v_int && v_signed_int\n"
400 gdb_expect {
401     -re ".*$true.*$gdb_prompt $" {
402         pass "print value of v_int&&v_signed_int"
403       }
404     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_int" }
405     timeout           { fail "(timeout) print value of v_int&&v_signed_int" }    
406   }
407
408
409 send_gdb "print v_int && v_unsigned_int\n"
410 gdb_expect {
411     -re ".*$true.*$gdb_prompt $" {
412         pass "print value of v_int&&v_unsigned_int"
413       }
414     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_int" }
415     timeout           { fail "(timeout) print value of v_int&&v_unsigned_int" }    
416   }
417
418
419 send_gdb "print v_int && v_long\n"
420 gdb_expect {
421     -re ".*$true.*$gdb_prompt $" {
422         pass "print value of v_int&&v_long"
423       }
424     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_long" }
425     timeout           { fail "(timeout) print value of v_int&&v_long" }    
426   }
427
428
429 send_gdb "print v_int && v_signed_long\n"
430 gdb_expect {
431     -re ".*$true.*$gdb_prompt $" {
432         pass "print value of v_int&&v_signed_long"
433       }
434     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_signed_long" }
435     timeout           { fail "(timeout) print value of v_int&&v_signed_long" }    
436   }
437
438
439 send_gdb "print v_int && v_unsigned_long\n"
440 gdb_expect {
441     -re ".*$false.*$gdb_prompt $" {
442         pass "print value of v_int&&v_unsigned_long"
443       }
444     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_unsigned_long" }
445     timeout           { fail "(timeout) print value of v_int&&v_unsigned_long" }    
446   }
447
448
449 send_gdb "print v_int && v_float\n"
450 gdb_expect {
451     -re ".*$true.*$gdb_prompt $" {
452         pass "print value of v_int&&v_float"
453       }
454     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_float" }
455     timeout           { fail "(timeout) print value of v_int&&v_float" }    
456   }
457
458
459 send_gdb "print v_int && v_double\n"
460 gdb_expect {
461     -re ".*$false.*$gdb_prompt $" {
462         pass "print value of v_int&&v_double"
463       }
464     -re ".*$gdb_prompt $" { fail "print value of v_int&&v_double" }
465     timeout           { fail "(timeout) print value of v_int&&v_double" }    
466   }
467
468
469
470
471