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