]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/whatis-exp.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis-exp.exp
1 # Copyright 1998, 1999, 2007 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 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
32 if $tracelevel then {
33 strace $tracelevel
34 }
35
36 #
37 # test running programs
38 #
39 set prms_id 0
40 set bug_id 0
41
42 set testfile "int-type"
43 set srcfile ${testfile}.c
44 set binfile ${objdir}/${subdir}/${testfile}
45 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
46 untested whatis-exp.exp
47 return -1
48 }
49
50
51 gdb_exit
52 gdb_start
53 gdb_reinitialize_dir $srcdir/$subdir
54 gdb_load ${binfile}
55
56
57 #
58 # set it up at a breakpoint so we can play with the variable values
59 #
60
61 if ![runto_main] then {
62 perror "couldn't run to breakpoint"
63 continue
64 }
65
66 #
67 # test expressions with "int" types
68 #
69
70 gdb_test "set variable x=14" "" "set variable x=14"
71 gdb_test "set variable y=2" "" "set variable y=2"
72 gdb_test "set variable z=2" "" "set variable z=2"
73 gdb_test "set variable w=3" "" "set variable w=3"
74
75 send_gdb "print x\n"
76 gdb_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
85 send_gdb "print y\n"
86 gdb_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
94 send_gdb "print z\n"
95 gdb_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
103 send_gdb "print w\n"
104 gdb_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
114 send_gdb "whatis x+y\n"
115 gdb_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
123 send_gdb "whatis x-y\n"
124 gdb_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
132 send_gdb "whatis x*y\n"
133 gdb_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
141 send_gdb "whatis x/y\n"
142 gdb_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
150 send_gdb "whatis x%y\n"
151 gdb_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
161 send_gdb "whatis x=y\n"
162 gdb_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
171 send_gdb "whatis x+=2\n"
172 gdb_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
181 send_gdb "whatis ++x\n"
182 gdb_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
190 send_gdb "whatis --x\n"
191 gdb_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
199 send_gdb "whatis x++\n"
200 gdb_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
208 send_gdb "whatis x--\n"
209 gdb_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
217 gdb_exit
218 return 0