Commit | Line | Data |
---|---|---|
c906108c SS |
1 | # Copyright (C) 1998 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 | ||
21 | # This file is part of the gdb testsuite | |
22 | # file written by Elena Zannoni (ezannoni@cygnus.com) | |
23 | ||
24 | # | |
25 | # tests for expressions with struct/array elements and mixed operator types | |
26 | # with elementary types | |
27 | # | |
28 | ||
29 | if $tracelevel then { | |
30 | strace $tracelevel | |
31 | } | |
32 | ||
33 | # | |
34 | # test running programs | |
35 | # | |
36 | set prms_id 0 | |
37 | set bug_id 0 | |
38 | ||
39 | set testfile "miscexprs" | |
40 | set srcfile ${testfile}.c | |
41 | set binfile ${objdir}/${subdir}/${testfile} | |
42 | ||
43 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { | |
44 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
45 | } | |
46 | ||
085dd6e6 JM |
47 | if [get_compiler_info ${binfile}] { |
48 | return -1; | |
49 | } | |
c906108c SS |
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 | if ![runto_main] then { | |
61 | perror "couldn't run to breakpoint" | |
62 | continue | |
63 | } | |
64 | ||
65 | send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" | |
66 | ||
67 | send_gdb "cont\n" | |
68 | gdb_expect { | |
69 | -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" { | |
70 | send_gdb "up\n" | |
71 | gdb_expect { | |
660fd469 MS |
72 | -re ".*main.*$gdb_prompt $" {} |
73 | -re ".*$gdb_prompt $" { | |
74 | fail "up from marker1" | |
75 | } | |
76 | timeout { fail "up from marker1 (timeout)" } | |
c906108c SS |
77 | } |
78 | } | |
79 | -re "$gdb_prompt $" { fail "continue to marker1" } | |
80 | timeout { fail "(timeout) continue to marker1" } | |
81 | } | |
82 | ||
83 | global hex | |
84 | ||
85 | send_gdb "print &ibig.i\[0\]\n" | |
86 | gdb_expect { | |
87 | -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" { | |
88 | pass "print value of &ibig.i\[0\]" | |
89 | } | |
90 | -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" } | |
91 | timeout { fail "(timeout) print value of &ibig.i\[0\]" } | |
92 | } | |
93 | ||
94 | send_gdb "print &cbig.c\[0\]\n" | |
95 | gdb_expect { | |
96 | -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" { | |
97 | pass "print value of &cbig.c\[0\]" | |
98 | } | |
085dd6e6 JM |
99 | -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" { |
100 | pass "print value of &cbig.c\[0\]" | |
101 | } | |
c906108c SS |
102 | -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" } |
103 | timeout { fail "(timeout) print value of &cbig.c\[0\]" } | |
104 | } | |
105 | ||
106 | send_gdb "print &fbig.f\[0\]\n" | |
107 | gdb_expect { | |
108 | -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" { | |
109 | pass "print value of &fbig.f\[0\]" | |
110 | } | |
111 | -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" } | |
112 | timeout { fail "(timeout) print value of &fbig.f\[0\]" } | |
113 | } | |
114 | ||
115 | send_gdb "print &dbig.d\[0\]\n" | |
116 | gdb_expect { | |
117 | -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" { | |
118 | pass "print value of &dbig.d\[0\]" | |
119 | } | |
120 | -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" } | |
121 | timeout { fail "(timeout) print value of &dbig.d\[0\]" } | |
122 | } | |
123 | ||
124 | send_gdb "print &sbig.s\[0\]\n" | |
125 | gdb_expect { | |
7a292a7a SS |
126 | -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" { |
127 | pass "print value of &sbig.s\[0\]" | |
128 | } | |
c906108c SS |
129 | -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" { |
130 | pass "print value of &sbig.s\[0\]" | |
7a292a7a | 131 | } |
c906108c SS |
132 | -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" } |
133 | timeout { fail "(timeout) print value of &sbig.s\[0\]" } | |
134 | } | |
135 | ||
136 | send_gdb "print &lbig.l\[0\]\n" | |
137 | gdb_expect { | |
7a292a7a SS |
138 | -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" { |
139 | pass "print value of &lbig.l\[0\]" | |
140 | } | |
c906108c SS |
141 | -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" { |
142 | pass "print value of &lbig.l\[0\]" | |
7a292a7a | 143 | } |
c906108c SS |
144 | -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" } |
145 | timeout { fail "(timeout) print value of &lbig.l\[0\]" } | |
146 | } | |
147 | ||
148 | ||
149 | send_gdb "print ibig.i\[100\] | 1\n" | |
150 | gdb_expect { | |
151 | -re ".\[0-9\]* = 5.*$gdb_prompt $" { | |
152 | pass "print value of ibig.i\[100\] | 1" | |
153 | } | |
154 | -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" } | |
155 | timeout { fail "(timeout) print value of ibig.i\[100\] | 1" } | |
156 | } | |
157 | ||
158 | ||
159 | send_gdb "print sbig.s\[90\] & 127\n" | |
160 | gdb_expect { | |
161 | -re ".\[0-9\]* = 127.*$gdb_prompt $" { | |
162 | pass "print value of sbig.s\[90\] & 127" | |
163 | } | |
164 | -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" } | |
165 | timeout { fail "(timeout) print value of sbig.s\[90\] & 127" } | |
166 | } | |
167 | ||
168 | send_gdb "print !ibig.i\[100\]\n" | |
169 | gdb_expect { | |
085dd6e6 | 170 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
171 | pass "print value of !ibig.i\[100\]" |
172 | } | |
173 | -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" } | |
174 | timeout { fail "(timeout) print value of !ibig.i\[100\]" } | |
175 | } | |
176 | ||
177 | send_gdb "print !sbig.s\[90\]\n" | |
178 | gdb_expect { | |
085dd6e6 | 179 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
180 | pass "print value of !sbig.s\[90\]" |
181 | } | |
182 | -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" } | |
183 | timeout { fail "(timeout) print value of !sbig.s\[90\]" } | |
184 | } | |
185 | ||
186 | ||
187 | send_gdb "print !fbig.f\[100\]\n" | |
188 | gdb_expect { | |
085dd6e6 | 189 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
190 | pass "print value of !ibig.i\[100\]" |
191 | } | |
192 | -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" } | |
193 | timeout { fail "(timeout) print value of !ibig.i\[100\]" } | |
194 | } | |
195 | ||
196 | send_gdb "print !dbig.d\[202\]\n" | |
197 | gdb_expect { | |
085dd6e6 | 198 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
199 | pass "print value of !ibig.i\[100\]" |
200 | } | |
201 | -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" } | |
202 | timeout { fail "(timeout) print value of !ibig.i\[100\]" } | |
203 | } | |
204 | ||
205 | ||
206 | ||
207 | send_gdb "print sbig.s\[90\] * 10\n" | |
208 | gdb_expect { | |
209 | -re ".\[0-9\]* = 2550.*$gdb_prompt $" { | |
210 | pass "print value of !sbig.s\[90\] * 10" | |
211 | } | |
212 | -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" } | |
213 | timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" } | |
214 | } | |
215 | ||
216 | send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n" | |
217 | gdb_expect { | |
218 | -re ".\[0-9\]* = 1275.*$gdb_prompt $" { | |
219 | pass "print value of ibig.i\[100\] * sbig.s\[90\]" | |
220 | } | |
221 | -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" } | |
222 | timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" } | |
223 | } | |
224 | ||
225 | send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n" | |
226 | gdb_expect { | |
227 | -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" { | |
228 | pass "print value of fbig.f\[100\] * dbig.d\[202\]" | |
229 | } | |
230 | -re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" } | |
231 | timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" } | |
232 | } | |
233 | ||
234 | send_gdb "print !(sbig.s\[90\] * 2)\n" | |
235 | gdb_expect { | |
085dd6e6 | 236 | -re ".\[0-9\]* = $false.*$gdb_prompt $" { |
c906108c SS |
237 | pass "print value of !(sbig.s\[90\] * 2)" |
238 | } | |
239 | -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" } | |
240 | timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" } | |
241 | } | |
242 | ||
243 | ||
244 | send_gdb "print sizeof(sbig)\n" | |
245 | gdb_expect { | |
246 | -re ".\[0-9\]* = 800.*$gdb_prompt $" { | |
247 | pass "print value of sizeof(sbig)" | |
248 | } | |
249 | -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" } | |
250 | timeout { fail "(timeout) print value of sizeof(sbig)" } | |
251 | } | |
252 | ||
253 | ||
254 | send_gdb "print sizeof(cbig)\n" | |
255 | gdb_expect { | |
256 | -re ".\[0-9\]* = 100.*$gdb_prompt $" { | |
257 | pass "print value of sizeof(cbig)" | |
258 | } | |
259 | -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" } | |
260 | timeout { fail "(timeout) print value of sizeof(cbig)" } | |
261 | } | |
262 | ||
263 | ||
b84b7669 | 264 | send_gdb "print sizeof(lbig)/sizeof(long)\n" |
085dd6e6 | 265 | gdb_expect { |
b84b7669 MS |
266 | -re ".\[0-9\]* = 900.*$gdb_prompt $" { |
267 | pass "print value of sizeof(lbig)/sizeof(long)" | |
085dd6e6 | 268 | } |
b84b7669 MS |
269 | -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" } |
270 | timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" } | |
085dd6e6 | 271 | } |
c906108c SS |
272 | |
273 | send_gdb "print ibig.i\[100\] << 2\n" | |
274 | gdb_expect { | |
275 | -re ".\[0-9\]* = 20.*$gdb_prompt $" { | |
276 | pass "print value of ibig.i\[100\] << 2" | |
277 | } | |
278 | -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" } | |
279 | timeout { fail "(timeout) print value of ibig.i\[100\] << 2" } | |
280 | } | |
281 | ||
282 | send_gdb "print sbig.s\[90\] >> 4\n" | |
283 | gdb_expect { | |
284 | -re ".\[0-9\]* = 15.*$gdb_prompt $" { | |
285 | pass "print value of sbig.s\[90\] >> 4" | |
286 | } | |
287 | -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" } | |
288 | timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" } | |
289 | } | |
290 | ||
291 | send_gdb "print lbig.l\[333\] >> 6\n" | |
292 | gdb_expect { | |
293 | -re ".\[0-9\]* = 15624999.*$gdb_prompt $" { | |
294 | pass "print value of lbig.l\[333\] >> 6" | |
295 | } | |
296 | -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" } | |
297 | timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" } | |
298 | } |