]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/exprs.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / exprs.exp
CommitLineData
74641dfb 1# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 2000,
6aba47ca 2# 2001, 2003, 2007 Free Software Foundation, Inc.
c906108c
SS
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
23if $tracelevel {
24 strace $tracelevel
25}
26
27#
28# test running programs
29#
30set prms_id 0
31set bug_id 0
32
33set testfile "exprs"
34set srcfile ${testfile}.c
35set binfile ${objdir}/${subdir}/${testfile}
36if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
37 untested exprs.exp
38 return -1
c906108c
SS
39}
40
41if [get_compiler_info ${binfile}] {
42 return -1;
43}
44
45gdb_exit
46gdb_start
47gdb_reinitialize_dir $srcdir/$subdir
48gdb_load ${binfile}
49
50#
51# set it up at a breakpoint so we can play with the variable values
52#
53
54if ![runto_main] then {
55 perror "couldn't run to breakpoint"
56 continue
57}
58
59proc test_expr { args } {
60 if { [llength $args] % 2 } {
61 warning "an even # of arguments should be passed to test_expr"
62 }
63 set last_ent [expr [llength $args] - 1];
64 set testname [lindex $args $last_ent];
65 if [gdb_test [lindex $args 0] "" "$testname (setup)"] {
66 gdb_suppress_tests;
67 }
68 for {set x 1} {$x < $last_ent} {set x [expr $x + 2]} {
69 if [gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname ([lindex $args $x])"] {
70 gdb_suppress_tests;
71 }
72 }
73 gdb_stop_suppressing_tests;
74}
75#
76# test expressions with "char" types
77#
085dd6e6
JM
78test_expr "set variable v_char=127" "print v_char == 0" "\\$\[0-9\]* = $false" "print v_char == 127" "\\$\[0-9\]* = $true" "print char =="
79test_expr "set variable v_char=127" "print v_char != 0" "\\$\[0-9\]* = $true" "print v_char != 127" "\\$\[0-9\]* = $false" "print char !="
80test_expr "set variable v_char=127" "print v_char < 0" "\\$\[0-9\]* = $false" "print v_char < 127" "\\$\[0-9\]* = $false" "print char <"
81test_expr "set variable v_char=127" "print v_char > 0" "\\$\[0-9\]* = $true" "print v_char > 127" "\\$\[0-9\]* = $false" "print char >"
c906108c
SS
82#
83# test expressions with "signed char" types
84#
085dd6e6
JM
85test_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 =="
86test_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 !="
87test_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 <"
88test_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 >"
c906108c 89# make char a minus
085dd6e6
JM
90test_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)"
91test_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)"
92test_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)"
93test_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)"
c906108c
SS
94#
95# test expressions with "unsigned char" types
96#
085dd6e6
JM
97test_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 =="
98test_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 !="
99test_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 <"
100test_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 >"
c906108c 101# make char a minus
f2d8c86d 102test_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)"
400071f1 103test_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)"
085dd6e6
JM
104test_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)"
105test_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)"
c906108c
SS
106#
107# test expressions with "short" types
108#
085dd6e6
JM
109test_expr "set variable v_short=0x7FFF" "print v_short == 0" "\\$\[0-9\]* = $false" "print v_short == 0x7FFF" "\\$\[0-9\]* = $true" "print signed short =="
110test_expr "set variable v_short=0x7FFF" "print v_short != 0" "\\$\[0-9\]* = $true" "print v_short != 0x7FFF" "\\$\[0-9\]* = $false" "print signed short !="
111test_expr "set variable v_short=0x7FFF" "print v_short < 0" "\\$\[0-9\]* = $false" "print v_short < 0x7FFF" "\\$\[0-9\]* = $false" "print signed short <"
112test_expr "set variable v_short=0x7FFF" "print v_short > 0" "\\$\[0-9\]* = $true" "print v_short > 0x7FFF" "\\$\[0-9\]* = $false" "print signed short >"
c906108c 113# make short a minus
085dd6e6
JM
114test_expr "set variable v_short=-1" "print v_short == 0" "\\$\[0-9\]* = $false" "print v_short == -1" "\\$\[0-9\]* = $true" "print signed short == (minus)"
115test_expr "set variable v_short=-1" "print v_short != 0" "\\$\[0-9\]* = $true" "print v_short != -1" "\\$\[0-9\]* = $false" "print signed short != (minus)"
116test_expr "set variable v_short=-1" "print v_short < 0" "\\$\[0-9\]* = $true" "print v_short < 0x7FFF" "\\$\[0-9\]* = $true" "print signed short < (minus)"
117test_expr "set variable v_short=-1" "print v_short > 0" "\\$\[0-9\]* = $false" "print v_short > 0x7FFF" "\\$\[0-9\]* = $false" "print signed short > (minus)"
c906108c
SS
118#
119# test expressions with "signed short" types
120#
085dd6e6
JM
121test_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 =="
122test_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 !="
123test_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 <"
124test_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 >"
c906108c 125# make short a minus
085dd6e6
JM
126test_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)"
127test_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)"
128test_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)"
129test_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)"
c906108c
SS
130#
131# test expressions with "unsigned short" types
132#
085dd6e6
JM
133test_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 =="
134test_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 !="
135test_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 <"
136test_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 >"
c906108c 137# make short a minus
400071f1 138test_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)"
085dd6e6
JM
139test_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)"
140test_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)"
141test_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)"
c906108c
SS
142#
143# test expressions with "int" types
144#
085dd6e6
JM
145test_expr "set variable v_int=0x7FFF" "print v_int == 0" "\\$\[0-9\]* = $false" "print v_int == 0x7FFF" "\\$\[0-9\]* = $true" "print signed int =="
146test_expr "set variable v_int=0x7FFF" "print v_int != 0" "\\$\[0-9\]* = $true" "print v_int != 0x7FFF" "\\$\[0-9\]* = $false" "print signed int !="
147test_expr "set variable v_int=0x7FFF" "print v_int < 0" "\\$\[0-9\]* = $false" "print v_int < 0x7FFF" "\\$\[0-9\]* = $false" "print signed int <"
148test_expr "set variable v_int=0x7FFF" "print v_int > 0" "\\$\[0-9\]* = $true" "print v_int > 0x7FFF" "\\$\[0-9\]* = $false" "print signed int >"
c906108c 149# make int a minus
085dd6e6
JM
150test_expr "set variable v_int=-1" "print v_int == 0" "\\$\[0-9\]* = $false" "print v_int == -1" "\\$\[0-9\]* = $true" "print signed int == (minus)"
151test_expr "set variable v_int=-1" "print v_int != 0" "\\$\[0-9\]* = $true" "print v_int != -1" "\\$\[0-9\]* = $false" "print signed int != (minus)"
152test_expr "set variable v_int=-1" "print v_int < 0" "\\$\[0-9\]* = $true" "print v_int < 0x7FFF" "\\$\[0-9\]* = $true" "print signed int < (minus)"
153test_expr "set variable v_int=-1" "print v_int > 0" "\\$\[0-9\]* = $false" "print v_int > 0x7FFF" "\\$\[0-9\]* = $false" "print signed int > (minus)"
c906108c
SS
154#
155# test expressions with "signed int" types
156#
085dd6e6
JM
157test_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 =="
158test_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 !="
159test_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 <"
160test_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 >"
c906108c 161# make int a minus
085dd6e6
JM
162test_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)"
163test_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)"
164test_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)"
165test_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)"
c906108c
SS
166#
167# test expressions with "unsigned int" types
168#
085dd6e6
JM
169test_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 =="
170test_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 !="
171test_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 <"
172test_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 >"
c906108c 173# make int a minus
085dd6e6
JM
174test_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)"
175test_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)"
176test_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)"
177test_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)"
c906108c
SS
178#
179# test expressions with "long" types
180#
085dd6e6
JM
181test_expr "set variable v_long=0x7FFF" "print v_long == 0" "\\$\[0-9\]* = $false" "print v_long == 0x7FFF" "\\$\[0-9\]* = $true" "print signed long =="
182test_expr "set variable v_long=0x7FFF" "print v_long != 0" "\\$\[0-9\]* = $true" "print v_long != 0x7FFF" "\\$\[0-9\]* = $false" "print signed long !="
183test_expr "set variable v_long=0x7FFF" "print v_long < 0" "\\$\[0-9\]* = $false" "print v_long < 0x7FFF" "\\$\[0-9\]* = $false" "print signed long <"
184test_expr "set variable v_long=0x7FFF" "print v_long > 0" "\\$\[0-9\]* = $true" "print v_long > 0x7FFF" "\\$\[0-9\]* = $false" "print signed long >"
c906108c 185# make long a minus
085dd6e6
JM
186test_expr "set variable v_long=-1" "print v_long == 0" "\\$\[0-9\]* = $false" "print v_long == -1" "\\$\[0-9\]* = $true" "print signed long == (minus)"
187test_expr "set variable v_long=-1" "print v_long != 0" "\\$\[0-9\]* = $true" "print v_long != -1" "\\$\[0-9\]* = $false" "print signed long != (minus)"
188test_expr "set variable v_long=-1" "print v_long < 0" "\\$\[0-9\]* = $true" "print v_long < 0x7FFF" "\\$\[0-9\]* = $true" "print signed long < (minus)"
189test_expr "set variable v_long=-1" "print v_long > 0" "\\$\[0-9\]* = $false" "print v_long > 0x7FFF" "\\$\[0-9\]* = $false" "print signed long > (minus)"
c906108c
SS
190#
191# test expressions with "signed long" types
192#
085dd6e6
JM
193test_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 =="
194test_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 !="
195test_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 <"
196test_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 >"
c906108c 197# make long a minus
085dd6e6
JM
198test_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)"
199test_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)"
200test_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)"
201test_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)"
c906108c
SS
202#
203# test expressions with "unsigned long" types
204#
085dd6e6
JM
205test_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 =="
206test_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 !="
207test_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 <"
208test_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 >"
c906108c 209# make long a minus
085dd6e6
JM
210test_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)"
211test_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)"
212test_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)"
213test_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)"
4f823a66
AC
214#
215# Test expressions with casts to a pointer.
216# NB: Some architectures convert a ``NULL'' pointer into
217# something else. Don't simply test for 0.
218#
219test_expr "set variable v_signed_char = 0" "print (void*)v_signed_char" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_char"
220test_expr "set variable v_signed_short = 0" "print (void*)v_signed_short" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_short"
221test_expr "set variable v_signed_int = 0" "print (void*)v_signed_int" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_int"
222test_expr "set variable v_signed_long = 0" "print (void*)v_signed_long" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_long"
223test_expr "set variable v_unsigned_char = 0" "print (void*)v_unsigned_char" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_char"
224test_expr "set variable v_unsigned_short = 0" "print (void*)v_unsigned_short" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_short"
225test_expr "set variable v_unsigned_int = 0" "print (void*)v_unsigned_int" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_int"
226test_expr "set variable v_unsigned_long = 0" "print (void*)v_unsigned_long" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_long"
227#
228# Test expressions with pointers out of range
229#
230# NB: For some architectures, all of sizeof(long),
231# sizeof(long long) and sizeof(void*) are
232# the same size so this test can not work.
233#
234send_gdb "print sizeof (long long) > sizeof (long)\n"
235gdb_expect {
b18bced9 236 -re "\\$\[0-9\]* = $true.*$gdb_prompt" {
4f823a66
AC
237 set ok 1
238 pass "sizeof (long long) > sizeof (long) (true)"
239 }
b18bced9 240 -re "\\$\[0-9\]* = $false.*$gdb_prompt" {
4f823a66
AC
241 set ok 0
242 pass "sizeof (long long) > sizeof (long) (false)"
243 }
244 timeout {
245 set ok 0
246 fail "sizeof (long long) > sizeof (long) (timeout)"
247 }
248}
249if [expr ! $ok] { setup_xfail "*-*-*" }
250gdb_test "print (void*) ((long long) (unsigned long) -1 + 1)" \
251 "warning: value truncated.*" "truncate (void*) 0x00000000ffffffff + 1"
252if [expr ! $ok] { setup_xfail "*-*-*" }
253gdb_test "print (void*) (~((long long)(unsigned long) -1) - 1)" \
254 "warning: value truncated.*" "truncate (void*) 0xffffffff00000000 - 1"