Forgot to add these files. They are referent to the last commit,
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis-exp.exp
1 # Copyright 1998, 1999, 2007, 2008, 2009 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
15
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
28 if $tracelevel then {
29 strace $tracelevel
30 }
31
32 #
33 # test running programs
34 #
35 set prms_id 0
36 set bug_id 0
37
38 if { [prepare_for_testing whatis-exp.exp whatis-exp int-type.c {debug nowarnings}] } {
39 return -1
40 }
41
42 #
43 # set it up at a breakpoint so we can play with the variable values
44 #
45
46 if ![runto_main] then {
47 perror "couldn't run to breakpoint"
48 continue
49 }
50
51 #
52 # test expressions with "int" types
53 #
54
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"
59
60 send_gdb "print x\n"
61 gdb_expect {
62 -re ".*14.*$gdb_prompt $" {
63 pass "print value of x"
64 }
65 -re ".*$gdb_prompt $" { fail "print value of x" }
66 timeout { fail "(timeout) print value of x" }
67 }
68
69
70 send_gdb "print y\n"
71 gdb_expect {
72 -re ".*2.*$gdb_prompt $" {
73 pass "print value of y"
74 }
75 -re ".*$gdb_prompt $" { fail "print value of y" }
76 timeout { fail "(timeout) print value of y" }
77 }
78
79 send_gdb "print z\n"
80 gdb_expect {
81 -re ".*2.*$gdb_prompt $" {
82 pass "print value of z"
83 }
84 -re ".*$gdb_prompt $" { fail "print value of z" }
85 timeout { fail "(timeout) print value of z" }
86 }
87
88 send_gdb "print w\n"
89 gdb_expect {
90 -re ".*3.*$gdb_prompt $" {
91 pass "print value of w"
92 }
93 -re ".*$gdb_prompt $" { fail "print value of w" }
94 timeout { fail "(timeout) print value of w" }
95 }
96
97
98
99 send_gdb "whatis x+y\n"
100 gdb_expect {
101 -re ".*type = int.*$gdb_prompt $" {
102 pass "whatis value of x+y"
103 }
104 -re ".*$gdb_prompt $" { fail "whatis value of x+y" }
105 timeout { fail "(timeout) whatis value of x+y" }
106 }
107
108 send_gdb "whatis x-y\n"
109 gdb_expect {
110 -re ".*type = int.*$gdb_prompt $" {
111 pass "whatis value of x-y"
112 }
113 -re ".*$gdb_prompt $" { fail "whatis value of x-y" }
114 timeout { fail "(timeout) whatis value of x-y" }
115 }
116
117 send_gdb "whatis x*y\n"
118 gdb_expect {
119 -re ".*type = int.*$gdb_prompt $" {
120 pass "whatis value of x*y"
121 }
122 -re ".*$gdb_prompt $" { fail "whatis value of x*y" }
123 timeout { fail "(timeout) whatis value of x*y" }
124 }
125
126 send_gdb "whatis x/y\n"
127 gdb_expect {
128 -re ".*type = int.*$gdb_prompt $" {
129 pass "whatis value of x/y"
130 }
131 -re ".*$gdb_prompt $" { fail "whatis value of x/y" }
132 timeout { fail "(timeout) whatis value of x/y" }
133 }
134
135 send_gdb "whatis x%y\n"
136 gdb_expect {
137 -re ".*type = int.*$gdb_prompt $" {
138 pass "whatis value of x%y"
139 }
140 -re ".*$gdb_prompt $" { fail "whatis value of x%y" }
141 timeout { fail "(timeout) whatis value of x%y" }
142 }
143
144
145
146 send_gdb "whatis x=y\n"
147 gdb_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 send_gdb "whatis x+=2\n"
157 gdb_expect {
158 -re ".*type = int.*$gdb_prompt $" {
159 pass "whatis value of x+=2"
160 }
161 -re ".*$gdb_prompt $" { fail "whatis value of x+=2" }
162 timeout { fail "(timeout) whatis value of x+=2" }
163 }
164
165
166 send_gdb "whatis ++x\n"
167 gdb_expect {
168 -re ".*type = int.*$gdb_prompt $" {
169 pass "whatis value of ++x"
170 }
171 -re ".*$gdb_prompt $" { fail "whatis value of ++x" }
172 timeout { fail "(timeout) whatis value of ++x" }
173 }
174
175 send_gdb "whatis --x\n"
176 gdb_expect {
177 -re ".*type = int.*$gdb_prompt $" {
178 pass "whatis value of --x"
179 }
180 -re ".*$gdb_prompt $" { fail "whatis value of --x" }
181 timeout { fail "(timeout) whatis value of --x" }
182 }
183
184 send_gdb "whatis x++\n"
185 gdb_expect {
186 -re ".*type = int.*$gdb_prompt $" {
187 pass "whatis value of x++"
188 }
189 -re ".*$gdb_prompt $" { fail "whatis value of x++" }
190 timeout { fail "(timeout) whatis value of x++" }
191 }
192
193 send_gdb "whatis x--\n"
194 gdb_expect {
195 -re ".*type = int.*$gdb_prompt $" {
196 pass "whatis value of x--"
197 }
198 -re ".*$gdb_prompt $" { fail "whatis value of x--" }
199 timeout { fail "(timeout) whatis value of x--" }
200 }
201
202 gdb_exit
203 return 0
This page took 0.035911 seconds and 4 git commands to generate.