Fix a typo.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis-exp.exp
CommitLineData
0fb0cc75 1# Copyright 1998, 1999, 2007, 2008, 2009 Free Software Foundation, Inc.
c906108c
SS
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 15
c906108c
SS
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 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
26#
27
28if $tracelevel then {
29 strace $tracelevel
30 }
31
32#
33# test running programs
34#
35set prms_id 0
36set bug_id 0
37
38set testfile "int-type"
39set srcfile ${testfile}.c
40set binfile ${objdir}/${subdir}/${testfile}
fc91c6c2 41if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
b60f0898
JB
42 untested whatis-exp.exp
43 return -1
c906108c
SS
44 }
45
46
47gdb_exit
48gdb_start
49gdb_reinitialize_dir $srcdir/$subdir
50gdb_load ${binfile}
51
52
53#
54# set it up at a breakpoint so we can play with the variable values
55#
56
57if ![runto_main] then {
58 perror "couldn't run to breakpoint"
59 continue
60}
61
62#
63# test expressions with "int" types
64#
65
66gdb_test "set variable x=14" "" "set variable x=14"
67gdb_test "set variable y=2" "" "set variable y=2"
68gdb_test "set variable z=2" "" "set variable z=2"
69gdb_test "set variable w=3" "" "set variable w=3"
70
71send_gdb "print x\n"
72gdb_expect {
73 -re ".*14.*$gdb_prompt $" {
74 pass "print value of x"
75 }
76 -re ".*$gdb_prompt $" { fail "print value of x" }
77 timeout { fail "(timeout) print value of x" }
78 }
79
80
81send_gdb "print y\n"
82gdb_expect {
83 -re ".*2.*$gdb_prompt $" {
84 pass "print value of y"
85 }
86 -re ".*$gdb_prompt $" { fail "print value of y" }
87 timeout { fail "(timeout) print value of y" }
88 }
89
90send_gdb "print z\n"
91gdb_expect {
92 -re ".*2.*$gdb_prompt $" {
93 pass "print value of z"
94 }
95 -re ".*$gdb_prompt $" { fail "print value of z" }
96 timeout { fail "(timeout) print value of z" }
97 }
98
99send_gdb "print w\n"
100gdb_expect {
101 -re ".*3.*$gdb_prompt $" {
102 pass "print value of w"
103 }
104 -re ".*$gdb_prompt $" { fail "print value of w" }
105 timeout { fail "(timeout) print value of w" }
106 }
107
108
109
110send_gdb "whatis x+y\n"
111gdb_expect {
301f0ecf 112 -re ".*type = int.*$gdb_prompt $" {
c906108c
SS
113 pass "whatis value of x+y"
114 }
115 -re ".*$gdb_prompt $" { fail "whatis value of x+y" }
116 timeout { fail "(timeout) whatis value of x+y" }
117 }
118
119send_gdb "whatis x-y\n"
120gdb_expect {
301f0ecf 121 -re ".*type = int.*$gdb_prompt $" {
c906108c
SS
122 pass "whatis value of x-y"
123 }
124 -re ".*$gdb_prompt $" { fail "whatis value of x-y" }
125 timeout { fail "(timeout) whatis value of x-y" }
126 }
127
128send_gdb "whatis x*y\n"
129gdb_expect {
301f0ecf 130 -re ".*type = int.*$gdb_prompt $" {
c906108c
SS
131 pass "whatis value of x*y"
132 }
133 -re ".*$gdb_prompt $" { fail "whatis value of x*y" }
134 timeout { fail "(timeout) whatis value of x*y" }
135 }
136
137send_gdb "whatis x/y\n"
138gdb_expect {
139 -re ".*type = int.*$gdb_prompt $" {
140 pass "whatis value of x/y"
141 }
142 -re ".*$gdb_prompt $" { fail "whatis value of x/y" }
143 timeout { fail "(timeout) whatis value of x/y" }
144 }
145
146send_gdb "whatis x%y\n"
147gdb_expect {
148 -re ".*type = int.*$gdb_prompt $" {
149 pass "whatis value of x%y"
150 }
151 -re ".*$gdb_prompt $" { fail "whatis value of x%y" }
152 timeout { fail "(timeout) whatis value of x%y" }
153 }
154
155
156
157send_gdb "whatis x=y\n"
158gdb_expect {
159 -re ".*type = int.*$gdb_prompt $" {
160 pass "whatis value of x=y"
161 }
162 -re ".*$gdb_prompt $" { fail "whatis value of x=y" }
163 timeout { fail "(timeout) whatis value of x=y" }
164 }
165
166
167send_gdb "whatis x+=2\n"
168gdb_expect {
169 -re ".*type = int.*$gdb_prompt $" {
170 pass "whatis value of x+=2"
171 }
172 -re ".*$gdb_prompt $" { fail "whatis value of x+=2" }
173 timeout { fail "(timeout) whatis value of x+=2" }
174 }
175
176
177send_gdb "whatis ++x\n"
178gdb_expect {
179 -re ".*type = int.*$gdb_prompt $" {
180 pass "whatis value of ++x"
181 }
182 -re ".*$gdb_prompt $" { fail "whatis value of ++x" }
183 timeout { fail "(timeout) whatis value of ++x" }
184 }
185
186send_gdb "whatis --x\n"
187gdb_expect {
188 -re ".*type = int.*$gdb_prompt $" {
189 pass "whatis value of --x"
190 }
191 -re ".*$gdb_prompt $" { fail "whatis value of --x" }
192 timeout { fail "(timeout) whatis value of --x" }
193 }
194
195send_gdb "whatis x++\n"
196gdb_expect {
197 -re ".*type = int.*$gdb_prompt $" {
198 pass "whatis value of x++"
199 }
200 -re ".*$gdb_prompt $" { fail "whatis value of x++" }
201 timeout { fail "(timeout) whatis value of x++" }
202 }
203
204send_gdb "whatis x--\n"
205gdb_expect {
206 -re ".*type = int.*$gdb_prompt $" {
207 pass "whatis value of x--"
208 }
209 -re ".*$gdb_prompt $" { fail "whatis value of x--" }
210 timeout { fail "(timeout) whatis value of x--" }
211 }
212
213gdb_exit
214return 0
This page took 1.165412 seconds and 4 git commands to generate.