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 if { [prepare_for_testing whatis-exp.exp whatis-exp int-type.c {debug nowarnings}] } {
43 # set it up at a breakpoint so we can play with the variable values
46 if ![runto_main] then {
47 perror "couldn't run to breakpoint"
52 # test expressions with "int" types
55 gdb_test "set variable x=14" "" "set variable x=14"
56 gdb_test "set variable y=2" "" "set variable y=2"
57 gdb_test "set variable z=2" "" "set variable z=2"
58 gdb_test "set variable w=3" "" "set variable w=3"
62 -re ".*14.*$gdb_prompt $" {
63 pass "print value of x"
65 -re ".*$gdb_prompt $" { fail "print value of x" }
66 timeout { fail "(timeout) print value of x" }
72 -re ".*2.*$gdb_prompt $" {
73 pass "print value of y"
75 -re ".*$gdb_prompt $" { fail "print value of y" }
76 timeout { fail "(timeout) print value of y" }
81 -re ".*2.*$gdb_prompt $" {
82 pass "print value of z"
84 -re ".*$gdb_prompt $" { fail "print value of z" }
85 timeout { fail "(timeout) print value of z" }
90 -re ".*3.*$gdb_prompt $" {
91 pass "print value of w"
93 -re ".*$gdb_prompt $" { fail "print value of w" }
94 timeout { fail "(timeout) print value of w" }
99 send_gdb "whatis x+y\n"
101 -re ".*type = int.*$gdb_prompt $" {
102 pass "whatis value of x+y"
104 -re ".*$gdb_prompt $" { fail "whatis value of x+y" }
105 timeout { fail "(timeout) whatis value of x+y" }
108 send_gdb "whatis x-y\n"
110 -re ".*type = int.*$gdb_prompt $" {
111 pass "whatis value of x-y"
113 -re ".*$gdb_prompt $" { fail "whatis value of x-y" }
114 timeout { fail "(timeout) whatis value of x-y" }
117 send_gdb "whatis x*y\n"
119 -re ".*type = int.*$gdb_prompt $" {
120 pass "whatis value of x*y"
122 -re ".*$gdb_prompt $" { fail "whatis value of x*y" }
123 timeout { fail "(timeout) whatis value of x*y" }
126 send_gdb "whatis x/y\n"
128 -re ".*type = int.*$gdb_prompt $" {
129 pass "whatis value of x/y"
131 -re ".*$gdb_prompt $" { fail "whatis value of x/y" }
132 timeout { fail "(timeout) whatis value of x/y" }
135 send_gdb "whatis x%y\n"
137 -re ".*type = int.*$gdb_prompt $" {
138 pass "whatis value of x%y"
140 -re ".*$gdb_prompt $" { fail "whatis value of x%y" }
141 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" }
156 send_gdb "whatis x+=2\n"
158 -re ".*type = int.*$gdb_prompt $" {
159 pass "whatis value of x+=2"
161 -re ".*$gdb_prompt $" { fail "whatis value of x+=2" }
162 timeout { fail "(timeout) whatis value of x+=2" }
166 send_gdb "whatis ++x\n"
168 -re ".*type = int.*$gdb_prompt $" {
169 pass "whatis value of ++x"
171 -re ".*$gdb_prompt $" { fail "whatis value of ++x" }
172 timeout { fail "(timeout) whatis value of ++x" }
175 send_gdb "whatis --x\n"
177 -re ".*type = int.*$gdb_prompt $" {
178 pass "whatis value of --x"
180 -re ".*$gdb_prompt $" { fail "whatis value of --x" }
181 timeout { fail "(timeout) whatis value of --x" }
184 send_gdb "whatis x++\n"
186 -re ".*type = int.*$gdb_prompt $" {
187 pass "whatis value of x++"
189 -re ".*$gdb_prompt $" { fail "whatis value of x++" }
190 timeout { fail "(timeout) whatis value of x++" }
193 send_gdb "whatis x--\n"
195 -re ".*type = int.*$gdb_prompt $" {
196 pass "whatis value of x--"
198 -re ".*$gdb_prompt $" { fail "whatis value of x--" }
199 timeout { fail "(timeout) whatis value of x--" }