Commit | Line | Data |
---|---|---|
4c38e0a4 | 1 | # Copyright 1998, 1999, 2007, 2008, 2009, 2010 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 | ||
28 | if $tracelevel then { | |
29 | strace $tracelevel | |
30 | } | |
31 | ||
32 | # | |
33 | # test running programs | |
34 | # | |
c906108c | 35 | |
aa81e255 JK |
36 | if { [prepare_for_testing whatis-exp.exp whatis-exp int-type.c {debug nowarnings}] } { |
37 | return -1 | |
38 | } | |
c906108c SS |
39 | |
40 | # | |
41 | # set it up at a breakpoint so we can play with the variable values | |
42 | # | |
43 | ||
44 | if ![runto_main] then { | |
45 | perror "couldn't run to breakpoint" | |
46 | continue | |
47 | } | |
48 | ||
49 | # | |
50 | # test expressions with "int" types | |
51 | # | |
52 | ||
53 | gdb_test "set variable x=14" "" "set variable x=14" | |
54 | gdb_test "set variable y=2" "" "set variable y=2" | |
55 | gdb_test "set variable z=2" "" "set variable z=2" | |
56 | gdb_test "set variable w=3" "" "set variable w=3" | |
57 | ||
58 | send_gdb "print x\n" | |
59 | gdb_expect { | |
60 | -re ".*14.*$gdb_prompt $" { | |
61 | pass "print value of x" | |
62 | } | |
63 | -re ".*$gdb_prompt $" { fail "print value of x" } | |
64 | timeout { fail "(timeout) print value of x" } | |
65 | } | |
66 | ||
67 | ||
68 | send_gdb "print y\n" | |
69 | gdb_expect { | |
70 | -re ".*2.*$gdb_prompt $" { | |
71 | pass "print value of y" | |
72 | } | |
73 | -re ".*$gdb_prompt $" { fail "print value of y" } | |
74 | timeout { fail "(timeout) print value of y" } | |
75 | } | |
76 | ||
77 | send_gdb "print z\n" | |
78 | gdb_expect { | |
79 | -re ".*2.*$gdb_prompt $" { | |
80 | pass "print value of z" | |
81 | } | |
82 | -re ".*$gdb_prompt $" { fail "print value of z" } | |
83 | timeout { fail "(timeout) print value of z" } | |
84 | } | |
85 | ||
86 | send_gdb "print w\n" | |
87 | gdb_expect { | |
88 | -re ".*3.*$gdb_prompt $" { | |
89 | pass "print value of w" | |
90 | } | |
91 | -re ".*$gdb_prompt $" { fail "print value of w" } | |
92 | timeout { fail "(timeout) print value of w" } | |
93 | } | |
94 | ||
95 | ||
96 | ||
97 | send_gdb "whatis x+y\n" | |
98 | gdb_expect { | |
301f0ecf | 99 | -re ".*type = int.*$gdb_prompt $" { |
c906108c SS |
100 | pass "whatis value of x+y" |
101 | } | |
102 | -re ".*$gdb_prompt $" { fail "whatis value of x+y" } | |
103 | timeout { fail "(timeout) whatis value of x+y" } | |
104 | } | |
105 | ||
106 | send_gdb "whatis x-y\n" | |
107 | gdb_expect { | |
301f0ecf | 108 | -re ".*type = int.*$gdb_prompt $" { |
c906108c SS |
109 | pass "whatis value of x-y" |
110 | } | |
111 | -re ".*$gdb_prompt $" { fail "whatis value of x-y" } | |
112 | timeout { fail "(timeout) whatis value of x-y" } | |
113 | } | |
114 | ||
115 | send_gdb "whatis x*y\n" | |
116 | gdb_expect { | |
301f0ecf | 117 | -re ".*type = int.*$gdb_prompt $" { |
c906108c SS |
118 | pass "whatis value of x*y" |
119 | } | |
120 | -re ".*$gdb_prompt $" { fail "whatis value of x*y" } | |
121 | timeout { fail "(timeout) whatis value of x*y" } | |
122 | } | |
123 | ||
124 | send_gdb "whatis x/y\n" | |
125 | gdb_expect { | |
126 | -re ".*type = int.*$gdb_prompt $" { | |
127 | pass "whatis value of x/y" | |
128 | } | |
129 | -re ".*$gdb_prompt $" { fail "whatis value of x/y" } | |
130 | timeout { fail "(timeout) whatis value of x/y" } | |
131 | } | |
132 | ||
133 | send_gdb "whatis x%y\n" | |
134 | gdb_expect { | |
135 | -re ".*type = int.*$gdb_prompt $" { | |
136 | pass "whatis value of x%y" | |
137 | } | |
138 | -re ".*$gdb_prompt $" { fail "whatis value of x%y" } | |
139 | timeout { fail "(timeout) whatis value of x%y" } | |
140 | } | |
141 | ||
142 | ||
143 | ||
144 | send_gdb "whatis x=y\n" | |
145 | gdb_expect { | |
146 | -re ".*type = int.*$gdb_prompt $" { | |
147 | pass "whatis value of x=y" | |
148 | } | |
149 | -re ".*$gdb_prompt $" { fail "whatis value of x=y" } | |
150 | timeout { fail "(timeout) whatis value of x=y" } | |
151 | } | |
152 | ||
153 | ||
154 | send_gdb "whatis x+=2\n" | |
155 | gdb_expect { | |
156 | -re ".*type = int.*$gdb_prompt $" { | |
157 | pass "whatis value of x+=2" | |
158 | } | |
159 | -re ".*$gdb_prompt $" { fail "whatis value of x+=2" } | |
160 | timeout { fail "(timeout) whatis value of x+=2" } | |
161 | } | |
162 | ||
163 | ||
164 | send_gdb "whatis ++x\n" | |
165 | gdb_expect { | |
166 | -re ".*type = int.*$gdb_prompt $" { | |
167 | pass "whatis value of ++x" | |
168 | } | |
169 | -re ".*$gdb_prompt $" { fail "whatis value of ++x" } | |
170 | timeout { fail "(timeout) whatis value of ++x" } | |
171 | } | |
172 | ||
173 | send_gdb "whatis --x\n" | |
174 | gdb_expect { | |
175 | -re ".*type = int.*$gdb_prompt $" { | |
176 | pass "whatis value of --x" | |
177 | } | |
178 | -re ".*$gdb_prompt $" { fail "whatis value of --x" } | |
179 | timeout { fail "(timeout) whatis value of --x" } | |
180 | } | |
181 | ||
182 | send_gdb "whatis x++\n" | |
183 | gdb_expect { | |
184 | -re ".*type = int.*$gdb_prompt $" { | |
185 | pass "whatis value of x++" | |
186 | } | |
187 | -re ".*$gdb_prompt $" { fail "whatis value of x++" } | |
188 | timeout { fail "(timeout) whatis value of x++" } | |
189 | } | |
190 | ||
191 | send_gdb "whatis x--\n" | |
192 | gdb_expect { | |
193 | -re ".*type = int.*$gdb_prompt $" { | |
194 | pass "whatis value of x--" | |
195 | } | |
196 | -re ".*$gdb_prompt $" { fail "whatis value of x--" } | |
197 | timeout { fail "(timeout) whatis value of x--" } | |
198 | } | |
199 | ||
200 | gdb_exit | |
201 | return 0 |