]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/whatis-exp.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis-exp.exp
CommitLineData
6aba47ca 1# Copyright 1998, 1999, 2007 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
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
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.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Elena Zannoni (ezannoni@cygnus.com)
21
22# This file is part of the gdb testsuite
23#
24# tests for whatis command on expressions.
25# used in file eval.c. This flavor of whatis
26# command performs evaluation of expressions w/o actually
27# computing the value, but just the type
28# of the result. It goes through the evaluate_subexp_standard
29# with the EVAL_AVOID_SIDE_EFFECTS flag rather than EVAL_NORMAL
30#
31
32if $tracelevel then {
33 strace $tracelevel
34 }
35
36#
37# test running programs
38#
39set prms_id 0
40set bug_id 0
41
42set testfile "int-type"
43set srcfile ${testfile}.c
44set binfile ${objdir}/${subdir}/${testfile}
fc91c6c2 45if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
b60f0898
JB
46 untested whatis-exp.exp
47 return -1
c906108c
SS
48 }
49
50
51gdb_exit
52gdb_start
53gdb_reinitialize_dir $srcdir/$subdir
54gdb_load ${binfile}
55
56
57#
58# set it up at a breakpoint so we can play with the variable values
59#
60
61if ![runto_main] then {
62 perror "couldn't run to breakpoint"
63 continue
64}
65
66#
67# test expressions with "int" types
68#
69
70gdb_test "set variable x=14" "" "set variable x=14"
71gdb_test "set variable y=2" "" "set variable y=2"
72gdb_test "set variable z=2" "" "set variable z=2"
73gdb_test "set variable w=3" "" "set variable w=3"
74
75send_gdb "print x\n"
76gdb_expect {
77 -re ".*14.*$gdb_prompt $" {
78 pass "print value of x"
79 }
80 -re ".*$gdb_prompt $" { fail "print value of x" }
81 timeout { fail "(timeout) print value of x" }
82 }
83
84
85send_gdb "print y\n"
86gdb_expect {
87 -re ".*2.*$gdb_prompt $" {
88 pass "print value of y"
89 }
90 -re ".*$gdb_prompt $" { fail "print value of y" }
91 timeout { fail "(timeout) print value of y" }
92 }
93
94send_gdb "print z\n"
95gdb_expect {
96 -re ".*2.*$gdb_prompt $" {
97 pass "print value of z"
98 }
99 -re ".*$gdb_prompt $" { fail "print value of z" }
100 timeout { fail "(timeout) print value of z" }
101 }
102
103send_gdb "print w\n"
104gdb_expect {
105 -re ".*3.*$gdb_prompt $" {
106 pass "print value of w"
107 }
108 -re ".*$gdb_prompt $" { fail "print value of w" }
109 timeout { fail "(timeout) print value of w" }
110 }
111
112
113
114send_gdb "whatis x+y\n"
115gdb_expect {
116 -re ".*type = long.*$gdb_prompt $" {
117 pass "whatis value of x+y"
118 }
119 -re ".*$gdb_prompt $" { fail "whatis value of x+y" }
120 timeout { fail "(timeout) whatis value of x+y" }
121 }
122
123send_gdb "whatis x-y\n"
124gdb_expect {
125 -re ".*type = long.*$gdb_prompt $" {
126 pass "whatis value of x-y"
127 }
128 -re ".*$gdb_prompt $" { fail "whatis value of x-y" }
129 timeout { fail "(timeout) whatis value of x-y" }
130 }
131
132send_gdb "whatis x*y\n"
133gdb_expect {
134 -re ".*type = long.*$gdb_prompt $" {
135 pass "whatis value of x*y"
136 }
137 -re ".*$gdb_prompt $" { fail "whatis value of x*y" }
138 timeout { fail "(timeout) whatis value of x*y" }
139 }
140
141send_gdb "whatis x/y\n"
142gdb_expect {
143 -re ".*type = int.*$gdb_prompt $" {
144 pass "whatis value of x/y"
145 }
146 -re ".*$gdb_prompt $" { fail "whatis value of x/y" }
147 timeout { fail "(timeout) whatis value of x/y" }
148 }
149
150send_gdb "whatis x%y\n"
151gdb_expect {
152 -re ".*type = int.*$gdb_prompt $" {
153 pass "whatis value of x%y"
154 }
155 -re ".*$gdb_prompt $" { fail "whatis value of x%y" }
156 timeout { fail "(timeout) whatis value of x%y" }
157 }
158
159
160
161send_gdb "whatis x=y\n"
162gdb_expect {
163 -re ".*type = int.*$gdb_prompt $" {
164 pass "whatis value of x=y"
165 }
166 -re ".*$gdb_prompt $" { fail "whatis value of x=y" }
167 timeout { fail "(timeout) whatis value of x=y" }
168 }
169
170
171send_gdb "whatis x+=2\n"
172gdb_expect {
173 -re ".*type = int.*$gdb_prompt $" {
174 pass "whatis value of x+=2"
175 }
176 -re ".*$gdb_prompt $" { fail "whatis value of x+=2" }
177 timeout { fail "(timeout) whatis value of x+=2" }
178 }
179
180
181send_gdb "whatis ++x\n"
182gdb_expect {
183 -re ".*type = int.*$gdb_prompt $" {
184 pass "whatis value of ++x"
185 }
186 -re ".*$gdb_prompt $" { fail "whatis value of ++x" }
187 timeout { fail "(timeout) whatis value of ++x" }
188 }
189
190send_gdb "whatis --x\n"
191gdb_expect {
192 -re ".*type = int.*$gdb_prompt $" {
193 pass "whatis value of --x"
194 }
195 -re ".*$gdb_prompt $" { fail "whatis value of --x" }
196 timeout { fail "(timeout) whatis value of --x" }
197 }
198
199send_gdb "whatis x++\n"
200gdb_expect {
201 -re ".*type = int.*$gdb_prompt $" {
202 pass "whatis value of x++"
203 }
204 -re ".*$gdb_prompt $" { fail "whatis value of x++" }
205 timeout { fail "(timeout) whatis value of x++" }
206 }
207
208send_gdb "whatis x--\n"
209gdb_expect {
210 -re ".*type = int.*$gdb_prompt $" {
211 pass "whatis value of x--"
212 }
213 -re ".*$gdb_prompt $" { fail "whatis value of x--" }
214 timeout { fail "(timeout) whatis value of x--" }
215 }
216
217gdb_exit
218return 0