OSDN Git Service

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