1 # Copyright 1998, 1999, 2007, 2008, 2009 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
18 # This file is part of the gdb testsuite
20 # tests for whatis command on expressions.
21 # used in file eval.c. This flavor of whatis
22 # command performs evaluation of expressions w/o actually
23 # computing the value, but just the type
24 # of the result. It goes through the evaluate_subexp_standard
25 # with the EVAL_AVOID_SIDE_EFFECTS flag rather than EVAL_NORMAL
33 # test running programs
38 set testfile "int-type"
39 set srcfile ${testfile}.c
40 set binfile ${objdir}/${subdir}/${testfile}
41 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
42 untested whatis-exp.exp
49 gdb_reinitialize_dir $srcdir/$subdir
54 # set it up at a breakpoint so we can play with the variable values
57 if ![runto_main] then {
58 perror "couldn't run to breakpoint"
63 # test expressions with "int" types
66 gdb_test "set variable x=14" "" "set variable x=14"
67 gdb_test "set variable y=2" "" "set variable y=2"
68 gdb_test "set variable z=2" "" "set variable z=2"
69 gdb_test "set variable w=3" "" "set variable w=3"
73 -re ".*14.*$gdb_prompt $" {
74 pass "print value of x"
76 -re ".*$gdb_prompt $" { fail "print value of x" }
77 timeout { fail "(timeout) print value of x" }
83 -re ".*2.*$gdb_prompt $" {
84 pass "print value of y"
86 -re ".*$gdb_prompt $" { fail "print value of y" }
87 timeout { fail "(timeout) print value of y" }
92 -re ".*2.*$gdb_prompt $" {
93 pass "print value of z"
95 -re ".*$gdb_prompt $" { fail "print value of z" }
96 timeout { fail "(timeout) print value of z" }
101 -re ".*3.*$gdb_prompt $" {
102 pass "print value of w"
104 -re ".*$gdb_prompt $" { fail "print value of w" }
105 timeout { fail "(timeout) print value of w" }
110 send_gdb "whatis x+y\n"
112 -re ".*type = int.*$gdb_prompt $" {
113 pass "whatis value of x+y"
115 -re ".*$gdb_prompt $" { fail "whatis value of x+y" }
116 timeout { fail "(timeout) whatis value of x+y" }
119 send_gdb "whatis x-y\n"
121 -re ".*type = int.*$gdb_prompt $" {
122 pass "whatis value of x-y"
124 -re ".*$gdb_prompt $" { fail "whatis value of x-y" }
125 timeout { fail "(timeout) whatis value of x-y" }
128 send_gdb "whatis x*y\n"
130 -re ".*type = int.*$gdb_prompt $" {
131 pass "whatis value of x*y"
133 -re ".*$gdb_prompt $" { fail "whatis value of x*y" }
134 timeout { fail "(timeout) whatis value of x*y" }
137 send_gdb "whatis x/y\n"
139 -re ".*type = int.*$gdb_prompt $" {
140 pass "whatis value of x/y"
142 -re ".*$gdb_prompt $" { fail "whatis value of x/y" }
143 timeout { fail "(timeout) whatis value of x/y" }
146 send_gdb "whatis x%y\n"
148 -re ".*type = int.*$gdb_prompt $" {
149 pass "whatis value of x%y"
151 -re ".*$gdb_prompt $" { fail "whatis value of x%y" }
152 timeout { fail "(timeout) whatis value of x%y" }
157 send_gdb "whatis x=y\n"
159 -re ".*type = int.*$gdb_prompt $" {
160 pass "whatis value of x=y"
162 -re ".*$gdb_prompt $" { fail "whatis value of x=y" }
163 timeout { fail "(timeout) whatis value of x=y" }
167 send_gdb "whatis x+=2\n"
169 -re ".*type = int.*$gdb_prompt $" {
170 pass "whatis value of x+=2"
172 -re ".*$gdb_prompt $" { fail "whatis value of x+=2" }
173 timeout { fail "(timeout) whatis value of x+=2" }
177 send_gdb "whatis ++x\n"
179 -re ".*type = int.*$gdb_prompt $" {
180 pass "whatis value of ++x"
182 -re ".*$gdb_prompt $" { fail "whatis value of ++x" }
183 timeout { fail "(timeout) whatis value of ++x" }
186 send_gdb "whatis --x\n"
188 -re ".*type = int.*$gdb_prompt $" {
189 pass "whatis value of --x"
191 -re ".*$gdb_prompt $" { fail "whatis value of --x" }
192 timeout { fail "(timeout) whatis value of --x" }
195 send_gdb "whatis x++\n"
197 -re ".*type = int.*$gdb_prompt $" {
198 pass "whatis value of x++"
200 -re ".*$gdb_prompt $" { fail "whatis value of x++" }
201 timeout { fail "(timeout) whatis value of x++" }
204 send_gdb "whatis x--\n"
206 -re ".*type = int.*$gdb_prompt $" {
207 pass "whatis value of x--"
209 -re ".*$gdb_prompt $" { fail "whatis value of x--" }
210 timeout { fail "(timeout) whatis value of x--" }