1 # Copyright (C) 1992, 1994 Free Software Foundation, Inc.
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.
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.
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. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Fred Fish. (fnf@cygnus.com)
30 set srcfile $binfile.c
32 if ![file exists $objdir/$subdir/$binfile] then {
33 perror "$objdir/$subdir/$binfile does not exist."
37 source gdb.base/scope0.ci
39 # Test locating various things when stopped just inside main, after
40 # running init(). To prevent cascading of errors, we report the
41 # first one and quit. If all pass, then we print the pass results.
43 proc test_at_main {} {
51 # skip past init. There may be a call to __main at the start of
52 # main, so the first next may only get us to the init call.
55 -re "$decimal.*foo \\(\\);\r\n$prompt $" {
56 pass "next over init() in main"
58 -re "$decimal.*init \\(\\);\r\n$prompt $"\
59 { send "next\n" ; exp_continue }
60 -re "$prompt $" { fail "next over init() in main" ; return }
61 timeout { fail "(timeout) next over init() in main" ; return }
64 # Print scope0.c::filelocal, which is 1
66 send "print filelocal\n"
68 -re "\\\$$decimal = 1\r\n$prompt $" { pass "print filelocal" }
69 -re "$prompt $" { fail "print filelocal" ; return }
71 fail "(timeout) print filelocal" ; return
75 send "print 'scope0.c'::filelocal\n"
77 -re "\\\$$decimal = 1\r\n$prompt $" {
78 pass "print 'scope0.c'::filelocal at main"
80 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
81 send "print '$srcdir/$subdir/scope0.c'::filelocal\n"
84 -re "$prompt $" { fail "print 'scope0.c'::filelocal at main" ; return }
86 fail "(timeout) print 'scope0.c'::filelocal at main" ; return
90 # Print scope0.c::filelocal_bss, which is 101
92 send "print filelocal_bss\n"
94 -re "\\\$$decimal = 101\r\n$prompt $" {
95 pass "print filelocal_bss"
97 -re "$prompt $" { fail "print filelocal_bss" ; return }
99 fail "(timeout) print filelocal_bss" ; return
103 send "print 'scope0.c'::filelocal_bss\n"
105 -re "\\\$$decimal = 101\r\n$prompt $" {
106 pass "print 'scope0.c'::filelocal_bss in test_at_main"
108 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
109 send "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
113 fail "print 'scope0.c'::filelocal_bss in test_at_main" ; return
116 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_main"
121 # Print scope0.c::filelocal_ro, which is 201
123 # No clue why the powerpc fails this test.
124 setup_xfail "powerpc-*-*"
125 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
126 send "print filelocal_ro\n"
128 -re "\\\$$decimal = 201\r\n$prompt $" {
129 pass "print filelocal_ro in test_at_main"
132 fail "print filelocal_ro in test_at_main"
136 fail "(timeout) print filelocal_ro in test_at_main"
141 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
142 setup_xfail "powerpc-*-*"
143 send "print 'scope0.c'::filelocal_ro\n"
145 -re "\\\$$decimal = 201\r\n$prompt $" {
146 pass "print 'scope0.c'::filelocal_ro"
148 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
149 send "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
152 -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
154 fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
158 # Print scope1.c::filelocal, which is 2
160 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
161 send "print 'scope1.c'::filelocal\n"
163 -re "\\\$$decimal = 2\r\n$prompt $" {
164 pass "print 'scope1.c'::filelocal"
166 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
167 send "print '$srcdir/$subdir/scope1.c'::filelocal\n"
170 -re "$prompt $" { fail "print 'scope1.c'::filelocal" ; return }
172 fail "(timeout) print 'scope1.c'::filelocal" ; return
176 # Print scope1.c::filelocal_bss, which is 102
178 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
179 send "print 'scope1.c'::filelocal_bss\n"
181 -re "\\\$$decimal = 102\r\n$prompt $" {
182 pass "print 'scope1.c'::filelocal_bss"
184 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
185 send "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
188 -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss" ; return }
190 fail "(timeout) print 'scope1.c'::filelocal_bss" ; return
194 # Print scope1.c::filelocal_ro, which is 202
196 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
197 send "print 'scope1.c'::filelocal_ro\n"
199 -re "\\\$$decimal = 202\r\n$prompt $" {
200 pass "print 'scope1.c'::filelocal_ro"
202 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
203 send "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
206 -re "$prompt " {fail "print 'scope1.c'::filelocal_ro" ; return }
208 fail "(timeout) print 'scope1.c'::filelocal_ro" ; return
212 # Print scope1.c::foo::funclocal, which is 3
214 send "print foo::funclocal\n"
216 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print foo::funclocal" }
217 -re "$prompt $" { fail "print foo::funclocal" ; return }
219 fail "(timeout) print foo::funclocal" ; return
223 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
224 send "print 'scope1.c'::foo::funclocal\n"
226 -re "\\\$$decimal = 3\r\n$prompt $" {
227 pass "print 'scope1.c'::foo::funclocal"
229 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
230 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
233 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal" ; return }
235 fail "(timeout) print 'scope1.c'::foo::funclocal" ; return
239 # Print scope1.c::foo::funclocal_ro, which is 203
241 send "print foo::funclocal_ro\n"
243 -re "\\\$$decimal = 203\r\n$prompt $" {
244 pass "print foo::funclocal_ro"
246 -re "$prompt $" { fail "print foo::funclocal_ro" ; return }
248 fail "(timeout) print foo::funclocal_ro" ; return
252 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
253 send "print 'scope1.c'::foo::funclocal_ro\n"
255 -re "\\\$$decimal = 203\r\n$prompt $" {
256 pass "print 'scope1.c'::foo::funclocal_ro" }
257 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
258 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
261 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro" ; return }
263 fail "(timeout) print 'scope1.c'::foo::funclocal_ro" ; return
267 # Print scope1.c::bar::funclocal, which is 4
269 send "print bar::funclocal\n"
271 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print bar::funclocal" }
272 -re "$prompt $" { fail "print bar::funclocal" ; return }
274 fail "(timeout) print bar::funclocal" ; return
278 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
279 send "print 'scope1.c'::bar::funclocal\n"
281 -re "\\\$$decimal = 4\r\n$prompt $" {
282 pass "print 'scope1.c'::bar::funclocal"
284 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
285 send "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
288 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal" ; return }
290 fail "print 'scope1.c'::bar::funclocal" ; return
295 proc test_at_foo {} {
305 -re ".*bar \\(\\);\r\n$prompt $" {}
306 -re "$prompt $" { fail "continue to foo()" ; return }
307 timeout { fail "(timeout) continue to foo()" ; return }
310 # Print scope0.c::filelocal, which is 1
312 send "print 'scope0.c'::filelocal\n"
314 -re "\\\$$decimal = 1\r\n$prompt $" {
315 pass "print 'scope0.c'::filelocal at foo"
317 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
318 send "print '$srcdir/$subdir/scope0.c'::filelocal\n"
321 -re "$prompt $" { fail "print 'scope0.c'::filelocal at foo" ; return }
323 fail "(timeout) print 'scope0.c'::filelocal at foo" ; return
327 # Print scope0.c::filelocal_bss, which is 101
329 send "print 'scope0.c'::filelocal_bss\n"
331 -re "\\\$$decimal = 101\r\n$prompt $" {
332 pass "print 'scope0.c'::filelocal_bss in test_at_foo"
334 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
335 send "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
339 fail "print 'scope0.c'::filelocal_bss in test_at_foo"
343 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_foo"
348 # Print scope0.c::filelocal_ro, which is 201
350 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
351 setup_xfail "powerpc-*-*"
352 send "print 'scope0.c'::filelocal_ro\n"
354 -re "\\\$$decimal = 201\r\n$prompt $" { pass "print 'scope0.c'::filelocal_ro" }
355 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
356 send "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
359 -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
361 fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
365 gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo"
367 # Print scope1.c::filelocal, which is 2
369 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
370 send "print 'scope1.c'::filelocal\n"
372 -re "\\\$$decimal = 2\r\n$prompt $" {
373 pass "print 'scope1.c'::filelocal at foo"
375 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
376 send "print '$srcdir/$subdir/scope1.c'::filelocal\n"
379 -re "$prompt $" { fail "print 'scope1.c'::filelocal at foo" ; return }
381 fail "(timeout) print 'scope1.c'::filelocal at foo" ; return
385 gdb_test "print filelocal_bss" "\\\$$decimal = 102" \
386 "print filelocal_bss at foo"
388 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
389 send "print 'scope1.c'::filelocal_bss\n"
391 -re "\\\$$decimal = 102\r\n$prompt $" {
392 pass "print 'scope1.c'::filelocal_bss at foo"
394 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
395 send "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
398 -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss at foo" }
400 fail "(timeout) print 'scope1.c'::filelocal_bss at foo"
404 gdb_test "print filelocal_ro" "\\\$$decimal = 202" \
405 "print filelocal_ro at foo"
407 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
408 send "print 'scope1.c'::filelocal_ro\n"
410 -re "\\\$$decimal = 202\r\n$prompt $" { pass "print 'scope1.c'::filelocal_ro at foo" }
411 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
412 send "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
415 -re "$prompt $" { fail "print 'scope1.c'::filelocal_ro at foo" }
417 fail "(timeout) print 'scope1.c'::filelocal_ro at foo"
421 # Print scope1.c::foo::funclocal, which is 3
423 gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo"
425 gdb_test "print foo::funclocal" "\\\$$decimal = 3" \
426 "print foo::funclocal at foo"
428 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
429 send "print 'scope1.c'::foo::funclocal\n"
431 -re "\\\$$decimal = 3\r\n$prompt $" {
432 pass "print 'scope1.c'::foo::funclocal at foo"
434 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
435 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
438 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal at foo" }
440 fail "(timeout) print 'scope1.c'::foo::funclocal at foo"
444 # Print scope1.c::foo::funclocal_bss, which is 103
446 gdb_test "print funclocal_bss" "\\\$$decimal = 103" \
447 "print funclocal_bss at foo"
449 gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \
450 "print foo::funclocal_bss at foo"
452 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
453 send "print 'scope1.c'::foo::funclocal_bss\n"
455 -re "\\\$$decimal = 103\r\n$prompt $" {
456 pass "print 'scope1.c'::foo::funclocal_bss at foo"
458 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
459 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n"
463 fail "print 'scope1.c'::foo::funclocal_bss at foo"
466 fail "(timeout) print 'scope1.c'::foo::funclocal_bss at foo"
470 # Print scope1.c::foo::funclocal_ro, which is 203
472 gdb_test "print funclocal_ro" "\\\$$decimal = 203" \
473 "print funclocal_ro at foo"
475 gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \
476 "print foo::funclocal_ro at foo"
478 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
479 send "print 'scope1.c'::foo::funclocal_ro\n"
481 -re "\\\$$decimal = 203\r\n$prompt $" {
482 pass "print 'scope1.c'::foo::funclocal_ro at foo"
484 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
485 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
488 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro at foo" }
490 fail "(timeout) print 'scope1.c'::foo::funclocal_ro at foo"
494 # Print scope1.c::bar::funclocal, which is 4
496 gdb_test "print bar::funclocal" "\\\$$decimal = 4" \
497 "print bar::funclocal at foo"
499 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
500 send "print 'scope1.c'::bar::funclocal\n"
502 -re "\\\$$decimal = 4\r\n$prompt $" {
503 pass "print 'scope1.c'::bar::funclocal at foo"
505 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
506 send "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
509 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal at foo" }
511 fail "(timeout) print 'scope1.c'::bar::funclocal at foo"
516 proc test_at_bar {} {
527 timeout { fail "next in bar()" ; return }
530 # Print scope0.c::filelocal, which is 1
532 send "print 'scope0.c'::filelocal\n"
534 -re "\\\$$decimal = 1\r\n$prompt $" {
535 pass "print 'scope0.c'::filelocal at bar"
537 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
538 send "print '$srcdir/$subdir/scope0.c'::filelocal\n"
541 -re "$prompt $" { fail "print 'scope0.c'::filelocal at bar" ; return }
543 fail "(timeout) print 'scope0.c'::filelocal at bar" ; return
547 # Print scope0.c::filelocal_bss, which is 101
549 send "print 'scope0.c'::filelocal_bss\n"
551 -re "\\\$$decimal = 101\r\n$prompt $" {
552 pass "print 'scope0.c'::filelocal_bss in test_at_bar"
554 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
555 send "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
559 fail "print 'scope0.c'::filelocal_bss in test_at_bar"
563 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_bar"
568 # Print scope0.c::filelocal_ro, which is 201
570 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
571 setup_xfail "powerpc-*-*"
572 send "print 'scope0.c'::filelocal_ro\n"
574 -re "\\\$$decimal = 201\r\n$prompt $" { pass "print 'scope0.c'::filelocal_ro" }
575 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
576 send "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
579 -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
581 fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
585 # Print scope1.c::filelocal, which is 2
587 send "print filelocal\n"
589 -re "\\\$$decimal = 2\r\n$prompt $" { pass "print filelocal" }
590 -re "$prompt $" { fail "print filelocal" ; return }
592 fail "(timeout) print filelocal" ; return
596 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
597 send "print 'scope1.c'::filelocal\n"
599 -re "\\\$$decimal = 2\r\n$prompt $" { pass "print 'scope1.c'::filelocal" }
600 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
601 send "print '$srcdir/$subdir/scope1.c'::filelocal\n"
604 -re "$prompt $" { fail "print 'scope1.c'::filelocal" ; return }
606 fail "(timeout) print 'scope1.c'::filelocal" ; return
610 # Print scope1.c::filelocal_bss, which is 102
612 send "print filelocal_bss\n"
614 -re "\\\$$decimal = 102\r\n$prompt $" { pass "print filelocal_bss" }
615 -re "$prompt $" { fail "print filelocal_bss" ; return }
617 fail "(timeout) print filelocal_bss" ; return
621 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
622 send "print 'scope1.c'::filelocal_bss\n"
624 -re "\\\$$decimal = 102\r\n$prompt $" { pass "print 'scope1.c'::filelocal_bss" }
625 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
626 send "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
629 -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss" ; return }
631 fail "(timeout) print 'scope1.c'::filelocal_bss" ; return
635 # Print scope1.c::filelocal_ro, which is 202
637 send "print filelocal_ro\n"
639 -re "\\\$$decimal = 202\r\n$prompt $" {
640 pass "print filelocal_ro in test_at_bar"
643 fail "print filelocal_ro in test_at_bar"
647 fail "(timeout) print filelocal_ro in test_at_bar"
652 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
653 send "print 'scope1.c'::filelocal_ro\n"
655 -re "\\\$$decimal = 202\r\n$prompt $" { pass "print 'scope1.c'::filelocal_ro" }
656 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
657 send "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
660 -re "$prompt $" { fail "print 'scope1.c'::filelocal_ro" ; return }
662 fail "(timeout) print 'scope1.c'::filelocal_ro" ; return
666 # Print scope1.c::foo::funclocal, which is 3
668 send "print foo::funclocal\n"
670 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print foo::funclocal" }
671 -re "$prompt $" { fail "print foo::funclocal" ; return }
673 fail "(timeout) print foo::funclocal" ; return
677 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
678 send "print 'scope1.c'::foo::funclocal\n"
680 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal" }
681 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
682 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
685 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal" ; return }
687 fail "(timeout) print 'scope1.c'::foo::funclocal" ; return
691 # Print scope1.c::foo::funclocal_bss, which is 103
693 send "print foo::funclocal_bss\n"
695 -re "\\\$$decimal = 103\r\n$prompt $" { pass "print foo::funclocal_bss" }
696 -re "$prompt $" { fail "print foo::funclocal_bss" ; return }
698 fail "(timeout) print foo::funclocal_bss" ; return
702 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
703 send "print 'scope1.c'::foo::funclocal_bss\n"
705 -re "\\\$$decimal = 103\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal_bss" }
706 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
707 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n"
710 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_bss" ; return }
712 fail "(timeout) print 'scope1.c'::foo::funclocal_bss" ; return
716 # Print scope1.c::foo::funclocal_ro, which is 203
718 send "print foo::funclocal_ro\n"
720 -re "\\\$$decimal = 203\r\n$prompt $" { pass "print foo::funclocal_ro" }
721 -re "$prompt $" { fail "print foo::funclocal_ro" ; return }
723 fail "(timeout) print foo::funclocal_ro" ; return
727 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
728 send "print 'scope1.c'::foo::funclocal_ro\n"
730 -re "\\\$$decimal = 203\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal_ro" }
731 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
732 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
735 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro" ; return }
737 fail "(timeout) print 'scope1.c'::foo::funclocal_ro" ; return
741 # Print scope1.c::bar::funclocal, which is 4
743 send "print funclocal\n"
745 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print funclocal" }
746 -re "$prompt $" { fail "print funclocal" ; return }
748 fail "(timeout) print funclocal" ; return
752 send "print bar::funclocal\n"
754 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print bar::funclocal" }
755 -re "$prompt $" { fail "print bar::funclocal" ; return }
757 fail "(timeout) print bar::funclocal" ; return
761 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
762 send "print 'scope1.c'::bar::funclocal\n"
764 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print 'scope1.c'::bar::funclocal" }
765 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
766 send "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
769 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal" ; return }
771 fail "(timeout) print 'scope1.c'::bar::funclocal" ; return
775 # Print scope1.c::bar::funclocal_bss, which is 104
777 send "print funclocal_bss\n"
779 -re "\\\$$decimal = 104\r\n$prompt $" { pass "print funclocal_bss" }
780 -re "$prompt $" { fail "print funclocal_bss" ; return }
782 fail "(timeout) print funclocal_bss" ; return
786 send "print bar::funclocal_bss\n"
788 -re "\\\$$decimal = 104\r\n$prompt $" { pass "print bar::funclocal_bss" }
789 -re "$prompt $" { fail "print bar::funclocal_bss" ; return }
791 fail "(timeout) print bar::funclocal_bss" ; return
795 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
796 send "print 'scope1.c'::bar::funclocal_bss\n"
798 -re "\\\$$decimal = 104\r\n$prompt $" { pass "print 'scope1.c'::bar::funclocal_bss" }
799 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
800 send "print '$srcdir/$subdir/scope1.c'::bar::funclocal_bss\n"
803 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal_bss" ; return }
805 fail "(timeout) print 'scope1.c'::bar::funclocal_bss" ; return
810 # This test has little to do with local scopes, but it is in scope.exp anyway.
813 proc test_at_autovars {} {
819 # Test symbol table lookup with 100 local (auto) variables.
821 send "break marker1\n" ; expect -re ".*$prompt $"
825 -re "Break.* marker1 \\(\\) at .*:$decimal.*$prompt $" {
829 timeout { fail "up from marker1" ; return }
832 -re "$prompt $" { fail "continue to marker1" ; return }
833 timeout { fail "(timeout) continue to marker1" ; return }
837 while {$count < 100} {
838 send "print i$count\n"
840 -re ".* = $count\r\n$prompt $" {}
842 fail "bad value for auto variable i$count"; return
845 fail "(timeout) bad value for auto variable i$count"; return
848 set count [expr $count+1]
851 pass "$count auto variables correctly initialized"
853 # Test that block variable sorting is not screwing us.
854 gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order"
857 proc test_at_localscopes {} {
863 send "break marker2\n" ; expect -re ".*$prompt $"
864 send "break marker3\n" ; expect -re ".*$prompt $"
865 send "break marker4\n" ; expect -re ".*$prompt $"
869 -re "Break.* marker2 \\(\\) at .*:$decimal.*$prompt $" {
873 timeout { fail "up from marker2" ; return }
876 -re "$prompt $" { fail "continue to marker2" ; return }
877 timeout { fail "(timeout) continue to marker2" ; return }
880 # Should be at first (outermost) scope. Check values.
882 gdb_test "print localval" " = 10" "print localval, outer scope"
883 gdb_test "print localval1" " = 11" "print localval1, outer scope"
884 gdb_test "print localval2" "No symbol \"localval2\" in current context." \
885 "print localval2, outer scope"
886 gdb_test "print localval3" "No symbol \"localval3\" in current context." \
887 "print localval3, outer scope"
889 if [gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \
890 "continue to marker3 in scope.exp"] then { return }
891 if [gdb_test "up" "" "up from marker3 in scope.exp"] then { return }
893 # Should be at next (first nested) scope. Check values.
895 gdb_test "print localval" " = 20" \
896 "print localval, first nested scope"
897 gdb_test "print localval1" " = 11" "print localval1, first nested scope"
898 gdb_test "print localval2" " = 12" "print localval2, first nested scope"
899 gdb_test "print localval3" "No symbol \"localval3\" in current context." \
900 "print localval3, first nested scope"
902 # This test will only fail if the file was compiled by gcc, but
903 # there's no way to check that.
904 setup_xfail "a29k-*-udi" 2423
905 if [gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \
906 "continue to marker4 in scope.exp"] then { return }
907 if [gdb_test "up" "" "up from marker4 in scope.exp"] then { return }
909 gdb_test "print localval" " = 30" "print localval, innermost scope"
910 gdb_test "print localval1" " = 11" "print localval1, innermost scope"
911 gdb_test "print localval2" " = 12" "print localval2, innermost scope"
912 gdb_test "print localval3" " = 13" "print localval3, innermost scope"
915 # Start with a fresh gdb.
919 gdb_reinitialize_dir $srcdir/$subdir
920 gdb_load $objdir/$subdir/$binfile
922 if [istarget "*-*-vxworks*"] {
926 # Test that variables in various segments print out correctly before
927 # the program is run.
929 # AIX--sections get mapped to the same address so we can't get the right one.
930 setup_xfail "rs6000-*-*"
931 setup_xfail "powerpc-*-*"
933 gdb_test "print 'scope0.c'::filelocal_ro" "= 201"
935 # gdb currently cannot access bss memory on some targets if the inferior
938 # For PA boards using monitor/remote-pa.c, the bss test is going to
939 # randomly fail. We've already put remote-pa on the target stack,
940 # so we actually read memory from the board. Problem is crt0.o
941 # is responsible for clearing bss and that hasnt' happened yet.
942 setup_xfail "hppa*-*-*pro*"
943 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
944 send "print 'scope0.c'::filelocal_bss\n"
946 -re " = 0\r\n$prompt $" {
947 pass "print 'scope0.c'::filelocal_bss before run"
949 -re "Cannot access memory.*$prompt $" {
951 fail "print 'scope0.c'::filelocal_bss before run"
954 fail "print 'scope0.c'::filelocal_bss before run"
957 fail "print 'scope0.c'::filelocal_bss before run"
961 # AIX--sections get mapped to the same address so we can't get the right one.
962 setup_xfail "rs6000-*-*"
964 gdb_test "print 'scope0.c'::filelocal" "= 1" \
965 "print 'scope0.c'::filelocal before run"
967 if [runto_main] then { test_at_main }
968 if [istarget "mips-idt-*"] then {
969 # Restart because IDT/SIM runs out of file descriptors.
972 gdb_reinitialize_dir $srcdir/$subdir
973 gdb_load $objdir/$subdir/$binfile
975 if [runto foo] then { test_at_foo }
976 if [istarget "mips-idt-*"] then {
977 # Restart because IDT/SIM runs out of file descriptors.
980 gdb_reinitialize_dir $srcdir/$subdir
981 gdb_load $objdir/$subdir/$binfile
983 if [runto bar] then { test_at_bar }
984 if [istarget "mips-idt-*"] then {
985 # Restart because IDT/SIM runs out of file descriptors.
988 gdb_reinitialize_dir $srcdir/$subdir
989 gdb_load $objdir/$subdir/$binfile
991 if [runto localscopes] then { test_at_localscopes }
992 if [istarget "mips-idt-*"] then {
993 # Restart because IDT/SIM runs out of file descriptors.
996 gdb_reinitialize_dir $srcdir/$subdir
997 gdb_load $objdir/$subdir/$binfile
999 if [runto autovars] then { test_at_autovars }
1001 if [istarget "*-*-vxworks*"] {