1 |
24 |
jeremybenn |
# Copyright 1998, 1999, 2000, 2007, 2008 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 .
|
15 |
|
|
|
16 |
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
17 |
|
|
# bug-gdb@prep.ai.mit.edu
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
# This file is part of the gdb testsuite
|
21 |
|
|
# file written by Elena Zannoni (ezannoni@cygnus.com)
|
22 |
|
|
|
23 |
|
|
#
|
24 |
|
|
# tests for expressions with struct/array elements and mixed operator types
|
25 |
|
|
# with elementary types
|
26 |
|
|
#
|
27 |
|
|
|
28 |
|
|
if $tracelevel then {
|
29 |
|
|
strace $tracelevel
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
# By default, the datastructures are allocated on the stack. For targets
|
33 |
|
|
# with very small stack, that will not work. In that case, just set
|
34 |
|
|
# storage to `-DSTORAGE=static' which changes the datastructures to be
|
35 |
|
|
# allocated in data segment.
|
36 |
|
|
set storage "-DSTORAGE="
|
37 |
|
|
if [target_info exists gdb,small_stack_section] {
|
38 |
|
|
set storage "-DSTORAGE=static"
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
set additional_flags "additional_flags=${storage}"
|
42 |
|
|
|
43 |
|
|
#
|
44 |
|
|
# test running programs
|
45 |
|
|
#
|
46 |
|
|
set prms_id 0
|
47 |
|
|
set bug_id 0
|
48 |
|
|
|
49 |
|
|
set testfile "miscexprs"
|
50 |
|
|
set srcfile ${testfile}.c
|
51 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
52 |
|
|
|
53 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } {
|
54 |
|
|
untested miscexprs.exp
|
55 |
|
|
return -1
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
if [get_compiler_info ${binfile}] {
|
59 |
|
|
return -1;
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
gdb_exit
|
63 |
|
|
gdb_start
|
64 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
65 |
|
|
gdb_load ${binfile}
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
#
|
69 |
|
|
# set it up at a breakpoint so we can play with the variable values
|
70 |
|
|
#
|
71 |
|
|
if ![runto_main] then {
|
72 |
|
|
perror "couldn't run to breakpoint"
|
73 |
|
|
continue
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
|
77 |
|
|
|
78 |
|
|
send_gdb "cont\n"
|
79 |
|
|
gdb_expect {
|
80 |
|
|
-re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
|
81 |
|
|
send_gdb "up\n"
|
82 |
|
|
gdb_expect {
|
83 |
|
|
-re ".*main.*$gdb_prompt $" {
|
84 |
|
|
pass "up from marker1"
|
85 |
|
|
}
|
86 |
|
|
-re ".*$gdb_prompt $" {
|
87 |
|
|
fail "up from marker1"
|
88 |
|
|
}
|
89 |
|
|
timeout { fail "up from marker1 (timeout)" }
|
90 |
|
|
}
|
91 |
|
|
}
|
92 |
|
|
-re "$gdb_prompt $" { fail "continue to marker1" }
|
93 |
|
|
timeout { fail "(timeout) continue to marker1" }
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
global hex
|
97 |
|
|
|
98 |
|
|
send_gdb "print &ibig.i\[0\]\n"
|
99 |
|
|
gdb_expect {
|
100 |
|
|
-re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" {
|
101 |
|
|
pass "print value of &ibig.i\[0\]"
|
102 |
|
|
}
|
103 |
|
|
-re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" }
|
104 |
|
|
timeout { fail "(timeout) print value of &ibig.i\[0\]" }
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
send_gdb "print &cbig.c\[0\]\n"
|
108 |
|
|
gdb_expect {
|
109 |
|
|
-re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
|
110 |
|
|
pass "print value of &cbig.c\[0\]"
|
111 |
|
|
}
|
112 |
|
|
-re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
|
113 |
|
|
pass "print value of &cbig.c\[0\]"
|
114 |
|
|
}
|
115 |
|
|
-re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
|
116 |
|
|
timeout { fail "(timeout) print value of &cbig.c\[0\]" }
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
send_gdb "print &fbig.f\[0\]\n"
|
120 |
|
|
gdb_expect {
|
121 |
|
|
-re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" {
|
122 |
|
|
pass "print value of &fbig.f\[0\]"
|
123 |
|
|
}
|
124 |
|
|
-re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" }
|
125 |
|
|
timeout { fail "(timeout) print value of &fbig.f\[0\]" }
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
send_gdb "print &dbig.d\[0\]\n"
|
129 |
|
|
gdb_expect {
|
130 |
|
|
-re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" {
|
131 |
|
|
pass "print value of &dbig.d\[0\]"
|
132 |
|
|
}
|
133 |
|
|
-re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" }
|
134 |
|
|
timeout { fail "(timeout) print value of &dbig.d\[0\]" }
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
send_gdb "print &sbig.s\[0\]\n"
|
138 |
|
|
gdb_expect {
|
139 |
|
|
-re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
|
140 |
|
|
pass "print value of &sbig.s\[0\]"
|
141 |
|
|
}
|
142 |
|
|
-re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
|
143 |
|
|
pass "print value of &sbig.s\[0\]"
|
144 |
|
|
}
|
145 |
|
|
-re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
|
146 |
|
|
timeout { fail "(timeout) print value of &sbig.s\[0\]" }
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
send_gdb "print &lbig.l\[0\]\n"
|
150 |
|
|
gdb_expect {
|
151 |
|
|
-re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
|
152 |
|
|
pass "print value of &lbig.l\[0\]"
|
153 |
|
|
}
|
154 |
|
|
-re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
|
155 |
|
|
pass "print value of &lbig.l\[0\]"
|
156 |
|
|
}
|
157 |
|
|
-re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
|
158 |
|
|
timeout { fail "(timeout) print value of &lbig.l\[0\]" }
|
159 |
|
|
}
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
send_gdb "print ibig.i\[100\] | 1\n"
|
163 |
|
|
gdb_expect {
|
164 |
|
|
-re ".\[0-9\]* = 5.*$gdb_prompt $" {
|
165 |
|
|
pass "print value of ibig.i\[100\] | 1"
|
166 |
|
|
}
|
167 |
|
|
-re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" }
|
168 |
|
|
timeout { fail "(timeout) print value of ibig.i\[100\] | 1" }
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
send_gdb "print sbig.s\[90\] & 127\n"
|
173 |
|
|
gdb_expect {
|
174 |
|
|
-re ".\[0-9\]* = 127.*$gdb_prompt $" {
|
175 |
|
|
pass "print value of sbig.s\[90\] & 127"
|
176 |
|
|
}
|
177 |
|
|
-re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" }
|
178 |
|
|
timeout { fail "(timeout) print value of sbig.s\[90\] & 127" }
|
179 |
|
|
}
|
180 |
|
|
|
181 |
|
|
send_gdb "print !ibig.i\[100\]\n"
|
182 |
|
|
gdb_expect {
|
183 |
|
|
-re ".\[0-9\]* = $false.*$gdb_prompt $" {
|
184 |
|
|
pass "print value of !ibig.i\[100\]"
|
185 |
|
|
}
|
186 |
|
|
-re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
|
187 |
|
|
timeout { fail "(timeout) print value of !ibig.i\[100\]" }
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
send_gdb "print !sbig.s\[90\]\n"
|
191 |
|
|
gdb_expect {
|
192 |
|
|
-re ".\[0-9\]* = $false.*$gdb_prompt $" {
|
193 |
|
|
pass "print value of !sbig.s\[90\]"
|
194 |
|
|
}
|
195 |
|
|
-re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" }
|
196 |
|
|
timeout { fail "(timeout) print value of !sbig.s\[90\]" }
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
send_gdb "print !fbig.f\[100\]\n"
|
201 |
|
|
gdb_expect {
|
202 |
|
|
-re ".\[0-9\]* = $false.*$gdb_prompt $" {
|
203 |
|
|
pass "print value of !ibig.i\[100\]"
|
204 |
|
|
}
|
205 |
|
|
-re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
|
206 |
|
|
timeout { fail "(timeout) print value of !ibig.i\[100\]" }
|
207 |
|
|
}
|
208 |
|
|
|
209 |
|
|
send_gdb "print !dbig.d\[202\]\n"
|
210 |
|
|
gdb_expect {
|
211 |
|
|
-re ".\[0-9\]* = $false.*$gdb_prompt $" {
|
212 |
|
|
pass "print value of !ibig.i\[100\]"
|
213 |
|
|
}
|
214 |
|
|
-re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
|
215 |
|
|
timeout { fail "(timeout) print value of !ibig.i\[100\]" }
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
send_gdb "print sbig.s\[90\] * 10\n"
|
221 |
|
|
gdb_expect {
|
222 |
|
|
-re ".\[0-9\]* = 2550.*$gdb_prompt $" {
|
223 |
|
|
pass "print value of !sbig.s\[90\] * 10"
|
224 |
|
|
}
|
225 |
|
|
-re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" }
|
226 |
|
|
timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" }
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
|
230 |
|
|
gdb_expect {
|
231 |
|
|
-re ".\[0-9\]* = 1275.*$gdb_prompt $" {
|
232 |
|
|
pass "print value of ibig.i\[100\] * sbig.s\[90\]"
|
233 |
|
|
}
|
234 |
|
|
-re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" }
|
235 |
|
|
timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" }
|
236 |
|
|
}
|
237 |
|
|
|
238 |
|
|
send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
|
239 |
|
|
gdb_expect {
|
240 |
|
|
-re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" {
|
241 |
|
|
pass "print value of fbig.f\[100\] * dbig.d\[202\]"
|
242 |
|
|
}
|
243 |
|
|
-re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" }
|
244 |
|
|
timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" }
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
send_gdb "print !(sbig.s\[90\] * 2)\n"
|
248 |
|
|
gdb_expect {
|
249 |
|
|
-re ".\[0-9\]* = $false.*$gdb_prompt $" {
|
250 |
|
|
pass "print value of !(sbig.s\[90\] * 2)"
|
251 |
|
|
}
|
252 |
|
|
-re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" }
|
253 |
|
|
timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" }
|
254 |
|
|
}
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
send_gdb "print sizeof(sbig)\n"
|
258 |
|
|
gdb_expect {
|
259 |
|
|
-re ".\[0-9\]* = 800.*$gdb_prompt $" {
|
260 |
|
|
pass "print value of sizeof(sbig)"
|
261 |
|
|
}
|
262 |
|
|
-re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" }
|
263 |
|
|
timeout { fail "(timeout) print value of sizeof(sbig)" }
|
264 |
|
|
}
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
send_gdb "print sizeof(cbig)\n"
|
268 |
|
|
gdb_expect {
|
269 |
|
|
-re ".\[0-9\]* = 100.*$gdb_prompt $" {
|
270 |
|
|
pass "print value of sizeof(cbig)"
|
271 |
|
|
}
|
272 |
|
|
-re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" }
|
273 |
|
|
timeout { fail "(timeout) print value of sizeof(cbig)" }
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
|
277 |
|
|
send_gdb "print sizeof(lbig)/sizeof(long)\n"
|
278 |
|
|
gdb_expect {
|
279 |
|
|
-re ".\[0-9\]* = 900.*$gdb_prompt $" {
|
280 |
|
|
pass "print value of sizeof(lbig)/sizeof(long)"
|
281 |
|
|
}
|
282 |
|
|
-re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" }
|
283 |
|
|
timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" }
|
284 |
|
|
}
|
285 |
|
|
|
286 |
|
|
send_gdb "print ibig.i\[100\] << 2\n"
|
287 |
|
|
gdb_expect {
|
288 |
|
|
-re ".\[0-9\]* = 20.*$gdb_prompt $" {
|
289 |
|
|
pass "print value of ibig.i\[100\] << 2"
|
290 |
|
|
}
|
291 |
|
|
-re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" }
|
292 |
|
|
timeout { fail "(timeout) print value of ibig.i\[100\] << 2" }
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
send_gdb "print sbig.s\[90\] >> 4\n"
|
296 |
|
|
gdb_expect {
|
297 |
|
|
-re ".\[0-9\]* = 15.*$gdb_prompt $" {
|
298 |
|
|
pass "print value of sbig.s\[90\] >> 4"
|
299 |
|
|
}
|
300 |
|
|
-re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" }
|
301 |
|
|
timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" }
|
302 |
|
|
}
|
303 |
|
|
|
304 |
|
|
send_gdb "print lbig.l\[333\] >> 6\n"
|
305 |
|
|
gdb_expect {
|
306 |
|
|
-re ".\[0-9\]* = 15624999.*$gdb_prompt $" {
|
307 |
|
|
pass "print value of lbig.l\[333\] >> 6"
|
308 |
|
|
}
|
309 |
|
|
-re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" }
|
310 |
|
|
timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" }
|
311 |
|
|
}
|