• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/gdb/gdb/testsuite/gdb.base/
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
29if $tracelevel then {
30	strace $tracelevel
31	}
32
33#
34# test running programs
35#
36set prms_id 0
37set bug_id 0
38
39set testfile "all-types"
40set srcfile ${testfile}.c
41set binfile ${objdir}/${subdir}/${testfile}
42
43if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
44    untested all-bin.exp
45    return -1
46    }
47
48if [get_compiler_info ${binfile}] {
49    return -1
50}
51
52gdb_exit
53gdb_start
54gdb_reinitialize_dir $srcdir/$subdir
55gdb_load ${binfile}
56
57
58#
59# set it up at a breakpoint so we can play with the variable values
60#
61
62if ![runto_main] then {
63    perror "couldn't run to breakpoint"
64    continue
65}
66
67gdb_test "next" "return 0;" "continuing after dummy()"
68
69send_gdb "print v_int+v_char\n"
70gdb_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
78send_gdb "print v_int+v_short\n"
79gdb_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
88send_gdb "print v_int+v_signed_char\n"
89gdb_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
98send_gdb "print v_int+v_unsigned_char\n"
99gdb_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
108send_gdb "print v_int+v_signed_short\n"
109gdb_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
118send_gdb "print v_int+v_unsigned_short\n"
119gdb_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
128send_gdb "print v_int+v_signed_int\n"
129gdb_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
138send_gdb "print v_int+v_unsigned_int\n"
139gdb_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
148send_gdb "print v_int+v_long\n"
149gdb_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
158send_gdb "print v_int+v_signed_long\n"
159gdb_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
168send_gdb "print v_int+v_unsigned_long\n"
169gdb_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
178send_gdb "print v_int+v_float\n"
179gdb_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
188send_gdb "print v_int+v_double\n"
189gdb_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
202send_gdb "print v_int <= v_char\n"
203gdb_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
211send_gdb "print v_int <= v_short\n"
212gdb_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
221send_gdb "print v_int <= v_signed_char\n"
222gdb_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
231send_gdb "print v_int <= v_unsigned_char\n"
232gdb_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
241send_gdb "print v_int <= v_signed_short\n"
242gdb_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
251send_gdb "print v_int <= v_unsigned_short\n"
252gdb_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
261send_gdb "print v_int <= v_signed_int\n"
262gdb_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
271send_gdb "print v_int <= v_unsigned_int\n"
272gdb_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
281send_gdb "print v_int <= v_long\n"
282gdb_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
291send_gdb "print v_int <= v_signed_long\n"
292gdb_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
301send_gdb "print v_int <= v_unsigned_long\n"
302gdb_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
311send_gdb "print v_int <= v_float\n"
312gdb_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
321send_gdb "print v_int <= v_double\n"
322gdb_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
336gdb_test "set variable v_char=0" "" "set v_char=0"
337gdb_test "set variable v_double=0.0" "" "set v_double=0"
338gdb_test "set variable v_unsigned_long=0" "" "set v_unsigned_long=0"
339
340send_gdb "print v_int && v_char\n"
341gdb_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
349send_gdb "print v_int && v_short\n"
350gdb_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
359send_gdb "print v_int && v_signed_char\n"
360gdb_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
369send_gdb "print v_int && v_unsigned_char\n"
370gdb_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
379send_gdb "print v_int && v_signed_short\n"
380gdb_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
389send_gdb "print v_int && v_unsigned_short\n"
390gdb_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
399send_gdb "print v_int && v_signed_int\n"
400gdb_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
409send_gdb "print v_int && v_unsigned_int\n"
410gdb_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
419send_gdb "print v_int && v_long\n"
420gdb_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
429send_gdb "print v_int && v_signed_long\n"
430gdb_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
439send_gdb "print v_int && v_unsigned_long\n"
440gdb_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
449send_gdb "print v_int && v_float\n"
450gdb_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
459send_gdb "print v_int && v_double\n"
460gdb_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
472