1 |
578 |
markom |
# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 2000, 2001
|
2 |
|
|
# Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
# This program is free software; you can redistribute it and/or modify
|
5 |
|
|
# it under the terms of the GNU General Public License as published by
|
6 |
|
|
# the Free Software Foundation; either version 2 of the License, or
|
7 |
|
|
# (at your option) any later version.
|
8 |
|
|
#
|
9 |
|
|
# This program is distributed in the hope that it will be useful,
|
10 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
|
|
# GNU General Public License for more details.
|
13 |
|
|
#
|
14 |
|
|
# You should have received a copy of the GNU General Public License
|
15 |
|
|
# along with this program; if not, write to the Free Software
|
16 |
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
17 |
|
|
|
18 |
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
19 |
|
|
# bug-gdb@prep.ai.mit.edu
|
20 |
|
|
|
21 |
|
|
# This file was written by Rob Savoye. (rob@cygnus.com)
|
22 |
|
|
|
23 |
|
|
if $tracelevel {
|
24 |
|
|
strace $tracelevel
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
#
|
28 |
|
|
# test running programs
|
29 |
|
|
#
|
30 |
|
|
set prms_id 0
|
31 |
|
|
set bug_id 0
|
32 |
|
|
|
33 |
|
|
set testfile "exprs"
|
34 |
|
|
set srcfile ${testfile}.c
|
35 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
36 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
37 |
|
|
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
if [get_compiler_info ${binfile}] {
|
41 |
|
|
return -1;
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
gdb_exit
|
45 |
|
|
gdb_start
|
46 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
47 |
|
|
gdb_load ${binfile}
|
48 |
|
|
|
49 |
|
|
#
|
50 |
|
|
# set it up at a breakpoint so we can play with the variable values
|
51 |
|
|
#
|
52 |
|
|
|
53 |
|
|
if ![runto_main] then {
|
54 |
|
|
perror "couldn't run to breakpoint"
|
55 |
|
|
continue
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
proc test_expr { args } {
|
59 |
|
|
if { [llength $args] % 2 } {
|
60 |
|
|
warning "an even # of arguments should be passed to test_expr"
|
61 |
|
|
}
|
62 |
|
|
set last_ent [expr [llength $args] - 1];
|
63 |
|
|
set testname [lindex $args $last_ent];
|
64 |
|
|
if [gdb_test [lindex $args 0] "" "$testname (setup)"] {
|
65 |
|
|
gdb_suppress_tests;
|
66 |
|
|
}
|
67 |
|
|
for {set x 1} {$x < $last_ent} {set x [expr $x + 2]} {
|
68 |
|
|
if [gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname ([lindex $args $x])"] {
|
69 |
|
|
gdb_suppress_tests;
|
70 |
|
|
}
|
71 |
|
|
}
|
72 |
|
|
gdb_stop_suppressing_tests;
|
73 |
|
|
}
|
74 |
|
|
#
|
75 |
|
|
# test expressions with "char" types
|
76 |
|
|
#
|
77 |
|
|
test_expr "set variable v_char=127" "print v_char == 0" "\\$\[0-9\]* = $false" "print v_char == 127" "\\$\[0-9\]* = $true" "print char =="
|
78 |
|
|
test_expr "set variable v_char=127" "print v_char != 0" "\\$\[0-9\]* = $true" "print v_char != 127" "\\$\[0-9\]* = $false" "print char !="
|
79 |
|
|
test_expr "set variable v_char=127" "print v_char < 0" "\\$\[0-9\]* = $false" "print v_char < 127" "\\$\[0-9\]* = $false" "print char <"
|
80 |
|
|
test_expr "set variable v_char=127" "print v_char > 0" "\\$\[0-9\]* = $true" "print v_char > 127" "\\$\[0-9\]* = $false" "print char >"
|
81 |
|
|
#
|
82 |
|
|
# test expressions with "signed char" types
|
83 |
|
|
#
|
84 |
|
|
test_expr "set variable v_signed_char=127" "print v_signed_char == 0" "\\$\[0-9\]* = $false" "print v_signed_char == 127" "\\$\[0-9\]* = $true" "print signed char =="
|
85 |
|
|
test_expr "set variable v_signed_char=127" "print v_signed_char != 0" "\\$\[0-9\]* = $true" "print v_signed_char != 127" "\\$\[0-9\]* = $false" "print signed char !="
|
86 |
|
|
test_expr "set variable v_signed_char=127" "print v_signed_char < 0" "\\$\[0-9\]* = $false" "print v_signed_char < 127" "\\$\[0-9\]* = $false" "print signed char <"
|
87 |
|
|
test_expr "set variable v_signed_char=127" "print v_signed_char > 0" "\\$\[0-9\]* = $true" "print v_signed_char > 127" "\\$\[0-9\]* = $false" "print signed char >"
|
88 |
|
|
# make char a minus
|
89 |
|
|
test_expr "set variable v_signed_char=-1" "print v_signed_char == 0" "\\$\[0-9\]* = $false" "print v_signed_char == -1" "\\$\[0-9\]* = $true" "print signed char == (minus)"
|
90 |
|
|
test_expr "set variable v_signed_char=-1" "print v_signed_char != 0" "\\$\[0-9\]* = $true" "print v_signed_char != -1" "\\$\[0-9\]* = $false" "print signed char != (minus)"
|
91 |
|
|
test_expr "set variable v_signed_char=-1" "print v_signed_char < 0" "\\$\[0-9\]* = $true" "print v_signed_char < 127" "\\$\[0-9\]* = $true" "print signed char < (minus)"
|
92 |
|
|
test_expr "set variable v_signed_char=-1" "print v_signed_char > 0" "\\$\[0-9\]* = $false" "print v_signed_char > 127" "\\$\[0-9\]* = $false" "print signed char > (minus)"
|
93 |
|
|
#
|
94 |
|
|
# test expressions with "unsigned char" types
|
95 |
|
|
#
|
96 |
|
|
test_expr "set variable v_unsigned_char=127" "print v_unsigned_char == 0" "\\$\[0-9\]* = $false" "print v_unsigned_char == 127" "\\$\[0-9\]* = $true" "print unsigned char =="
|
97 |
|
|
test_expr "set variable v_unsigned_char=127" "print v_unsigned_char != 0" "\\$\[0-9\]* = $true" "print v_unsigned_char != 127" "\\$\[0-9\]* = $false" "print unsigned char !="
|
98 |
|
|
test_expr "set variable v_unsigned_char=127" "print v_unsigned_char < 0" "\\$\[0-9\]* = $false" "print v_unsigned_char < 127" "\\$\[0-9\]* = $false" "print unsigned char <"
|
99 |
|
|
test_expr "set variable v_unsigned_char=127" "print v_unsigned_char > 0" "\\$\[0-9\]* = $true" "print v_unsigned_char > 127" "\\$\[0-9\]* = $false" "print unsigned char >"
|
100 |
|
|
# make char a minus
|
101 |
|
|
# FIXME: gdb mishandles the cast (unsigned char) on the i960, so I've
|
102 |
|
|
# set up an expected failure for this case.
|
103 |
|
|
setup_xfail "i960-*-*" 1821
|
104 |
|
|
test_expr "set variable v_unsigned_char=~0" "print v_unsigned_char == 0" "\\$\[0-9\]* = $false" "print v_unsigned_char == ~0" "\\$\[0-9\]* = $false" "print v_unsigned_char == (unsigned char)~0" "\\$\[0-9\]* = $true" "print unsigned char == (~0)"
|
105 |
|
|
# FIXME: gdb mishandles the cast (unsigned char) on the i960, so I've
|
106 |
|
|
# set up an expected failure for this case.
|
107 |
|
|
setup_xfail "i960-*-*" 1821
|
108 |
|
|
test_expr "set variable v_unsigned_char=~0" "print v_unsigned_char != 0" "\\$\[0-9\]* = $true" "print v_unsigned_char != (unsigned char)~0" "\\$\[0-9\]* = $false" "print v_unsigned_char != ~0" "\\$\[0-9\]* = $true" "print unsigned char != (~0)"
|
109 |
|
|
test_expr "set variable v_unsigned_char=~0" "print v_unsigned_char < 0" "\\$\[0-9\]* = $false" "print v_unsigned_char < 127" "\\$\[0-9\]* = $false" "print unsigned char < (~0)"
|
110 |
|
|
test_expr "set variable v_unsigned_char=~0" "print v_unsigned_char > 0" "\\$\[0-9\]* = $true" "print v_unsigned_char > 127" "\\$\[0-9\]* = $true" "print unsigned char > (~0)"
|
111 |
|
|
#
|
112 |
|
|
# test expressions with "short" types
|
113 |
|
|
#
|
114 |
|
|
test_expr "set variable v_short=0x7FFF" "print v_short == 0" "\\$\[0-9\]* = $false" "print v_short == 0x7FFF" "\\$\[0-9\]* = $true" "print signed short =="
|
115 |
|
|
test_expr "set variable v_short=0x7FFF" "print v_short != 0" "\\$\[0-9\]* = $true" "print v_short != 0x7FFF" "\\$\[0-9\]* = $false" "print signed short !="
|
116 |
|
|
test_expr "set variable v_short=0x7FFF" "print v_short < 0" "\\$\[0-9\]* = $false" "print v_short < 0x7FFF" "\\$\[0-9\]* = $false" "print signed short <"
|
117 |
|
|
test_expr "set variable v_short=0x7FFF" "print v_short > 0" "\\$\[0-9\]* = $true" "print v_short > 0x7FFF" "\\$\[0-9\]* = $false" "print signed short >"
|
118 |
|
|
# make short a minus
|
119 |
|
|
test_expr "set variable v_short=-1" "print v_short == 0" "\\$\[0-9\]* = $false" "print v_short == -1" "\\$\[0-9\]* = $true" "print signed short == (minus)"
|
120 |
|
|
test_expr "set variable v_short=-1" "print v_short != 0" "\\$\[0-9\]* = $true" "print v_short != -1" "\\$\[0-9\]* = $false" "print signed short != (minus)"
|
121 |
|
|
test_expr "set variable v_short=-1" "print v_short < 0" "\\$\[0-9\]* = $true" "print v_short < 0x7FFF" "\\$\[0-9\]* = $true" "print signed short < (minus)"
|
122 |
|
|
test_expr "set variable v_short=-1" "print v_short > 0" "\\$\[0-9\]* = $false" "print v_short > 0x7FFF" "\\$\[0-9\]* = $false" "print signed short > (minus)"
|
123 |
|
|
#
|
124 |
|
|
# test expressions with "signed short" types
|
125 |
|
|
#
|
126 |
|
|
test_expr "set variable v_signed_short=0x7FFF" "print v_signed_short == 0" "\\$\[0-9\]* = $false" "print v_signed_short == 0x7FFF" "\\$\[0-9\]* = $true" "print signed signed short =="
|
127 |
|
|
test_expr "set variable v_signed_short=0x7FFF" "print v_signed_short != 0" "\\$\[0-9\]* = $true" "print v_signed_short != 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed short !="
|
128 |
|
|
test_expr "set variable v_signed_short=0x7FFF" "print v_signed_short < 0" "\\$\[0-9\]* = $false" "print v_signed_short < 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed short <"
|
129 |
|
|
test_expr "set variable v_signed_short=0x7FFF" "print v_signed_short > 0" "\\$\[0-9\]* = $true" "print v_signed_short > 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed short >"
|
130 |
|
|
# make short a minus
|
131 |
|
|
test_expr "set variable v_signed_short=-1" "print v_signed_short == 0" "\\$\[0-9\]* = $false" "print v_signed_short == -1" "\\$\[0-9\]* = $true" "print signed signed short == (minus)"
|
132 |
|
|
test_expr "set variable v_signed_short=-1" "print v_signed_short != 0" "\\$\[0-9\]* = $true" "print v_signed_short != -1" "\\$\[0-9\]* = $false" "print signed signed short != (minus)"
|
133 |
|
|
test_expr "set variable v_signed_short=-1" "print v_signed_short < 0" "\\$\[0-9\]* = $true" "print v_signed_short < 0x7FFF" "\\$\[0-9\]* = $true" "print signed signed short < (minus)"
|
134 |
|
|
test_expr "set variable v_signed_short=-1" "print v_signed_short > 0" "\\$\[0-9\]* = $false" "print v_signed_short > 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed short > (minus)"
|
135 |
|
|
#
|
136 |
|
|
# test expressions with "unsigned short" types
|
137 |
|
|
#
|
138 |
|
|
test_expr "set variable v_unsigned_short=0x7FFF" "print v_unsigned_short == 0" "\\$\[0-9\]* = $false" "print v_unsigned_short == 0x7FFF" "\\$\[0-9\]* = $true" "print unsigned short =="
|
139 |
|
|
test_expr "set variable v_unsigned_short=0x7FFF" "print v_unsigned_short != 0" "\\$\[0-9\]* = $true" "print v_unsigned_short != 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned short !="
|
140 |
|
|
test_expr "set variable v_unsigned_short=0x7FFF" "print v_unsigned_short < 0" "\\$\[0-9\]* = $false" "print v_unsigned_short < 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned short <"
|
141 |
|
|
test_expr "set variable v_unsigned_short=0x7FFF" "print v_unsigned_short > 0" "\\$\[0-9\]* = $true" "print v_unsigned_short > 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned short >"
|
142 |
|
|
# make short a minus
|
143 |
|
|
test_expr "set variable v_unsigned_short=~0" "print v_unsigned_short == 0" "\\$\[0-9\]* = $false" "print sizeof (v_unsigned_short) < sizeof (~0) && v_unsigned_short == ~0" "\\$\[0-9\]* = $false" "print v_unsigned_short == (unsigned short)~0" "\\$\[0-9\]* = $true" "print unsigned short == (~0)"
|
144 |
|
|
test_expr "set variable v_unsigned_short=~0" "print v_unsigned_short != 0" "\\$\[0-9\]* = $true" "print v_unsigned_short != (unsigned short)~0" "\\$\[0-9\]* = $false" "print unsigned short != (~0)"
|
145 |
|
|
test_expr "set variable v_unsigned_short=~0" "print v_unsigned_short < 0" "\\$\[0-9\]* = $false" "print v_unsigned_short < 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned short < (~0)"
|
146 |
|
|
test_expr "set variable v_unsigned_short=~0" "print v_unsigned_short > 0" "\\$\[0-9\]* = $true" "print v_unsigned_short > 0x7FFF" "\\$\[0-9\]* = $true" "print unsigned short > (~0)"
|
147 |
|
|
#
|
148 |
|
|
# test expressions with "int" types
|
149 |
|
|
#
|
150 |
|
|
test_expr "set variable v_int=0x7FFF" "print v_int == 0" "\\$\[0-9\]* = $false" "print v_int == 0x7FFF" "\\$\[0-9\]* = $true" "print signed int =="
|
151 |
|
|
test_expr "set variable v_int=0x7FFF" "print v_int != 0" "\\$\[0-9\]* = $true" "print v_int != 0x7FFF" "\\$\[0-9\]* = $false" "print signed int !="
|
152 |
|
|
test_expr "set variable v_int=0x7FFF" "print v_int < 0" "\\$\[0-9\]* = $false" "print v_int < 0x7FFF" "\\$\[0-9\]* = $false" "print signed int <"
|
153 |
|
|
test_expr "set variable v_int=0x7FFF" "print v_int > 0" "\\$\[0-9\]* = $true" "print v_int > 0x7FFF" "\\$\[0-9\]* = $false" "print signed int >"
|
154 |
|
|
# make int a minus
|
155 |
|
|
test_expr "set variable v_int=-1" "print v_int == 0" "\\$\[0-9\]* = $false" "print v_int == -1" "\\$\[0-9\]* = $true" "print signed int == (minus)"
|
156 |
|
|
test_expr "set variable v_int=-1" "print v_int != 0" "\\$\[0-9\]* = $true" "print v_int != -1" "\\$\[0-9\]* = $false" "print signed int != (minus)"
|
157 |
|
|
test_expr "set variable v_int=-1" "print v_int < 0" "\\$\[0-9\]* = $true" "print v_int < 0x7FFF" "\\$\[0-9\]* = $true" "print signed int < (minus)"
|
158 |
|
|
test_expr "set variable v_int=-1" "print v_int > 0" "\\$\[0-9\]* = $false" "print v_int > 0x7FFF" "\\$\[0-9\]* = $false" "print signed int > (minus)"
|
159 |
|
|
#
|
160 |
|
|
# test expressions with "signed int" types
|
161 |
|
|
#
|
162 |
|
|
test_expr "set variable v_signed_int=0x7FFF" "print v_signed_int == 0" "\\$\[0-9\]* = $false" "print v_signed_int == 0x7FFF" "\\$\[0-9\]* = $true" "print signed signed int =="
|
163 |
|
|
test_expr "set variable v_signed_int=0x7FFF" "print v_signed_int != 0" "\\$\[0-9\]* = $true" "print v_signed_int != 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed int !="
|
164 |
|
|
test_expr "set variable v_signed_int=0x7FFF" "print v_signed_int < 0" "\\$\[0-9\]* = $false" "print v_signed_int < 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed int <"
|
165 |
|
|
test_expr "set variable v_signed_int=0x7FFF" "print v_signed_int > 0" "\\$\[0-9\]* = $true" "print v_signed_int > 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed int >"
|
166 |
|
|
# make int a minus
|
167 |
|
|
test_expr "set variable v_signed_int=-1" "print v_signed_int == 0" "\\$\[0-9\]* = $false" "print v_signed_int == -1" "\\$\[0-9\]* = $true" "print signed signed int == (minus)"
|
168 |
|
|
test_expr "set variable v_signed_int=-1" "print v_signed_int != 0" "\\$\[0-9\]* = $true" "print v_signed_int != -1" "\\$\[0-9\]* = $false" "print signed signed int != (minus)"
|
169 |
|
|
test_expr "set variable v_signed_int=-1" "print v_signed_int < 0" "\\$\[0-9\]* = $true" "print v_signed_int < 0x7FFF" "\\$\[0-9\]* = $true" "print signed signed int < (minus)"
|
170 |
|
|
test_expr "set variable v_signed_int=-1" "print v_signed_int > 0" "\\$\[0-9\]* = $false" "print v_signed_int > 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed int > (minus)"
|
171 |
|
|
#
|
172 |
|
|
# test expressions with "unsigned int" types
|
173 |
|
|
#
|
174 |
|
|
test_expr "set variable v_unsigned_int=0x7FFF" "print v_unsigned_int == 0" "\\$\[0-9\]* = $false" "print v_unsigned_int == 0x7FFF" "\\$\[0-9\]* = $true" "print unsigned int =="
|
175 |
|
|
test_expr "set variable v_unsigned_int=0x7FFF" "print v_unsigned_int != 0" "\\$\[0-9\]* = $true" "print v_unsigned_int != 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned int !="
|
176 |
|
|
test_expr "set variable v_unsigned_int=0x7FFF" "print v_unsigned_int < 0" "\\$\[0-9\]* = $false" "print v_unsigned_int < 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned int <"
|
177 |
|
|
test_expr "set variable v_unsigned_int=0x7FFF" "print v_unsigned_int > 0" "\\$\[0-9\]* = $true" "print v_unsigned_int > 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned int >"
|
178 |
|
|
# make int a minus
|
179 |
|
|
test_expr "set variable v_unsigned_int=~0" "print v_unsigned_int == 0" "\\$\[0-9\]* = $false" "print v_unsigned_int == ~0" "\\$\[0-9\]* = $true" "print v_unsigned_int == (unsigned int)~0" "\\$\[0-9\]* = $true" "print unsigned int == (~0)"
|
180 |
|
|
test_expr "set variable v_unsigned_int=~0" "print v_unsigned_int != 0" "\\$\[0-9\]* = $true" "print v_unsigned_int != (unsigned int)~0" "\\$\[0-9\]* = $false" "print unsigned int != (~0)"
|
181 |
|
|
test_expr "set variable v_unsigned_int=~0" "print v_unsigned_int < 0" "\\$\[0-9\]* = $false" "print v_unsigned_int < 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned int < (~0)"
|
182 |
|
|
test_expr "set variable v_unsigned_int=~0" "print v_unsigned_int > 0" "\\$\[0-9\]* = $true" "print v_unsigned_int > 0x7FFF" "\\$\[0-9\]* = $true" "print unsigned int > (~0)"
|
183 |
|
|
#
|
184 |
|
|
# test expressions with "long" types
|
185 |
|
|
#
|
186 |
|
|
test_expr "set variable v_long=0x7FFF" "print v_long == 0" "\\$\[0-9\]* = $false" "print v_long == 0x7FFF" "\\$\[0-9\]* = $true" "print signed long =="
|
187 |
|
|
test_expr "set variable v_long=0x7FFF" "print v_long != 0" "\\$\[0-9\]* = $true" "print v_long != 0x7FFF" "\\$\[0-9\]* = $false" "print signed long !="
|
188 |
|
|
test_expr "set variable v_long=0x7FFF" "print v_long < 0" "\\$\[0-9\]* = $false" "print v_long < 0x7FFF" "\\$\[0-9\]* = $false" "print signed long <"
|
189 |
|
|
test_expr "set variable v_long=0x7FFF" "print v_long > 0" "\\$\[0-9\]* = $true" "print v_long > 0x7FFF" "\\$\[0-9\]* = $false" "print signed long >"
|
190 |
|
|
# make long a minus
|
191 |
|
|
test_expr "set variable v_long=-1" "print v_long == 0" "\\$\[0-9\]* = $false" "print v_long == -1" "\\$\[0-9\]* = $true" "print signed long == (minus)"
|
192 |
|
|
test_expr "set variable v_long=-1" "print v_long != 0" "\\$\[0-9\]* = $true" "print v_long != -1" "\\$\[0-9\]* = $false" "print signed long != (minus)"
|
193 |
|
|
test_expr "set variable v_long=-1" "print v_long < 0" "\\$\[0-9\]* = $true" "print v_long < 0x7FFF" "\\$\[0-9\]* = $true" "print signed long < (minus)"
|
194 |
|
|
test_expr "set variable v_long=-1" "print v_long > 0" "\\$\[0-9\]* = $false" "print v_long > 0x7FFF" "\\$\[0-9\]* = $false" "print signed long > (minus)"
|
195 |
|
|
#
|
196 |
|
|
# test expressions with "signed long" types
|
197 |
|
|
#
|
198 |
|
|
test_expr "set variable v_signed_long=0x7FFF" "print v_signed_long == 0" "\\$\[0-9\]* = $false" "print v_signed_long == 0x7FFF" "\\$\[0-9\]* = $true" "print signed signed long =="
|
199 |
|
|
test_expr "set variable v_signed_long=0x7FFF" "print v_signed_long != 0" "\\$\[0-9\]* = $true" "print v_signed_long != 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed long !="
|
200 |
|
|
test_expr "set variable v_signed_long=0x7FFF" "print v_signed_long < 0" "\\$\[0-9\]* = $false" "print v_signed_long < 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed long <"
|
201 |
|
|
test_expr "set variable v_signed_long=0x7FFF" "print v_signed_long > 0" "\\$\[0-9\]* = $true" "print v_signed_long > 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed long >"
|
202 |
|
|
# make long a minus
|
203 |
|
|
test_expr "set variable v_signed_long=-1" "print v_signed_long == 0" "\\$\[0-9\]* = $false" "print v_signed_long == -1" "\\$\[0-9\]* = $true" "print signed signed long == (minus)"
|
204 |
|
|
test_expr "set variable v_signed_long=-1" "print v_signed_long != 0" "\\$\[0-9\]* = $true" "print v_signed_long != -1" "\\$\[0-9\]* = $false" "print signed signed long != (minus)"
|
205 |
|
|
test_expr "set variable v_signed_long=-1" "print v_signed_long < 0" "\\$\[0-9\]* = $true" "print v_signed_long < 0x7FFF" "\\$\[0-9\]* = $true" "print signed signed long < (minus)"
|
206 |
|
|
test_expr "set variable v_signed_long=-1" "print v_signed_long > 0" "\\$\[0-9\]* = $false" "print v_signed_long > 0x7FFF" "\\$\[0-9\]* = $false" "print signed signed long > (minus)"
|
207 |
|
|
#
|
208 |
|
|
# test expressions with "unsigned long" types
|
209 |
|
|
#
|
210 |
|
|
test_expr "set variable v_unsigned_long=0x7FFF" "print v_unsigned_long == 0" "\\$\[0-9\]* = $false" "print v_unsigned_long == 0x7FFF" "\\$\[0-9\]* = $true" "print unsigned long =="
|
211 |
|
|
test_expr "set variable v_unsigned_long=0x7FFF" "print v_unsigned_long != 0" "\\$\[0-9\]* = $true" "print v_unsigned_long != 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned long !="
|
212 |
|
|
test_expr "set variable v_unsigned_long=0x7FFF" "print v_unsigned_long < 0" "\\$\[0-9\]* = $false" "print v_unsigned_long < 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned long <"
|
213 |
|
|
test_expr "set variable v_unsigned_long=0x7FFF" "print v_unsigned_long > 0" "\\$\[0-9\]* = $true" "print v_unsigned_long > 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned long >"
|
214 |
|
|
# make long a minus
|
215 |
|
|
test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long == 0" "\\$\[0-9\]* = $false" "print v_unsigned_long == ~0" "\\$\[0-9\]* = $true" "print v_unsigned_long == (unsigned long)~0" "\\$\[0-9\]* = $true" "print unsigned long == (~0)"
|
216 |
|
|
test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long != 0" "\\$\[0-9\]* = $true" "print v_unsigned_long != (unsigned long)~0" "\\$\[0-9\]* = $false" "print unsigned long != (~0)"
|
217 |
|
|
test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long < 0" "\\$\[0-9\]* = $false" "print v_unsigned_long < 0x7FFF" "\\$\[0-9\]* = $false" "print unsigned long < (~0)"
|
218 |
|
|
test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long > 0" "\\$\[0-9\]* = $true" "print v_unsigned_long > 0x7FFF" "\\$\[0-9\]* = $true" "print unsigned long > (~0)"
|
219 |
|
|
#
|
220 |
|
|
# Test expressions with casts to a pointer.
|
221 |
|
|
# NB: Some architectures convert a ``NULL'' pointer into
|
222 |
|
|
# something else. Don't simply test for 0.
|
223 |
|
|
#
|
224 |
|
|
test_expr "set variable v_signed_char = 0" "print (void*)v_signed_char" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_char"
|
225 |
|
|
test_expr "set variable v_signed_short = 0" "print (void*)v_signed_short" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_short"
|
226 |
|
|
test_expr "set variable v_signed_int = 0" "print (void*)v_signed_int" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_int"
|
227 |
|
|
test_expr "set variable v_signed_long = 0" "print (void*)v_signed_long" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_long"
|
228 |
|
|
test_expr "set variable v_unsigned_char = 0" "print (void*)v_unsigned_char" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_char"
|
229 |
|
|
test_expr "set variable v_unsigned_short = 0" "print (void*)v_unsigned_short" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_short"
|
230 |
|
|
test_expr "set variable v_unsigned_int = 0" "print (void*)v_unsigned_int" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_int"
|
231 |
|
|
test_expr "set variable v_unsigned_long = 0" "print (void*)v_unsigned_long" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_long"
|
232 |
|
|
#
|
233 |
|
|
# Test expressions with pointers out of range
|
234 |
|
|
#
|
235 |
|
|
# NB: For some architectures, all of sizeof(long),
|
236 |
|
|
# sizeof(long long) and sizeof(void*) are
|
237 |
|
|
# the same size so this test can not work.
|
238 |
|
|
#
|
239 |
|
|
send_gdb "print sizeof (long long) > sizeof (long)\n"
|
240 |
|
|
gdb_expect {
|
241 |
|
|
-re "\\$\[0-9\]* = $true.*$gdb_prompt" {
|
242 |
|
|
set ok 1
|
243 |
|
|
pass "sizeof (long long) > sizeof (long) (true)"
|
244 |
|
|
}
|
245 |
|
|
-re "\\$\[0-9\]* = $false.*$gdb_prompt" {
|
246 |
|
|
set ok 0
|
247 |
|
|
pass "sizeof (long long) > sizeof (long) (false)"
|
248 |
|
|
}
|
249 |
|
|
timeout {
|
250 |
|
|
set ok 0
|
251 |
|
|
fail "sizeof (long long) > sizeof (long) (timeout)"
|
252 |
|
|
}
|
253 |
|
|
}
|
254 |
|
|
if [expr ! $ok] { setup_xfail "*-*-*" }
|
255 |
|
|
gdb_test "print (void*) ((long long) (unsigned long) -1 + 1)" \
|
256 |
|
|
"warning: value truncated.*" "truncate (void*) 0x00000000ffffffff + 1"
|
257 |
|
|
if [expr ! $ok] { setup_xfail "*-*-*" }
|
258 |
|
|
gdb_test "print (void*) (~((long long)(unsigned long) -1) - 1)" \
|
259 |
|
|
"warning: value truncated.*" "truncate (void*) 0xffffffff00000000 - 1"
|