Commit | Line | Data |
---|---|---|
28e7fd62 | 1 | # Copyright 1992-2013 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 Fred Fish. (fnf@cygnus.com) |
17 | ||
c906108c SS |
18 | |
19 | set testfile "scope" | |
20 | set binfile ${objdir}/${subdir}/${testfile} | |
21 | ||
22 | ||
23 | if { [gdb_compile "${srcdir}/${subdir}/scope0.c" "${binfile}0.o" object {debug}] != "" } { | |
b60f0898 JB |
24 | untested scope.exp |
25 | return -1 | |
c906108c SS |
26 | } |
27 | ||
28 | if { [gdb_compile "${srcdir}/${subdir}/scope1.c" "${binfile}1.o" object {debug}] != "" } { | |
b60f0898 JB |
29 | untested scope.exp |
30 | return -1 | |
c906108c SS |
31 | } |
32 | ||
33 | if { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } { | |
b60f0898 JB |
34 | untested scope.exp |
35 | return -1 | |
c906108c SS |
36 | } |
37 | ||
38 | # Create and source the file that provides information about the compiler | |
39 | # used to compile the test case. | |
4c93b1db | 40 | if [get_compiler_info] { |
c906108c SS |
41 | return -1; |
42 | } | |
43 | ||
44 | # Test locating various things when stopped just inside main, after | |
45 | # running init0(). To prevent cascading of errors, we report the | |
46 | # first one and quit. If all pass, then we print the pass results. | |
47 | ||
48 | proc test_at_main {} { | |
49 | global gdb_prompt | |
50 | global decimal | |
51 | global det_file | |
52 | global srcdir | |
53 | global subdir | |
085dd6e6 | 54 | global hp_cc_compiler |
c906108c | 55 | |
34e41e63 JB |
56 | # skip past init0. |
57 | # This used to do an extra "next" if the first one didn't get us | |
58 | # over the call to init0, to handle calls to __main in the | |
59 | # prologue, etc. But if a breakpoint at main doesn't leave us on | |
60 | # the first line of real code in the function, that's a GDB bug. | |
61 | gdb_test "next" "$decimal.*foo \\(\\);" "next over init0() in main" | |
c906108c SS |
62 | |
63 | # Print scope0.c::filelocal, which is 1 | |
64 | ||
65 | if [gdb_test "print filelocal" "\\\$$decimal = 1" "print filelocal" ] { | |
66 | gdb_suppress_tests ; | |
67 | } | |
68 | ||
69 | ||
70 | if [gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at main" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal"] { | |
71 | gdb_suppress_tests ; | |
72 | } | |
73 | ||
74 | ||
75 | # Print scope0.c::filelocal_bss, which is 101 | |
76 | ||
77 | if [gdb_test "print filelocal_bss" "\\\$$decimal = 101" "print filelocal_bss" ] { | |
78 | gdb_suppress_tests ; | |
79 | } | |
80 | ||
81 | ||
82 | if [gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_main" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_bss"] { | |
83 | gdb_suppress_tests ; | |
84 | } | |
85 | ||
86 | ||
87 | # Print scope0.c::filelocal_ro, which is 201 | |
88 | ||
15656118 | 89 | # No clue why the rs6000 fails this test. |
ba9b20a7 | 90 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
91 | if [gdb_test "print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main" ] { |
92 | gdb_suppress_tests ; | |
93 | } | |
94 | ||
95 | ||
ba9b20a7 | 96 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
97 | if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { |
98 | gdb_suppress_tests ; | |
99 | } | |
100 | ||
101 | ||
102 | # Print scope1.c::filelocal, which is 2 | |
103 | ||
ba9b20a7 | 104 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
105 | if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { |
106 | gdb_suppress_tests ; | |
107 | } | |
108 | ||
109 | ||
110 | # Print scope1.c::filelocal_bss, which is 102 | |
111 | ||
ba9b20a7 | 112 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
113 | if [gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss"] { |
114 | gdb_suppress_tests ; | |
115 | } | |
116 | ||
117 | ||
118 | # Print scope1.c::filelocal_ro, which is 202 | |
119 | ||
ba9b20a7 | 120 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
a0b3c4fd | 121 | if {$hp_cc_compiler} then { setup_xfail "hppa2.0w-*-*" 11747CLLbs} |
c906108c SS |
122 | if [gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro"] { |
123 | gdb_suppress_tests ; | |
124 | } | |
125 | ||
126 | ||
127 | # Print scope1.c::foo::funclocal, which is 3 | |
128 | ||
c906108c SS |
129 | if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal" ] { |
130 | gdb_suppress_tests ; | |
131 | } | |
132 | ||
133 | ||
ba9b20a7 | 134 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
135 | if [gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal"] { |
136 | gdb_suppress_tests ; | |
137 | } | |
138 | ||
139 | ||
140 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
141 | ||
142 | if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro" ] { | |
143 | gdb_suppress_tests ; | |
144 | } | |
145 | ||
146 | ||
ba9b20a7 | 147 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
148 | if [gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro"] { |
149 | gdb_suppress_tests ; | |
150 | } | |
151 | ||
152 | ||
153 | # Print scope1.c::bar::funclocal, which is 4 | |
154 | ||
155 | if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal" ] { | |
156 | gdb_suppress_tests ; | |
157 | } | |
158 | ||
159 | ||
ba9b20a7 | 160 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
161 | if [gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal"] { |
162 | gdb_suppress_tests ; | |
163 | } | |
164 | gdb_stop_suppressing_tests; | |
165 | ||
166 | } | |
167 | ||
168 | proc test_at_foo {} { | |
169 | global gdb_prompt | |
170 | global decimal | |
171 | global det_file | |
172 | global srcdir | |
173 | global subdir | |
c906108c SS |
174 | |
175 | if [gdb_test "next" ".*bar \\(\\);" "" ] { | |
176 | gdb_suppress_tests ; | |
177 | } | |
178 | ||
179 | ||
180 | # Print scope0.c::filelocal, which is 1 | |
181 | ||
182 | if [gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at foo" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal"] { | |
183 | gdb_suppress_tests ; | |
184 | } | |
185 | ||
186 | ||
187 | # Print scope0.c::filelocal_bss, which is 101 | |
188 | ||
189 | if [gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_foo" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_bss"] { | |
190 | gdb_suppress_tests ; | |
191 | } | |
192 | ||
193 | ||
194 | # Print scope0.c::filelocal_ro, which is 201 | |
195 | ||
ba9b20a7 | 196 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
197 | if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { |
198 | gdb_suppress_tests ; | |
199 | } | |
200 | ||
201 | ||
202 | gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo" | |
203 | ||
204 | # Print scope1.c::filelocal, which is 2 | |
205 | ||
ba9b20a7 | 206 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
207 | if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { |
208 | gdb_suppress_tests ; | |
209 | } | |
210 | ||
211 | ||
212 | gdb_test "print filelocal_bss" "\\\$$decimal = 102" \ | |
213 | "print filelocal_bss at foo" | |
214 | ||
ba9b20a7 | 215 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
216 | gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss" |
217 | ||
218 | ||
219 | gdb_test "print filelocal_ro" "\\\$$decimal = 202" \ | |
220 | "print filelocal_ro at foo" | |
221 | ||
ba9b20a7 | 222 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
223 | gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro" |
224 | ||
225 | ||
226 | # Print scope1.c::foo::funclocal, which is 3 | |
227 | ||
228 | gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo" | |
229 | ||
c906108c SS |
230 | gdb_test "print foo::funclocal" "\\\$$decimal = 3" \ |
231 | "print foo::funclocal at foo" | |
232 | ||
ba9b20a7 | 233 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
234 | gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal" |
235 | ||
236 | ||
237 | # Print scope1.c::foo::funclocal_bss, which is 103 | |
238 | ||
239 | gdb_test "print funclocal_bss" "\\\$$decimal = 103" \ | |
240 | "print funclocal_bss at foo" | |
241 | ||
c906108c SS |
242 | gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \ |
243 | "print foo::funclocal_bss at foo" | |
244 | ||
ba9b20a7 | 245 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
246 | gdb_test "print 'scope1.c'::foo::funclocal_bss" "\\\$$decimal = 103" "print 'scope1.c'::foo::funclocal_bss at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss" |
247 | ||
248 | ||
249 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
250 | ||
251 | gdb_test "print funclocal_ro" "\\\$$decimal = 203" \ | |
252 | "print funclocal_ro at foo" | |
253 | ||
c906108c SS |
254 | gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \ |
255 | "print foo::funclocal_ro at foo" | |
256 | ||
ba9b20a7 | 257 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
258 | gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro" |
259 | ||
260 | ||
261 | # Print scope1.c::bar::funclocal, which is 4 | |
262 | ||
c906108c SS |
263 | gdb_test "print bar::funclocal" "\\\$$decimal = 4" \ |
264 | "print bar::funclocal at foo" | |
265 | ||
ba9b20a7 | 266 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
267 | gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal" |
268 | gdb_stop_suppressing_tests; | |
269 | ||
270 | } | |
271 | ||
272 | proc test_at_bar {} { | |
273 | global gdb_prompt | |
274 | global decimal | |
275 | global det_file | |
276 | global srcdir | |
277 | global subdir | |
c906108c SS |
278 | |
279 | if [gdb_test "next" ".*" "" ] { | |
280 | gdb_suppress_tests ; | |
281 | } | |
282 | ||
283 | ||
284 | # Print scope0.c::filelocal, which is 1 | |
285 | ||
286 | if [gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at bar" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal"] { | |
287 | gdb_suppress_tests ; | |
288 | } | |
289 | ||
290 | ||
291 | # Print scope0.c::filelocal_bss, which is 101 | |
292 | ||
293 | if [gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_bar" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_bss"] { | |
294 | gdb_suppress_tests ; | |
295 | } | |
296 | ||
297 | ||
298 | # Print scope0.c::filelocal_ro, which is 201 | |
299 | ||
ba9b20a7 | 300 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
301 | if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro at bar" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { |
302 | gdb_suppress_tests ; | |
303 | } | |
304 | ||
305 | ||
306 | # Print scope1.c::filelocal, which is 2 | |
307 | ||
308 | if [gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at bar" ] { | |
309 | gdb_suppress_tests ; | |
310 | } | |
311 | ||
312 | ||
ba9b20a7 | 313 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
314 | if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { |
315 | gdb_suppress_tests ; | |
316 | } | |
317 | ||
318 | ||
319 | # Print scope1.c::filelocal_bss, which is 102 | |
320 | ||
321 | if [gdb_test "print filelocal_bss" "\\\$$decimal = 102" "print filelocal_bss at bar" ] { | |
322 | gdb_suppress_tests ; | |
323 | } | |
324 | ||
325 | ||
ba9b20a7 | 326 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
327 | if [gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss"] { |
328 | gdb_suppress_tests ; | |
329 | } | |
330 | ||
331 | ||
332 | # Print scope1.c::filelocal_ro, which is 202 | |
333 | ||
334 | if [gdb_test "print filelocal_ro" "\\\$$decimal = 202" "print filelocal_ro in test_at_bar" ] { | |
335 | gdb_suppress_tests ; | |
336 | } | |
337 | ||
338 | ||
ba9b20a7 | 339 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
340 | if [gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro"] { |
341 | gdb_suppress_tests ; | |
342 | } | |
343 | ||
344 | ||
345 | # Print scope1.c::foo::funclocal, which is 3 | |
346 | ||
c906108c SS |
347 | if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal at bar" ] { |
348 | gdb_suppress_tests ; | |
349 | } | |
350 | ||
351 | ||
ba9b20a7 | 352 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
353 | if [gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal"] { |
354 | gdb_suppress_tests ; | |
355 | } | |
356 | ||
357 | ||
358 | # Print scope1.c::foo::funclocal_bss, which is 103 | |
359 | ||
360 | if [gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" "print foo::funclocal_bss at bar" ] { | |
361 | gdb_suppress_tests ; | |
362 | } | |
363 | ||
364 | ||
ba9b20a7 | 365 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
366 | if [gdb_test "print 'scope1.c'::foo::funclocal_bss" "\\\$$decimal = 103" "print 'scope1.c'::foo::funclocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss"] { |
367 | gdb_suppress_tests ; | |
368 | } | |
369 | ||
370 | ||
371 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
372 | ||
373 | if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro at bar" ] { | |
374 | gdb_suppress_tests ; | |
375 | } | |
376 | ||
377 | ||
ba9b20a7 | 378 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
379 | if [gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro"] { |
380 | gdb_suppress_tests ; | |
381 | } | |
382 | ||
383 | ||
384 | # Print scope1.c::bar::funclocal, which is 4 | |
385 | ||
386 | if [gdb_test "print funclocal" "\\\$$decimal = 4" "print funclocal at bar" ] { | |
387 | gdb_suppress_tests ; | |
388 | } | |
389 | ||
390 | ||
391 | if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal at bar" ] { | |
392 | gdb_suppress_tests ; | |
393 | } | |
394 | ||
395 | ||
ba9b20a7 | 396 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
397 | if [gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal"] { |
398 | gdb_suppress_tests ; | |
399 | } | |
400 | ||
401 | ||
402 | # Print scope1.c::bar::funclocal_bss, which is 104 | |
403 | ||
404 | if [gdb_test "print funclocal_bss" "\\\$$decimal = 104" "print funclocal_bss at bar" ] { | |
405 | gdb_suppress_tests ; | |
406 | } | |
407 | ||
408 | ||
409 | if [gdb_test "print bar::funclocal_bss" "\\\$$decimal = 104" "print bar::funclocal_bss at bar" ] { | |
410 | gdb_suppress_tests ; | |
411 | } | |
412 | ||
413 | ||
ba9b20a7 | 414 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
415 | if [gdb_test "print 'scope1.c'::bar::funclocal_bss" "\\\$$decimal = 104" "print 'scope1.c'::bar::funclocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal_bss"] { |
416 | gdb_suppress_tests ; | |
417 | } | |
418 | gdb_stop_suppressing_tests; | |
419 | ||
420 | } | |
421 | ||
422 | # This test has little to do with local scopes, but it is in scope.exp anyway. | |
423 | # That's life. | |
424 | ||
425 | proc test_at_autovars {} { | |
426 | global gdb_prompt | |
427 | global decimal | |
428 | global hex | |
429 | global srcfile | |
430 | ||
431 | # Test symbol table lookup with 100 local (auto) variables. | |
432 | ||
433 | gdb_breakpoint marker1 | |
434 | ||
435 | if [gdb_test "cont" "Break.* marker1 \\(\\) at .*:$decimal.*" "continue to marker1"] { | |
436 | gdb_suppress_tests; | |
437 | } | |
438 | ||
660fd469 | 439 | if [gdb_test "up" ".*autovars.*" "up from marker1 in scope.exp" ] { |
c906108c SS |
440 | gdb_suppress_tests ; |
441 | } | |
442 | ||
443 | set count 0 | |
444 | while {$count < 100} { | |
445 | if [gdb_test "print i$count" ".* = $count" "" ] { | |
446 | gdb_suppress_tests ; | |
447 | } | |
448 | ||
449 | set count [expr $count+1] | |
450 | } | |
451 | clear_xfail "*-*-*" | |
452 | pass "$count auto variables correctly initialized" | |
453 | ||
454 | # Test that block variable sorting is not screwing us. | |
455 | gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order" | |
456 | } | |
457 | ||
458 | proc test_at_localscopes {} { | |
459 | global gdb_prompt | |
460 | global decimal | |
461 | global hex | |
462 | global srcfile | |
463 | ||
464 | gdb_breakpoint marker2 | |
465 | gdb_breakpoint marker3 | |
466 | gdb_breakpoint marker4 | |
467 | ||
468 | if [gdb_test "cont" "Break.* marker2 \\(\\) at .*:$decimal.*" "continue to marker2"] { | |
469 | gdb_suppress_tests; | |
470 | } | |
660fd469 | 471 | if [gdb_test "up" ".*localscopes.*" "up from marker2 in scopes.exp" ] { |
c906108c SS |
472 | gdb_suppress_tests ; |
473 | } | |
474 | ||
475 | # Should be at first (outermost) scope. Check values. | |
476 | ||
477 | gdb_test "print localval" " = 10" "print localval, outer scope" | |
478 | gdb_test "print localval1" " = 11" "print localval1, outer scope" | |
479 | gdb_test "print localval2" "No symbol \"localval2\" in current context." \ | |
480 | "print localval2, outer scope" | |
481 | gdb_test "print localval3" "No symbol \"localval3\" in current context." \ | |
482 | "print localval3, outer scope" | |
483 | ||
484 | if [gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \ | |
485 | "continue to marker3 in scope.exp"] then { gdb_suppress_tests } | |
660fd469 MS |
486 | if [gdb_test "up" ".*localscopes.*" "up from marker3 in scope.exp"] { |
487 | gdb_suppress_tests | |
488 | } | |
c906108c SS |
489 | |
490 | # Should be at next (first nested) scope. Check values. | |
491 | ||
492 | gdb_test "print localval" " = 20" \ | |
493 | "print localval, first nested scope" | |
494 | gdb_test "print localval1" " = 11" "print localval1, first nested scope" | |
495 | gdb_test "print localval2" " = 12" "print localval2, first nested scope" | |
496 | gdb_test "print localval3" "No symbol \"localval3\" in current context." \ | |
497 | "print localval3, first nested scope" | |
498 | ||
499 | # This test will only fail if the file was compiled by gcc, but | |
500 | # there's no way to check that. | |
c906108c SS |
501 | if [gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \ |
502 | "continue to marker4 in scope.exp"] then { gdb_suppress_tests } | |
660fd469 MS |
503 | if [gdb_test "up" ".*localscopes.*" "up from marker4 in scope.exp"] { |
504 | gdb_suppress_tests | |
505 | } | |
c906108c SS |
506 | |
507 | gdb_test "print localval" " = 30" "print localval, innermost scope" | |
508 | gdb_test "print localval1" " = 11" "print localval1, innermost scope" | |
509 | gdb_test "print localval2" " = 12" "print localval2, innermost scope" | |
510 | gdb_test "print localval3" " = 13" "print localval3, innermost scope" | |
511 | gdb_stop_suppressing_tests; | |
512 | } | |
513 | ||
514 | # Start with a fresh gdb. | |
515 | ||
516 | gdb_exit | |
517 | gdb_start | |
518 | gdb_reinitialize_dir $srcdir/$subdir | |
519 | gdb_load ${binfile} | |
520 | ||
521 | if [istarget "*-*-vxworks*"] { | |
522 | set timeout 120 | |
523 | verbose "Timeout is now $timeout seconds" 2 | |
524 | } | |
525 | ||
526 | # Test that variables in various segments print out correctly before | |
527 | # the program is run. | |
528 | ||
529 | # AIX--sections get mapped to the same address so we can't get the right one. | |
530 | setup_xfail "rs6000-*-*" | |
c906108c SS |
531 | |
532 | gdb_test "print 'scope0.c'::filelocal_ro" "= 201" | |
533 | ||
534 | # gdb currently cannot access bss memory on some targets if the inferior | |
535 | # is not running. | |
536 | # | |
537 | # For PA boards using monitor/remote-pa.c, the bss test is going to | |
538 | # randomly fail. We've already put remote-pa on the target stack, | |
539 | # so we actually read memory from the board. Problem is crt0.o | |
540 | # is responsible for clearing bss and that hasnt' happened yet. | |
541 | # | |
542 | # This is a problem for all non-native targets. -- manson | |
676a0442 | 543 | if [is_remote target] { |
c906108c SS |
544 | unsupported "print 'scope0.c'::filelocal_bss before run" |
545 | } else { | |
546 | gdb_test "print 'scope0.c'::filelocal_bss" "= 0" \ | |
547 | "print 'scope0.c'::filelocal_bss before run" | |
548 | } | |
549 | ||
550 | gdb_test "print 'scope0.c'::filelocal" "= 1" \ | |
551 | "print 'scope0.c'::filelocal before run" | |
552 | ||
553 | if [runto_main] then { test_at_main } | |
c906108c | 554 | if [runto foo] then { test_at_foo } |
c906108c | 555 | if [runto bar] then { test_at_bar } |
c906108c | 556 | if [runto localscopes] then { test_at_localscopes } |
c906108c SS |
557 | if [runto autovars] then { test_at_autovars } |
558 | ||
559 | if [istarget "*-*-vxworks*"] { | |
560 | set timeout 120 | |
561 | verbose "Timeout is now $timeout seconds" 2 | |
562 | } |