* gdb.arch/i386-prologue.exp (skip_breakpoint): New function. Use
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis-exp.exp
CommitLineData
b6ba6518 1# Copyright 1998, 1999 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}
45if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
46 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
47 }
48
49
50gdb_exit
51gdb_start
52gdb_reinitialize_dir $srcdir/$subdir
53gdb_load ${binfile}
54
55
56#
57# set it up at a breakpoint so we can play with the variable values
58#
59
60if ![runto_main] then {
61 perror "couldn't run to breakpoint"
62 continue
63}
64
65#
66# test expressions with "int" types
67#
68
69gdb_test "set variable x=14" "" "set variable x=14"
70gdb_test "set variable y=2" "" "set variable y=2"
71gdb_test "set variable z=2" "" "set variable z=2"
72gdb_test "set variable w=3" "" "set variable w=3"
73
74send_gdb "print x\n"
75gdb_expect {
76 -re ".*14.*$gdb_prompt $" {
77 pass "print value of x"
78 }
79 -re ".*$gdb_prompt $" { fail "print value of x" }
80 timeout { fail "(timeout) print value of x" }
81 }
82
83
84send_gdb "print y\n"
85gdb_expect {
86 -re ".*2.*$gdb_prompt $" {
87 pass "print value of y"
88 }
89 -re ".*$gdb_prompt $" { fail "print value of y" }
90 timeout { fail "(timeout) print value of y" }
91 }
92
93send_gdb "print z\n"
94gdb_expect {
95 -re ".*2.*$gdb_prompt $" {
96 pass "print value of z"
97 }
98 -re ".*$gdb_prompt $" { fail "print value of z" }
99 timeout { fail "(timeout) print value of z" }
100 }
101
102send_gdb "print w\n"
103gdb_expect {
104 -re ".*3.*$gdb_prompt $" {
105 pass "print value of w"
106 }
107 -re ".*$gdb_prompt $" { fail "print value of w" }
108 timeout { fail "(timeout) print value of w" }
109 }
110
111
112
113send_gdb "whatis x+y\n"
114gdb_expect {
115 -re ".*type = long.*$gdb_prompt $" {
116 pass "whatis value of x+y"
117 }
118 -re ".*$gdb_prompt $" { fail "whatis value of x+y" }
119 timeout { fail "(timeout) whatis value of x+y" }
120 }
121
122send_gdb "whatis x-y\n"
123gdb_expect {
124 -re ".*type = long.*$gdb_prompt $" {
125 pass "whatis value of x-y"
126 }
127 -re ".*$gdb_prompt $" { fail "whatis value of x-y" }
128 timeout { fail "(timeout) whatis value of x-y" }
129 }
130
131send_gdb "whatis x*y\n"
132gdb_expect {
133 -re ".*type = long.*$gdb_prompt $" {
134 pass "whatis value of x*y"
135 }
136 -re ".*$gdb_prompt $" { fail "whatis value of x*y" }
137 timeout { fail "(timeout) whatis value of x*y" }
138 }
139
140send_gdb "whatis x/y\n"
141gdb_expect {
142 -re ".*type = int.*$gdb_prompt $" {
143 pass "whatis value of x/y"
144 }
145 -re ".*$gdb_prompt $" { fail "whatis value of x/y" }
146 timeout { fail "(timeout) whatis value of x/y" }
147 }
148
149send_gdb "whatis x%y\n"
150gdb_expect {
151 -re ".*type = int.*$gdb_prompt $" {
152 pass "whatis value of x%y"
153 }
154 -re ".*$gdb_prompt $" { fail "whatis value of x%y" }
155 timeout { fail "(timeout) whatis value of x%y" }
156 }
157
158
159
160send_gdb "whatis x=y\n"
161gdb_expect {
162 -re ".*type = int.*$gdb_prompt $" {
163 pass "whatis value of x=y"
164 }
165 -re ".*$gdb_prompt $" { fail "whatis value of x=y" }
166 timeout { fail "(timeout) whatis value of x=y" }
167 }
168
169
170send_gdb "whatis x+=2\n"
171gdb_expect {
172 -re ".*type = int.*$gdb_prompt $" {
173 pass "whatis value of x+=2"
174 }
175 -re ".*$gdb_prompt $" { fail "whatis value of x+=2" }
176 timeout { fail "(timeout) whatis value of x+=2" }
177 }
178
179
180send_gdb "whatis ++x\n"
181gdb_expect {
182 -re ".*type = int.*$gdb_prompt $" {
183 pass "whatis value of ++x"
184 }
185 -re ".*$gdb_prompt $" { fail "whatis value of ++x" }
186 timeout { fail "(timeout) whatis value of ++x" }
187 }
188
189send_gdb "whatis --x\n"
190gdb_expect {
191 -re ".*type = int.*$gdb_prompt $" {
192 pass "whatis value of --x"
193 }
194 -re ".*$gdb_prompt $" { fail "whatis value of --x" }
195 timeout { fail "(timeout) whatis value of --x" }
196 }
197
198send_gdb "whatis x++\n"
199gdb_expect {
200 -re ".*type = int.*$gdb_prompt $" {
201 pass "whatis value of x++"
202 }
203 -re ".*$gdb_prompt $" { fail "whatis value of x++" }
204 timeout { fail "(timeout) whatis value of x++" }
205 }
206
207send_gdb "whatis x--\n"
208gdb_expect {
209 -re ".*type = int.*$gdb_prompt $" {
210 pass "whatis value of x--"
211 }
212 -re ".*$gdb_prompt $" { fail "whatis value of x--" }
213 timeout { fail "(timeout) whatis value of x--" }
214 }
215
216gdb_exit
217return 0
This page took 0.460271 seconds and 4 git commands to generate.