1 |
330 |
jeremybenn |
# Copyright 1998, 1999, 2007, 2008, 2009, 2010 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 .
|
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 |
|
|
|
34 |
|
|
set testfile "all-types"
|
35 |
|
|
set srcfile ${testfile}.c
|
36 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
37 |
|
|
|
38 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
|
39 |
|
|
untested all-bin.exp
|
40 |
|
|
return -1
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
if [get_compiler_info ${binfile}] {
|
44 |
|
|
return -1
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
gdb_exit
|
48 |
|
|
gdb_start
|
49 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
50 |
|
|
gdb_load ${binfile}
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
#
|
54 |
|
|
# set it up at a breakpoint so we can play with the variable values
|
55 |
|
|
#
|
56 |
|
|
|
57 |
|
|
if ![runto_main] then {
|
58 |
|
|
perror "couldn't run to breakpoint"
|
59 |
|
|
continue
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
gdb_test "next" "return 0;" "continuing after dummy()"
|
63 |
|
|
|
64 |
|
|
gdb_test "print v_int+v_char" " = 71" "print value of v_int+v_char"
|
65 |
|
|
|
66 |
|
|
gdb_test "print v_int+v_short" " = 9" "print value of v_int+v_short"
|
67 |
|
|
|
68 |
|
|
gdb_test "print v_int+v_signed_char" " = 72" \
|
69 |
|
|
"print value of v_int+v_signed_char"
|
70 |
|
|
|
71 |
|
|
gdb_test "print v_int+v_unsigned_char" " = 73" \
|
72 |
|
|
"print value of v_int+v_unsigned_char"
|
73 |
|
|
|
74 |
|
|
gdb_test "print v_int+v_signed_short" " = 10" \
|
75 |
|
|
"print value of v_int+v_signed_short"
|
76 |
|
|
|
77 |
|
|
gdb_test "print v_int+v_unsigned_short" " = 11" \
|
78 |
|
|
"print value of v_int+v_unsigned_short"
|
79 |
|
|
|
80 |
|
|
gdb_test "print v_int+v_signed_int" " = 13" \
|
81 |
|
|
"print value of v_int+v_signed_int"
|
82 |
|
|
|
83 |
|
|
gdb_test "print v_int+v_unsigned_int" " = 14" \
|
84 |
|
|
"print value of v_int+v_unsigned_int"
|
85 |
|
|
|
86 |
|
|
gdb_test "print v_int+v_long" " = 15" "print value of v_int+v_long"
|
87 |
|
|
|
88 |
|
|
gdb_test "print v_int+v_signed_long" " = 16" \
|
89 |
|
|
"print value of v_int+v_signed_long"
|
90 |
|
|
|
91 |
|
|
gdb_test "print v_int+v_unsigned_long" " = 17" \
|
92 |
|
|
"print value of v_int+v_unsigned_long"
|
93 |
|
|
|
94 |
|
|
gdb_test "print v_int+v_float" " = 106.34343.*" \
|
95 |
|
|
"print value of v_int+v_float"
|
96 |
|
|
|
97 |
|
|
gdb_test "print v_int+v_double" " = 206.565.*" \
|
98 |
|
|
"print value of v_int+v_double"
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
#
|
102 |
|
|
# test the relational operators with mixed types
|
103 |
|
|
#
|
104 |
|
|
|
105 |
|
|
gdb_test "print v_int <= v_char" " = 1" "print value of v_int<=v_char"
|
106 |
|
|
|
107 |
|
|
gdb_test "print v_int <= v_short" " = $false" \
|
108 |
|
|
"print value of v_int<=v_short"
|
109 |
|
|
|
110 |
|
|
gdb_test "print v_int <= v_signed_char" " = 1" \
|
111 |
|
|
"print value of v_int<=v_signed_char"
|
112 |
|
|
|
113 |
|
|
gdb_test "print v_int <= v_unsigned_char" " = 1" \
|
114 |
|
|
"print value of v_int<=v_unsigned_char"
|
115 |
|
|
|
116 |
|
|
gdb_test "print v_int <= v_signed_short" " = $false" \
|
117 |
|
|
"print value of v_int<=v_signed_short"
|
118 |
|
|
|
119 |
|
|
gdb_test "print v_int <= v_unsigned_short" " = $false" \
|
120 |
|
|
"print value of v_int<=v_unsigned_short"
|
121 |
|
|
|
122 |
|
|
gdb_test "print v_int <= v_signed_int" " = $true" \
|
123 |
|
|
"print value of v_int<=v_signed_int"
|
124 |
|
|
|
125 |
|
|
gdb_test "print v_int <= v_unsigned_int" " = $true" \
|
126 |
|
|
"print value of v_int<=v_unsigned_int"
|
127 |
|
|
|
128 |
|
|
gdb_test "print v_int <= v_long" " = $true" "print value of v_int<=v_long"
|
129 |
|
|
|
130 |
|
|
gdb_test "print v_int <= v_signed_long" " = $true" \
|
131 |
|
|
"print value of v_int<=v_signed_long"
|
132 |
|
|
|
133 |
|
|
gdb_test "print v_int <= v_unsigned_long" " = $true" \
|
134 |
|
|
"print value of v_int<=v_unsigned_long"
|
135 |
|
|
|
136 |
|
|
gdb_test "print v_int <= v_float" " = $true" "print value of v_int<=v_float"
|
137 |
|
|
|
138 |
|
|
gdb_test "print v_int <= v_double" " = $true" \
|
139 |
|
|
"print value of v_int<=v_double"
|
140 |
|
|
|
141 |
|
|
#
|
142 |
|
|
# test the logical operators with mixed types
|
143 |
|
|
#
|
144 |
|
|
|
145 |
|
|
gdb_test_no_output "set variable v_char=0" "set v_char=0"
|
146 |
|
|
gdb_test_no_output "set variable v_double=0.0" "set v_double=0"
|
147 |
|
|
gdb_test_no_output "set variable v_unsigned_long=0" "set v_unsigned_long=0"
|
148 |
|
|
|
149 |
|
|
gdb_test "print v_int && v_char" " = $false" "print value of v_int&&v_char"
|
150 |
|
|
|
151 |
|
|
gdb_test "print v_int && v_short" " = $true" "print value of v_int&&v_short"
|
152 |
|
|
|
153 |
|
|
gdb_test "print v_int && v_signed_char" " = $true" \
|
154 |
|
|
"print value of v_int&&v_signed_char"
|
155 |
|
|
|
156 |
|
|
gdb_test "print v_int && v_unsigned_char" " = $true" \
|
157 |
|
|
"print value of v_int&&v_unsigned_char"
|
158 |
|
|
|
159 |
|
|
gdb_test "print v_int && v_signed_short" " = $true" \
|
160 |
|
|
"print value of v_int&&v_signed_short"
|
161 |
|
|
|
162 |
|
|
gdb_test "print v_int && v_unsigned_short" " = $true" \
|
163 |
|
|
"print value of v_int&&v_unsigned_short"
|
164 |
|
|
|
165 |
|
|
gdb_test "print v_int && v_signed_int" " = $true" \
|
166 |
|
|
"print value of v_int&&v_signed_int"
|
167 |
|
|
|
168 |
|
|
gdb_test "print v_int && v_unsigned_int" " = $true" \
|
169 |
|
|
"print value of v_int&&v_unsigned_int"
|
170 |
|
|
|
171 |
|
|
gdb_test "print v_int && v_long" " = $true" "print value of v_int&&v_long"
|
172 |
|
|
|
173 |
|
|
gdb_test "print v_int && v_signed_long" " = $true" \
|
174 |
|
|
"print value of v_int&&v_signed_long"
|
175 |
|
|
|
176 |
|
|
gdb_test "print v_int && v_unsigned_long" " = $false" \
|
177 |
|
|
"print value of v_int&&v_unsigned_long"
|
178 |
|
|
|
179 |
|
|
gdb_test "print v_int && v_float" " = $true" "print value of v_int&&v_float"
|
180 |
|
|
|
181 |
|
|
gdb_test "print v_int && v_double" " = $false" \
|
182 |
|
|
"print value of v_int&&v_double"
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|