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 binfile ${objdir}/${subdir}/${testfile}
31 if { [gdb_compile "${srcdir}/${subdir}/scope0.c ${srcdir}/${subdir}/scope1.c" "${binfile}" executable {debug}] != "" } {
32 perror "Couldn't compile scope0.c to object"
36 # Create and source the file that provides information about the compiler
37 # used to compile the test case.
38 if [get_compiler_info ${binfile}] {
42 # Test locating various things when stopped just inside main, after
43 # running init(). To prevent cascading of errors, we report the
44 # first one and quit. If all pass, then we print the pass results.
46 proc test_at_main {} {
54 # skip past init. There may be a call to __main at the start of
55 # main, so the first next may only get us to the init call.
58 -re "$decimal.*foo \\(\\);\r\n$prompt $" {
59 pass "next over init() in main"
61 -re "$decimal.*init \\(\\);\r\n$prompt $"\
62 { send_gdb "next\n" ; exp_continue }
63 -re "$prompt $" { fail "next over init() in main" ; return }
64 timeout { fail "(timeout) next over init() in main" ; return }
67 # Print scope0.c::filelocal, which is 1
69 send_gdb "print filelocal\n"
71 -re "\\\$$decimal = 1\r\n$prompt $" { pass "print filelocal" }
72 -re "$prompt $" { fail "print filelocal" ; return }
74 fail "(timeout) print filelocal" ; return
78 send_gdb "print 'scope0.c'::filelocal\n"
80 -re "\\\$$decimal = 1\r\n$prompt $" {
81 pass "print 'scope0.c'::filelocal at main"
83 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
84 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal\n"
87 -re "$prompt $" { fail "print 'scope0.c'::filelocal at main" ; return }
89 fail "(timeout) print 'scope0.c'::filelocal at main" ; return
93 # Print scope0.c::filelocal_bss, which is 101
95 send_gdb "print filelocal_bss\n"
97 -re "\\\$$decimal = 101\r\n$prompt $" {
98 pass "print filelocal_bss"
100 -re "$prompt $" { fail "print filelocal_bss" ; return }
102 fail "(timeout) print filelocal_bss" ; return
106 send_gdb "print 'scope0.c'::filelocal_bss\n"
108 -re "\\\$$decimal = 101\r\n$prompt $" {
109 pass "print 'scope0.c'::filelocal_bss in test_at_main"
111 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
112 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
116 fail "print 'scope0.c'::filelocal_bss in test_at_main" ; return
119 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_main"
124 # Print scope0.c::filelocal_ro, which is 201
126 # No clue why the powerpc fails this test.
127 setup_xfail "powerpc-*-*"
128 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
129 send_gdb "print filelocal_ro\n"
131 -re "\\\$$decimal = 201\r\n$prompt $" {
132 pass "print filelocal_ro in test_at_main"
135 fail "print filelocal_ro in test_at_main"
139 fail "(timeout) print filelocal_ro in test_at_main"
144 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
145 setup_xfail "powerpc-*-*"
146 send_gdb "print 'scope0.c'::filelocal_ro\n"
148 -re "\\\$$decimal = 201\r\n$prompt $" {
149 pass "print 'scope0.c'::filelocal_ro"
151 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
152 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
155 -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
157 fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
161 # Print scope1.c::filelocal, which is 2
163 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
164 send_gdb "print 'scope1.c'::filelocal\n"
166 -re "\\\$$decimal = 2\r\n$prompt $" {
167 pass "print 'scope1.c'::filelocal"
169 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
170 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal\n"
173 -re "$prompt $" { fail "print 'scope1.c'::filelocal" ; return }
175 fail "(timeout) print 'scope1.c'::filelocal" ; return
179 # Print scope1.c::filelocal_bss, which is 102
181 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
182 send_gdb "print 'scope1.c'::filelocal_bss\n"
184 -re "\\\$$decimal = 102\r\n$prompt $" {
185 pass "print 'scope1.c'::filelocal_bss"
187 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
188 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
191 -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss" ; return }
193 fail "(timeout) print 'scope1.c'::filelocal_bss" ; return
197 # Print scope1.c::filelocal_ro, which is 202
199 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
200 send_gdb "print 'scope1.c'::filelocal_ro\n"
202 -re "\\\$$decimal = 202\r\n$prompt $" {
203 pass "print 'scope1.c'::filelocal_ro"
205 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
206 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
209 -re "$prompt " {fail "print 'scope1.c'::filelocal_ro" ; return }
211 fail "(timeout) print 'scope1.c'::filelocal_ro" ; return
215 # Print scope1.c::foo::funclocal, which is 3
217 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
218 send_gdb "print foo::funclocal\n"
220 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print foo::funclocal" }
221 -re "$prompt $" { fail "print foo::funclocal" ; return }
223 fail "(timeout) print foo::funclocal" ; return
227 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
228 send_gdb "print 'scope1.c'::foo::funclocal\n"
230 -re "\\\$$decimal = 3\r\n$prompt $" {
231 pass "print 'scope1.c'::foo::funclocal"
233 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
234 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
237 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal" ; return }
239 fail "(timeout) print 'scope1.c'::foo::funclocal" ; return
243 # Print scope1.c::foo::funclocal_ro, which is 203
245 send_gdb "print foo::funclocal_ro\n"
247 -re "\\\$$decimal = 203\r\n$prompt $" {
248 pass "print foo::funclocal_ro"
250 -re "$prompt $" { fail "print foo::funclocal_ro" ; return }
252 fail "(timeout) print foo::funclocal_ro" ; return
256 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
257 send_gdb "print 'scope1.c'::foo::funclocal_ro\n"
259 -re "\\\$$decimal = 203\r\n$prompt $" {
260 pass "print 'scope1.c'::foo::funclocal_ro" }
261 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
262 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
265 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro" ; return }
267 fail "(timeout) print 'scope1.c'::foo::funclocal_ro" ; return
271 # Print scope1.c::bar::funclocal, which is 4
273 send_gdb "print bar::funclocal\n"
275 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print bar::funclocal" }
276 -re "$prompt $" { fail "print bar::funclocal" ; return }
278 fail "(timeout) print bar::funclocal" ; return
282 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
283 send_gdb "print 'scope1.c'::bar::funclocal\n"
285 -re "\\\$$decimal = 4\r\n$prompt $" {
286 pass "print 'scope1.c'::bar::funclocal"
288 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
289 send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
292 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal" ; return }
294 fail "(timeout) print 'scope1.c'::bar::funclocal" ; return
299 proc test_at_foo {} {
309 -re ".*bar \\(\\);\r\n$prompt $" {}
310 -re "$prompt $" { fail "continue to foo()" ; return }
311 timeout { fail "(timeout) continue to foo()" ; return }
314 # Print scope0.c::filelocal, which is 1
316 send_gdb "print 'scope0.c'::filelocal\n"
318 -re "\\\$$decimal = 1\r\n$prompt $" {
319 pass "print 'scope0.c'::filelocal at foo"
321 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
322 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal\n"
325 -re "$prompt $" { fail "print 'scope0.c'::filelocal at foo" ; return }
327 fail "(timeout) print 'scope0.c'::filelocal at foo" ; return
331 # Print scope0.c::filelocal_bss, which is 101
333 send_gdb "print 'scope0.c'::filelocal_bss\n"
335 -re "\\\$$decimal = 101\r\n$prompt $" {
336 pass "print 'scope0.c'::filelocal_bss in test_at_foo"
338 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
339 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
343 fail "print 'scope0.c'::filelocal_bss in test_at_foo"
347 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_foo"
352 # Print scope0.c::filelocal_ro, which is 201
354 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
355 setup_xfail "powerpc-*-*"
356 send_gdb "print 'scope0.c'::filelocal_ro\n"
358 -re "\\\$$decimal = 201\r\n$prompt $" { pass "print 'scope0.c'::filelocal_ro" }
359 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
360 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
363 -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
365 fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
369 gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo"
371 # Print scope1.c::filelocal, which is 2
373 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
374 send_gdb "print 'scope1.c'::filelocal\n"
376 -re "\\\$$decimal = 2\r\n$prompt $" {
377 pass "print 'scope1.c'::filelocal at foo"
379 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
380 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal\n"
383 -re "$prompt $" { fail "print 'scope1.c'::filelocal at foo" ; return }
385 fail "(timeout) print 'scope1.c'::filelocal at foo" ; return
389 gdb_test "print filelocal_bss" "\\\$$decimal = 102" \
390 "print filelocal_bss at foo"
392 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
393 send_gdb "print 'scope1.c'::filelocal_bss\n"
395 -re "\\\$$decimal = 102\r\n$prompt $" {
396 pass "print 'scope1.c'::filelocal_bss at foo"
398 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
399 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
402 -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss at foo" }
404 fail "(timeout) print 'scope1.c'::filelocal_bss at foo"
408 gdb_test "print filelocal_ro" "\\\$$decimal = 202" \
409 "print filelocal_ro at foo"
411 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
412 send_gdb "print 'scope1.c'::filelocal_ro\n"
414 -re "\\\$$decimal = 202\r\n$prompt $" { pass "print 'scope1.c'::filelocal_ro at foo" }
415 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
416 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
419 -re "$prompt $" { fail "print 'scope1.c'::filelocal_ro at foo" }
421 fail "(timeout) print 'scope1.c'::filelocal_ro at foo"
425 # Print scope1.c::foo::funclocal, which is 3
427 gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo"
429 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
430 gdb_test "print foo::funclocal" "\\\$$decimal = 3" \
431 "print foo::funclocal at foo"
433 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
434 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
435 send_gdb "print 'scope1.c'::foo::funclocal\n"
437 -re "\\\$$decimal = 3\r\n$prompt $" {
438 pass "print 'scope1.c'::foo::funclocal at foo"
440 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
441 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
444 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal at foo" }
446 fail "(timeout) print 'scope1.c'::foo::funclocal at foo"
450 # Print scope1.c::foo::funclocal_bss, which is 103
452 gdb_test "print funclocal_bss" "\\\$$decimal = 103" \
453 "print funclocal_bss at foo"
455 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
456 gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \
457 "print foo::funclocal_bss at foo"
459 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
460 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
461 send_gdb "print 'scope1.c'::foo::funclocal_bss\n"
463 -re "\\\$$decimal = 103\r\n$prompt $" {
464 pass "print 'scope1.c'::foo::funclocal_bss at foo"
466 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
467 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n"
471 fail "print 'scope1.c'::foo::funclocal_bss at foo"
474 fail "(timeout) print 'scope1.c'::foo::funclocal_bss at foo"
478 # Print scope1.c::foo::funclocal_ro, which is 203
480 gdb_test "print funclocal_ro" "\\\$$decimal = 203" \
481 "print funclocal_ro at foo"
483 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
484 gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \
485 "print foo::funclocal_ro at foo"
487 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
488 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
489 send_gdb "print 'scope1.c'::foo::funclocal_ro\n"
491 -re "\\\$$decimal = 203\r\n$prompt $" {
492 pass "print 'scope1.c'::foo::funclocal_ro at foo"
494 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
495 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
498 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro at foo" }
500 fail "(timeout) print 'scope1.c'::foo::funclocal_ro at foo"
504 # Print scope1.c::bar::funclocal, which is 4
506 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
507 gdb_test "print bar::funclocal" "\\\$$decimal = 4" \
508 "print bar::funclocal at foo"
510 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
511 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
512 send_gdb "print 'scope1.c'::bar::funclocal\n"
514 -re "\\\$$decimal = 4\r\n$prompt $" {
515 pass "print 'scope1.c'::bar::funclocal at foo"
517 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
518 send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
521 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal at foo" }
523 fail "(timeout) print 'scope1.c'::bar::funclocal at foo"
528 proc test_at_bar {} {
539 timeout { fail "(timeout) next in bar()" ; return }
542 # Print scope0.c::filelocal, which is 1
544 send_gdb "print 'scope0.c'::filelocal\n"
546 -re "\\\$$decimal = 1\r\n$prompt $" {
547 pass "print 'scope0.c'::filelocal at bar"
549 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
550 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal\n"
554 fail "print 'scope0.c'::filelocal at bar" ; return
557 fail "(timeout) print 'scope0.c'::filelocal at bar" ; return
561 # Print scope0.c::filelocal_bss, which is 101
563 send_gdb "print 'scope0.c'::filelocal_bss\n"
565 -re "\\\$$decimal = 101\r\n$prompt $" {
566 pass "print 'scope0.c'::filelocal_bss in test_at_bar"
568 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
569 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
573 fail "print 'scope0.c'::filelocal_bss in test_at_bar"
577 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_bar"
582 # Print scope0.c::filelocal_ro, which is 201
584 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
585 setup_xfail "powerpc-*-*"
586 send_gdb "print 'scope0.c'::filelocal_ro\n"
588 -re "\\\$$decimal = 201\r\n$prompt $" {
589 pass "print 'scope0.c'::filelocal_ro at bar"
591 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
592 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
596 fail "print 'scope0.c'::filelocal_ro at bar" ; return
599 fail "(timeout) print 'scope0.c'::filelocal_ro at bar" ; return
603 # Print scope1.c::filelocal, which is 2
605 send_gdb "print filelocal\n"
607 -re "\\\$$decimal = 2\r\n$prompt $" {
608 pass "print filelocal at bar"
611 fail "print filelocal at bar" ; return
614 fail "(timeout) print filelocal at bar" ; return
618 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
619 send_gdb "print 'scope1.c'::filelocal\n"
621 -re "\\\$$decimal = 2\r\n$prompt $" {
622 pass "print 'scope1.c'::filelocal at bar"
624 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
625 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal\n"
629 fail "print 'scope1.c'::filelocal at bar" ; return
632 fail "(timeout) print 'scope1.c'::filelocal at bar" ; return
636 # Print scope1.c::filelocal_bss, which is 102
638 send_gdb "print filelocal_bss\n"
640 -re "\\\$$decimal = 102\r\n$prompt $" {
641 pass "print filelocal_bss at bar"
644 fail "print filelocal_bss at bar" ; return
647 fail "(timeout) print filelocal_bss at bar" ; return
651 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
652 send_gdb "print 'scope1.c'::filelocal_bss\n"
654 -re "\\\$$decimal = 102\r\n$prompt $" {
655 pass "print 'scope1.c'::filelocal_bss at bar"
657 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
658 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
662 fail "print 'scope1.c'::filelocal_bss at bar" ; return
665 fail "(timeout) print 'scope1.c'::filelocal_bss at bar" ; return
669 # Print scope1.c::filelocal_ro, which is 202
671 send_gdb "print filelocal_ro\n"
673 -re "\\\$$decimal = 202\r\n$prompt $" {
674 pass "print filelocal_ro in test_at_bar"
677 fail "print filelocal_ro in test_at_bar"
681 fail "(timeout) print filelocal_ro in test_at_bar"
686 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
687 send_gdb "print 'scope1.c'::filelocal_ro\n"
689 -re "\\\$$decimal = 202\r\n$prompt $" {
690 pass "print 'scope1.c'::filelocal_ro at bar"
692 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
693 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
697 fail "print 'scope1.c'::filelocal_ro at bar" ; return
700 fail "(timeout) print 'scope1.c'::filelocal_ro at bar" ; return
704 # Print scope1.c::foo::funclocal, which is 3
706 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
707 send_gdb "print foo::funclocal\n"
709 -re "\\\$$decimal = 3\r\n$prompt $" {
710 pass "print foo::funclocal at bar"
713 fail "print foo::funclocal at bar" ; return
716 fail "(timeout) print foo::funclocal at bar" ; return
720 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
721 send_gdb "print 'scope1.c'::foo::funclocal\n"
723 -re "\\\$$decimal = 3\r\n$prompt $" {
724 pass "print 'scope1.c'::foo::funclocal at bar"
726 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
727 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
731 fail "print 'scope1.c'::foo::funclocal at bar" ; return
734 fail "(timeout) print 'scope1.c'::foo::funclocal at bar" ; return
738 # Print scope1.c::foo::funclocal_bss, which is 103
740 send_gdb "print foo::funclocal_bss\n"
742 -re "\\\$$decimal = 103\r\n$prompt $" {
743 pass "print foo::funclocal_bss at bar"
746 fail "print foo::funclocal_bss at bar" ; return
749 fail "(timeout) print foo::funclocal_bss at bar" ; return
753 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
754 send_gdb "print 'scope1.c'::foo::funclocal_bss\n"
756 -re "\\\$$decimal = 103\r\n$prompt $" {
757 pass "print 'scope1.c'::foo::funclocal_bss at bar"
759 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
760 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n"
764 fail "print 'scope1.c'::foo::funclocal_bss at bar" ; return
767 fail "(timeout) print 'scope1.c'::foo::funclocal_bss at bar" ; return
771 # Print scope1.c::foo::funclocal_ro, which is 203
773 send_gdb "print foo::funclocal_ro\n"
775 -re "\\\$$decimal = 203\r\n$prompt $" {
776 pass "print foo::funclocal_ro at bar"
779 fail "print foo::funclocal_ro at bar" ; return
782 fail "(timeout) print foo::funclocal_ro at bar" ; return
786 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
787 send_gdb "print 'scope1.c'::foo::funclocal_ro\n"
789 -re "\\\$$decimal = 203\r\n$prompt $" {
790 pass "print 'scope1.c'::foo::funclocal_ro at bar"
792 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
793 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
797 fail "print 'scope1.c'::foo::funclocal_ro at bar" ; return
800 fail "(timeout) print 'scope1.c'::foo::funclocal_ro at bar" ; return
804 # Print scope1.c::bar::funclocal, which is 4
806 send_gdb "print funclocal\n"
808 -re "\\\$$decimal = 4\r\n$prompt $" {
809 pass "print funclocal at bar"
812 fail "print funclocal at bar" ; return
815 fail "(timeout) print funclocal at bar" ; return
819 send_gdb "print bar::funclocal\n"
821 -re "\\\$$decimal = 4\r\n$prompt $" {
822 pass "print bar::funclocal at bar"
825 fail "print bar::funclocal at bar" ; return
828 fail "(timeout) print bar::funclocal at bar" ; return
832 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
833 send_gdb "print 'scope1.c'::bar::funclocal\n"
835 -re "\\\$$decimal = 4\r\n$prompt $" {
836 pass "print 'scope1.c'::bar::funclocal at bar"
838 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
839 send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
843 fail "print 'scope1.c'::bar::funclocal at bar" ; return
846 fail "(timeout) print 'scope1.c'::bar::funclocal at bar" ; return
850 # Print scope1.c::bar::funclocal_bss, which is 104
852 send_gdb "print funclocal_bss\n"
854 -re "\\\$$decimal = 104\r\n$prompt $" {
855 pass "print funclocal_bss at bar"
858 fail "print funclocal_bss at bar" ; return
861 fail "(timeout) print funclocal_bss at bar" ; return
865 send_gdb "print bar::funclocal_bss\n"
867 -re "\\\$$decimal = 104\r\n$prompt $" {
868 pass "print bar::funclocal_bss at bar"
871 fail "print bar::funclocal_bss at bar" ; return
874 fail "(timeout) print bar::funclocal_bss at bar" ; return
878 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
879 send_gdb "print 'scope1.c'::bar::funclocal_bss\n"
881 -re "\\\$$decimal = 104\r\n$prompt $" {
882 pass "print 'scope1.c'::bar::funclocal_bss at bar"
884 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
885 send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal_bss\n"
889 fail "print 'scope1.c'::bar::funclocal_bss at bar" ; return
892 fail "(timeout) print 'scope1.c'::bar::funclocal_bss at bar" ; return
897 # This test has little to do with local scopes, but it is in scope.exp anyway.
900 proc test_at_autovars {} {
906 # Test symbol table lookup with 100 local (auto) variables.
908 send_gdb "break marker1\n" ; expect -re ".*$prompt $"
912 -re "Break.* marker1 \\(\\) at .*:$decimal.*$prompt $" {
916 timeout { fail "(timeout) up from marker1" ; return }
919 -re "$prompt $" { fail "continue to marker1" ; return }
920 timeout { fail "(timeout) continue to marker1" ; return }
924 while {$count < 100} {
925 send_gdb "print i$count\n"
927 -re ".* = $count\r\n$prompt $" {}
929 fail "bad value for auto variable i$count"; return
932 fail "(timeout) bad value for auto variable i$count"; return
935 set count [expr $count+1]
938 pass "$count auto variables correctly initialized"
940 # Test that block variable sorting is not screwing us.
941 gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order"
944 proc test_at_localscopes {} {
950 send_gdb "break marker2\n" ; expect -re ".*$prompt $"
951 send_gdb "break marker3\n" ; expect -re ".*$prompt $"
952 send_gdb "break marker4\n" ; expect -re ".*$prompt $"
956 -re "Break.* marker2 \\(\\) at .*:$decimal.*$prompt $" {
960 timeout { fail "(timeout) up from marker2" ; return }
963 -re "$prompt $" { fail "continue to marker2" ; return }
964 timeout { fail "(timeout) continue to marker2" ; return }
967 # Should be at first (outermost) scope. Check values.
969 gdb_test "print localval" " = 10" "print localval, outer scope"
970 gdb_test "print localval1" " = 11" "print localval1, outer scope"
971 gdb_test "print localval2" "No symbol \"localval2\" in current context." \
972 "print localval2, outer scope"
973 gdb_test "print localval3" "No symbol \"localval3\" in current context." \
974 "print localval3, outer scope"
976 if [gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \
977 "continue to marker3 in scope.exp"] then { return }
978 if [gdb_test "up" "" "up from marker3 in scope.exp"] then { return }
980 # Should be at next (first nested) scope. Check values.
982 gdb_test "print localval" " = 20" \
983 "print localval, first nested scope"
984 gdb_test "print localval1" " = 11" "print localval1, first nested scope"
985 gdb_test "print localval2" " = 12" "print localval2, first nested scope"
986 gdb_test "print localval3" "No symbol \"localval3\" in current context." \
987 "print localval3, first nested scope"
989 # This test will only fail if the file was compiled by gcc, but
990 # there's no way to check that.
991 setup_xfail "a29k-*-udi" 2423
992 if [gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \
993 "continue to marker4 in scope.exp"] then { return }
994 if [gdb_test "up" "" "up from marker4 in scope.exp"] then { return }
996 gdb_test "print localval" " = 30" "print localval, innermost scope"
997 gdb_test "print localval1" " = 11" "print localval1, innermost scope"
998 gdb_test "print localval2" " = 12" "print localval2, innermost scope"
999 gdb_test "print localval3" " = 13" "print localval3, innermost scope"
1002 # Start with a fresh gdb.
1006 gdb_reinitialize_dir $srcdir/$subdir
1009 if [istarget "*-*-vxworks*"] {
1011 verbose "Timeout is now $timeout seconds" 2
1014 # Test that variables in various segments print out correctly before
1015 # the program is run.
1017 # AIX--sections get mapped to the same address so we can't get the right one.
1018 setup_xfail "rs6000-*-*"
1019 setup_xfail "powerpc-*-*"
1021 gdb_test "print 'scope0.c'::filelocal_ro" "= 201"
1023 # gdb currently cannot access bss memory on some targets if the inferior
1026 # For PA boards using monitor/remote-pa.c, the bss test is going to
1027 # randomly fail. We've already put remote-pa on the target stack,
1028 # so we actually read memory from the board. Problem is crt0.o
1029 # is responsible for clearing bss and that hasnt' happened yet.
1030 setup_xfail "hppa*-*-*pro*"
1031 send_gdb "print 'scope0.c'::filelocal_bss\n"
1033 -re " = 0\r\n$prompt $" {
1034 pass "print 'scope0.c'::filelocal_bss before run"
1036 -re "Cannot access memory.*$prompt $" {
1038 fail "print 'scope0.c'::filelocal_bss before run"
1041 fail "print 'scope0.c'::filelocal_bss before run"
1044 fail "print 'scope0.c'::filelocal_bss before run"
1048 gdb_test "print 'scope0.c'::filelocal" "= 1" \
1049 "print 'scope0.c'::filelocal before run"
1051 if [runto_main] then { test_at_main }
1052 if [istarget "mips-idt-*"] then {
1053 # Restart because IDT/SIM runs out of file descriptors.
1056 gdb_reinitialize_dir $srcdir/$subdir
1059 if [runto foo] then { test_at_foo }
1060 if [istarget "mips-idt-*"] then {
1061 # Restart because IDT/SIM runs out of file descriptors.
1064 gdb_reinitialize_dir $srcdir/$subdir
1067 if [runto bar] then { test_at_bar }
1068 if [istarget "mips-idt-*"] then {
1069 # Restart because IDT/SIM runs out of file descriptors.
1072 gdb_reinitialize_dir $srcdir/$subdir
1075 if [runto localscopes] then { test_at_localscopes }
1076 if [istarget "mips-idt-*"] then {
1077 # Restart because IDT/SIM runs out of file descriptors.
1080 gdb_reinitialize_dir $srcdir/$subdir
1083 if [runto autovars] then { test_at_autovars }
1085 if [istarget "*-*-vxworks*"] {
1087 verbose "Timeout is now $timeout seconds" 2