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., 675 Mass Ave, Cambridge, MA 02139, 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 # Test locating various things when stopped just inside main, after
38 # running init(). To prevent cascading of errors, we report the
39 # first one and quit. If all pass, then we print the pass results.
41 proc test_at_main {} {
48 # skip past init. There may be a call to __main at the start of
49 # main, so the first next may only get us to the init call.
52 -re "$decimal.*foo \\(\\);\r\n$prompt $" {
53 pass "next over init() in main"
55 -re "$decimal.*init \\(\\);\r\n$prompt $"\
56 { send "next\n" ; exp_continue }
57 -re "$prompt $" { fail "next over init() in main" ; return }
58 timeout { fail "(timeout) next over init() in main" ; return }
61 # Print scope0.c::filelocal, which is 1
63 send "print filelocal\n"
65 -re "\\\$$decimal = 1\r\n$prompt $" { pass "print filelocal" }
66 -re "$prompt $" { fail "print filelocal" ; return }
68 fail "(timeout) print filelocal" ; return
72 # The RS/6000 does not seem to be handle print 'file'::var.
73 setup_xfail "rs6000-*-*"
74 send "print 'scope0.c'::filelocal\n"
76 -re "\\\$$decimal = 1\r\n$prompt $" {
77 pass "print 'scope0.c'::filelocal at main"
79 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
80 send "print '$srcdir/$subdir/scope0.c'::filelocal\n"
83 -re "$prompt $" { fail "print 'scope0.c'::filelocal at main" ; return }
85 fail "(timeout) print 'scope0.c'::filelocal at main" ; return
89 # Print scope0.c::filelocal_bss, which is 101
91 send "print filelocal_bss\n"
93 -re "\\\$$decimal = 101\r\n$prompt $" {
94 pass "print filelocal_bss"
96 -re "$prompt $" { fail "print filelocal_bss" ; return }
98 fail "(timeout) print filelocal_bss" ; return
102 setup_xfail "rs6000-*-*"
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 send "print filelocal_ro\n"
125 -re "\\\$$decimal = 201\r\n$prompt $" { pass "print filelocal_ro" }
126 -re "$prompt $" { fail "print filelocal_ro" ; return }
128 fail "(timeout) print filelocal_ro" ; return
132 setup_xfail "rs6000-*-*"
133 send "print 'scope0.c'::filelocal_ro\n"
135 -re "\\\$$decimal = 201\r\n$prompt $" {
136 pass "print 'scope0.c'::filelocal_ro"
138 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
139 send "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
142 -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
144 fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
148 # Print scope1.c::filelocal, which is 2
150 setup_xfail "rs6000-*-*"
151 send "print 'scope1.c'::filelocal\n"
153 -re "\\\$$decimal = 2\r\n$prompt $" {
154 pass "print 'scope1.c'::filelocal"
156 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
157 send "print '$srcdir/$subdir/scope1.c'::filelocal\n"
160 -re "$prompt $" { fail "print 'scope1.c'::filelocal" ; return }
162 fail "(timeout) print 'scope1.c'::filelocal" ; return
166 # Print scope1.c::filelocal_bss, which is 102
168 setup_xfail "rs6000-*-*"
169 send "print 'scope1.c'::filelocal_bss\n"
171 -re "\\\$$decimal = 102\r\n$prompt $" {
172 pass "print 'scope1.c'::filelocal_bss"
174 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
175 send "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
178 -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss" ; return }
180 fail "(timeout) print 'scope1.c'::filelocal_bss" ; return
184 # Print scope1.c::filelocal_ro, which is 202
186 setup_xfail "rs6000-*-*"
187 send "print 'scope1.c'::filelocal_ro\n"
189 -re "\\\$$decimal = 202\r\n$prompt $" {
190 pass "print 'scope1.c'::filelocal_ro"
192 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
193 send "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
196 -re "$prompt " {fail "print 'scope1.c'::filelocal_ro" ; return }
198 fail "(timeout) print 'scope1.c'::filelocal_ro" ; return
202 # Print scope1.c::foo::funclocal, which is 3
204 send "print foo::funclocal\n"
206 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print foo::funclocal" }
207 -re "$prompt $" { fail "print foo::funclocal" ; return }
209 fail "(timeout) print foo::funclocal" ; return
213 setup_xfail "rs6000-*-*"
214 send "print 'scope1.c'::foo::funclocal\n"
216 -re "\\\$$decimal = 3\r\n$prompt $" {
217 pass "print 'scope1.c'::foo::funclocal"
219 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
220 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
223 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal" ; return }
225 fail "(timeout) print 'scope1.c'::foo::funclocal" ; return
229 # Print scope1.c::foo::funclocal_ro, which is 203
231 send "print foo::funclocal_ro\n"
233 -re "\\\$$decimal = 203\r\n$prompt $" {
234 pass "print foo::funclocal_ro"
236 -re "$prompt $" { fail "print foo::funclocal_ro" ; return }
238 fail "(timeout) print foo::funclocal_ro" ; return
242 setup_xfail "rs6000-*-*"
243 send "print 'scope1.c'::foo::funclocal_ro\n"
245 -re "\\\$$decimal = 203\r\n$prompt $" {
246 pass "print 'scope1.c'::foo::funclocal_ro" }
247 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
248 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
251 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro" ; return }
253 fail "(timeout) print 'scope1.c'::foo::funclocal_ro" ; return
257 # Print scope1.c::bar::funclocal, which is 4
259 send "print bar::funclocal\n"
261 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print bar::funclocal" }
262 -re "$prompt $" { fail "print bar::funclocal" ; return }
264 fail "(timeout) print bar::funclocal" ; return
268 setup_xfail "rs6000-*-*"
269 send "print 'scope1.c'::bar::funclocal\n"
271 -re "\\\$$decimal = 4\r\n$prompt $" {
272 pass "print 'scope1.c'::bar::funclocal"
274 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
275 send "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
278 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal" ; return }
280 fail "print 'scope1.c'::bar::funclocal" ; return
285 proc test_at_foo {} {
294 -re ".*bar \\(\\);\r\n$prompt $" {}
295 -re "$prompt $" { fail "continue to foo()" ; return }
296 timeout { fail "(timeout) continue to foo()" ; return }
299 # Print scope0.c::filelocal, which is 1
301 setup_xfail "rs6000-*-*"
302 send "print 'scope0.c'::filelocal\n"
304 -re "\\\$$decimal = 1\r\n$prompt $" {
305 pass "print 'scope0.c'::filelocal at foo"
307 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
308 send "print '$srcdir/$subdir/scope0.c'::filelocal\n"
311 -re "$prompt $" { fail "print 'scope0.c'::filelocal at foo" ; return }
313 fail "(timeout) print 'scope0.c'::filelocal at foo" ; return
317 # Print scope0.c::filelocal_bss, which is 101
319 setup_xfail "rs6000-*-*"
320 send "print 'scope0.c'::filelocal_bss\n"
322 -re "\\\$$decimal = 101\r\n$prompt $" {
323 pass "print 'scope0.c'::filelocal_bss in test_at_foo"
325 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
326 send "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
330 fail "print 'scope0.c'::filelocal_bss in test_at_foo"
334 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_foo"
339 # Print scope0.c::filelocal_ro, which is 201
341 setup_xfail "rs6000-*-*"
342 send "print 'scope0.c'::filelocal_ro\n"
344 -re "\\\$$decimal = 201\r\n$prompt $" { pass "print 'scope0.c'::filelocal_ro" }
345 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
346 send "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
349 -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
351 fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
355 # Print scope1.c::filelocal, which is 2
357 send "print filelocal\n"
359 -re "\\\$$decimal = 2\r\n$prompt $" { pass "print filelocal" }
360 -re "$prompt $" { fail "print filelocal" ; return }
362 fail "(timeout) print filelocal" ; return
366 setup_xfail "rs6000-*-*"
367 send "print 'scope1.c'::filelocal\n"
369 -re "\\\$$decimal = 2\r\n$prompt $" { pass "print 'scope1.c'::filelocal" }
370 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
371 send "print '$srcdir/$subdir/scope1.c'::filelocal\n"
374 -re "$prompt $" { fail "print 'scope1.c'::filelocal" ; return }
376 fail "(timeout) print 'scope1.c'::filelocal" ; return
380 # Print scope1.c::filelocal_bss, which is 102
382 send "print filelocal_bss\n"
384 -re "\\\$$decimal = 102\r\n$prompt $" { pass "print filelocal_bss" }
385 -re "$prompt $" { fail "print filelocal_bss" ; return }
387 fail "(timeout) print filelocal_bss" ; return
391 setup_xfail "rs6000-*-*"
392 send "print 'scope1.c'::filelocal_bss\n"
394 -re "\\\$$decimal = 102\r\n$prompt $" { pass "print 'scope1.c'::filelocal_bss" }
395 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
396 send "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
399 -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss" ; return }
401 fail "(timeout) print 'scope1.c'::filelocal_bss" ; return
405 # Print scope1.c::filelocal_ro, which is 202
407 send "print filelocal_ro\n"
409 -re "\\\$$decimal = 202\r\n$prompt $" { pass "print filelocal_ro" }
410 -re "$prompt $" { fail "print filelocal_ro" ; return }
412 fail "(timeout) print filelocal_ro" ; return
416 setup_xfail "rs6000-*-*"
417 send "print 'scope1.c'::filelocal_ro\n"
419 -re "\\\$$decimal = 202\r\n$prompt $" { pass "print 'scope1.c'::filelocal_ro" }
420 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
421 send "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
424 -re "$prompt $" { fail "print 'scope1.c'::filelocal_ro" ; return }
426 fail "(timeout) print 'scope1.c'::filelocal_ro" ; return
430 # Print scope1.c::foo::funclocal, which is 3
432 send "print funclocal\n"
434 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print funclocal" }
435 -re "$prompt $" { fail "print funclocal" ; return }
437 fail "(timeout) print funclocal" ; return
441 send "print foo::funclocal\n"
443 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print foo::funclocal" }
444 -re "$prompt $" { fail "print foo::funclocal" ; return }
446 fail "(timeout) print foo::funclocal" ; return
450 setup_xfail "rs6000-*-*"
451 send "print 'scope1.c'::foo::funclocal\n"
453 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal" }
454 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
455 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
458 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal" ; return }
460 fail "(timeout) print 'scope1.c'::foo::funclocal" ; return
464 # Print scope1.c::foo::funclocal_bss, which is 103
466 send "print funclocal_bss\n"
468 -re "\\\$$decimal = 103\r\n$prompt $" { pass "print funclocal_bss" }
469 -re "$prompt $" { fail "print funclocal_bss" ; return }
471 fail "(timeout) print funclocal_bss" ; return
475 send "print foo::funclocal_bss\n"
477 -re "\\\$$decimal = 103\r\n$prompt $" { pass "print foo::funclocal_bss" }
478 -re "$prompt $" { fail "print foo::funclocal_bss" ; return }
480 fail "(timeout) print foo::funclocal_bss" ; return
484 setup_xfail "rs6000-*-*"
485 send "print 'scope1.c'::foo::funclocal_bss\n"
487 -re "\\\$$decimal = 103\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal_bss" }
488 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
489 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n"
492 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_bss" ; return }
494 fail "(timeout) print 'scope1.c'::foo::funclocal_bss" ; return
498 # Print scope1.c::foo::funclocal_ro, which is 203
500 send "print funclocal_ro\n"
502 -re "\\\$$decimal = 203\r\n$prompt $" { pass "print funclocal_ro" }
503 -re "$prompt $" { fail "print funclocal_ro" ; return }
505 fail "(timeout) print funclocal_ro" ; return
509 send "print foo::funclocal_ro\n"
511 -re "\\\$$decimal = 203\r\n$prompt $" { pass "print foo::funclocal_ro" }
512 -re "$prompt $" { fail "print foo::funclocal_ro" ; return }
514 fail "(timeout) print foo::funclocal_ro" ; return
518 setup_xfail "rs6000-*-*"
519 send "print 'scope1.c'::foo::funclocal_ro\n"
521 -re "\\\$$decimal = 203\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal_ro" }
522 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
523 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
526 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro" ; return }
528 fail "(timeout) print 'scope1.c'::foo::funclocal_ro" ; return
532 # Print scope1.c::bar::funclocal, which is 4
534 send "print bar::funclocal\n"
536 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print bar::funclocal" }
537 -re "$prompt $" { fail "print bar::funclocal" ; return }
539 fail "(timeout) print bar::funclocal" ; return
543 setup_xfail "rs6000-*-*"
544 send "print 'scope1.c'::bar::funclocal\n"
546 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print 'scope1.c'::bar::funclocal" }
547 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
548 send "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
551 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal" ; return }
553 fail "(timeout) print 'scope1.c'::bar::funclocal" ; return
558 proc test_at_bar {} {
568 timeout { fail "next in bar()" ; return }
571 # Print scope0.c::filelocal, which is 1
573 setup_xfail "rs6000-*-*"
574 send "print 'scope0.c'::filelocal\n"
576 -re "\\\$$decimal = 1\r\n$prompt $" {
577 pass "print 'scope0.c'::filelocal at bar"
579 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
580 send "print '$srcdir/$subdir/scope0.c'::filelocal\n"
583 -re "$prompt $" { fail "print 'scope0.c'::filelocal at bar" ; return }
585 fail "(timeout) print 'scope0.c'::filelocal at bar" ; return
589 # Print scope0.c::filelocal_bss, which is 101
591 setup_xfail "rs6000-*-*"
592 send "print 'scope0.c'::filelocal_bss\n"
594 -re "\\\$$decimal = 101\r\n$prompt $" {
595 pass "print 'scope0.c'::filelocal_bss in test_at_bar"
597 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
598 send "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
602 fail "print 'scope0.c'::filelocal_bss in test_at_bar"
606 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_bar"
611 # Print scope0.c::filelocal_ro, which is 201
613 setup_xfail "rs6000-*-*"
614 send "print 'scope0.c'::filelocal_ro\n"
616 -re "\\\$$decimal = 201\r\n$prompt $" { pass "print 'scope0.c'::filelocal_ro" }
617 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
618 send "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
621 -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
623 fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
627 # Print scope1.c::filelocal, which is 2
629 send "print filelocal\n"
631 -re "\\\$$decimal = 2\r\n$prompt $" { pass "print filelocal" }
632 -re "$prompt $" { fail "print filelocal" ; return }
634 fail "(timeout) print filelocal" ; return
638 setup_xfail "rs6000-*-*"
639 send "print 'scope1.c'::filelocal\n"
641 -re "\\\$$decimal = 2\r\n$prompt $" { pass "print 'scope1.c'::filelocal" }
642 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
643 send "print '$srcdir/$subdir/scope1.c'::filelocal\n"
646 -re "$prompt $" { fail "print 'scope1.c'::filelocal" ; return }
648 fail "(timeout) print 'scope1.c'::filelocal" ; return
652 # Print scope1.c::filelocal_bss, which is 102
654 send "print filelocal_bss\n"
656 -re "\\\$$decimal = 102\r\n$prompt $" { pass "print filelocal_bss" }
657 -re "$prompt $" { fail "print filelocal_bss" ; return }
659 fail "(timeout) print filelocal_bss" ; return
663 setup_xfail "rs6000-*-*"
664 send "print 'scope1.c'::filelocal_bss\n"
666 -re "\\\$$decimal = 102\r\n$prompt $" { pass "print 'scope1.c'::filelocal_bss" }
667 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
668 send "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
671 -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss" ; return }
673 fail "(timeout) print 'scope1.c'::filelocal_bss" ; return
677 # Print scope1.c::filelocal_ro, which is 202
679 send "print filelocal_ro\n"
681 -re "\\\$$decimal = 202\r\n$prompt $" { pass "print filelocal_ro" }
682 -re "$prompt $" { fail "print filelocal_ro" ; return }
684 fail "(timeout) print filelocal_ro" ; return
688 setup_xfail "rs6000-*-*"
689 send "print 'scope1.c'::filelocal_ro\n"
691 -re "\\\$$decimal = 202\r\n$prompt $" { pass "print 'scope1.c'::filelocal_ro" }
692 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
693 send "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
696 -re "$prompt $" { fail "print 'scope1.c'::filelocal_ro" ; return }
698 fail "(timeout) print 'scope1.c'::filelocal_ro" ; return
702 # Print scope1.c::foo::funclocal, which is 3
704 send "print foo::funclocal\n"
706 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print foo::funclocal" }
707 -re "$prompt $" { fail "print foo::funclocal" ; return }
709 fail "(timeout) print foo::funclocal" ; return
713 setup_xfail "rs6000-*-*"
714 send "print 'scope1.c'::foo::funclocal\n"
716 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal" }
717 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
718 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
721 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal" ; return }
723 fail "(timeout) print 'scope1.c'::foo::funclocal" ; return
727 # Print scope1.c::foo::funclocal_bss, which is 103
729 send "print foo::funclocal_bss\n"
731 -re "\\\$$decimal = 103\r\n$prompt $" { pass "print foo::funclocal_bss" }
732 -re "$prompt $" { fail "print foo::funclocal_bss" ; return }
734 fail "(timeout) print foo::funclocal_bss" ; return
738 setup_xfail "rs6000-*-*"
739 send "print 'scope1.c'::foo::funclocal_bss\n"
741 -re "\\\$$decimal = 103\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal_bss" }
742 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
743 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n"
746 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_bss" ; return }
748 fail "(timeout) print 'scope1.c'::foo::funclocal_bss" ; return
752 # Print scope1.c::foo::funclocal_ro, which is 203
754 send "print foo::funclocal_ro\n"
756 -re "\\\$$decimal = 203\r\n$prompt $" { pass "print foo::funclocal_ro" }
757 -re "$prompt $" { fail "print foo::funclocal_ro" ; return }
759 fail "(timeout) print foo::funclocal_ro" ; return
763 setup_xfail "rs6000-*-*"
764 send "print 'scope1.c'::foo::funclocal_ro\n"
766 -re "\\\$$decimal = 203\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal_ro" }
767 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
768 send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
771 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro" ; return }
773 fail "(timeout) print 'scope1.c'::foo::funclocal_ro" ; return
777 # Print scope1.c::bar::funclocal, which is 4
779 send "print funclocal\n"
781 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print funclocal" }
782 -re "$prompt $" { fail "print funclocal" ; return }
784 fail "(timeout) print funclocal" ; return
788 send "print bar::funclocal\n"
790 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print bar::funclocal" }
791 -re "$prompt $" { fail "print bar::funclocal" ; return }
793 fail "(timeout) print bar::funclocal" ; return
797 setup_xfail "rs6000-*-*"
798 send "print 'scope1.c'::bar::funclocal\n"
800 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print 'scope1.c'::bar::funclocal" }
801 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
802 send "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
805 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal" ; return }
807 fail "(timeout) print 'scope1.c'::bar::funclocal" ; return
811 # Print scope1.c::bar::funclocal_bss, which is 104
813 send "print funclocal_bss\n"
815 -re "\\\$$decimal = 104\r\n$prompt $" { pass "print funclocal_bss" }
816 -re "$prompt $" { fail "print funclocal_bss" ; return }
818 fail "(timeout) print funclocal_bss" ; return
822 send "print bar::funclocal_bss\n"
824 -re "\\\$$decimal = 104\r\n$prompt $" { pass "print bar::funclocal_bss" }
825 -re "$prompt $" { fail "print bar::funclocal_bss" ; return }
827 fail "(timeout) print bar::funclocal_bss" ; return
831 setup_xfail "rs6000-*-*"
832 send "print 'scope1.c'::bar::funclocal_bss\n"
834 -re "\\\$$decimal = 104\r\n$prompt $" { pass "print 'scope1.c'::bar::funclocal_bss" }
835 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
836 send "print '$srcdir/$subdir/scope1.c'::bar::funclocal_bss\n"
839 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal_bss" ; return }
841 fail "(timeout) print 'scope1.c'::bar::funclocal_bss" ; return
846 # FIXME: This test was originally part of some local scope resolution
847 # tests. It probably belongs somewhere else now.
849 proc test_at_autovars {} {
855 # Test symbol table lookup with 100 local (auto) variables.
857 send "break marker1\n" ; expect -re ".*$prompt $"
861 -re "Break.* marker1 \\(\\) at .*:$decimal.*$prompt $" {
865 timeout { fail "up from marker1" ; return }
868 -re "$prompt $" { fail "continue to marker1" ; return }
869 timeout { fail "(timeout) continue to marker1" ; return }
873 while {$count < 100} {
874 send "print i$count\n"
876 -re ".* = $count\r\n$prompt $" {}
878 fail "bad value for auto variable i$count"; return
881 fail "(timeout) bad value for auto variable i$count"; return
884 set count [expr $count+1]
887 pass "$count auto variables correctly initialized"
889 # Test that block variable sorting is not screwing us.
890 gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order"
893 proc test_at_localscopes {} {
899 send "break marker2\n" ; expect -re ".*$prompt $"
900 send "break marker3\n" ; expect -re ".*$prompt $"
901 send "break marker4\n" ; expect -re ".*$prompt $"
905 -re "Break.* marker2 \\(\\) at .*:$decimal.*$prompt $" {
909 timeout { fail "up from marker2" ; return }
912 -re "$prompt $" { fail "continue to marker2" ; return }
913 timeout { fail "(timeout) continue to marker2" ; return }
916 # Should be at first (outermost) scope. Check values.
918 send "print localval\n"
920 -re ".* = 10\r\n$prompt $" { pass "bad value for localval, outer scope" }
921 -re "$prompt $" { fail "bad value for localval, outer scope" ; return }
923 fail "(timeout) bad value for localval, outer scope" ; return
926 send "print localval1\n"
928 -re ".* = 11\r\n$prompt $" { pass "bad value for localval1" }
929 -re "$prompt $" { fail "bad value for localval1" ; return }
930 timeout { fail "(timeout) bad value for localval1" ; return }
932 send "print localval2\n"
934 -re "No symbol \"localval2\" in current context.\r\n$prompt $" {
935 pass "bad value for localval2"
937 -re "$prompt $" { fail "bad value for localval2" ; return }
938 timeout { fail "(timeout) bad value for localval2" ; return }
940 send "print localval3\n"
942 -re "No symbol \"localval3\" in current context.\r\n$prompt $" {
943 pass "bad value for localval3"
945 -re "$prompt $" { fail "bad value for localval3" ; return }
946 timeout { fail "(timeout) bad value for localval3" ; return }
951 -re "Break.* marker3 \\(\\) at .*:$decimal.*$prompt $" {
955 timeout { fail "up from marker3" ; return }
958 -re "$prompt $" { fail "continue to marker3" ; return }
959 timeout { fail "(timeout) continue to marker3" ; return }
962 # Should be at next (first nested) scope. Check values.
964 send "print localval\n"
966 -re ".* = 20\r\n$prompt $" { pass "bad value for localval, first nested scope" }
968 fail "bad value for localval, first nested scope" ; return
971 fail "(timeout) bad value for localval, first nested scope" ;
975 send "print localval1\n"
977 -re ".* = 11\r\n$prompt $" { pass "bad value for localval1" }
978 -re "$prompt $" { fail "bad value for localval1" ; return }
979 timeout { fail "(timeout) bad value for localval1" ; return }
981 send "print localval2\n"
983 -re ".* = 12\r\n$prompt $" { pass "bad value for localval2" }
984 -re "$prompt $" { fail "bad value for localval2" ; return }
985 timeout { fail "(timeout) bad value for localval2" ; return }
987 send "print localval3\n"
989 -re "No symbol \"localval3\" in current context.\r\n$prompt $" {
990 pass "bad value for localval3"
992 -re "$prompt $" { fail "bad value for localval3" ; return }
993 timeout { fail "(timeout) bad value for localval3" ; return }
996 # This test will only fail if the file was compiled by gcc, but
997 # there's no way to check that.
998 setup_xfail "a29k-*-udi" 2423
1001 -re "Break.* marker4.*at .*:$decimal.*$prompt $" {
1002 pass "continue to marker4"
1005 -re ".*$prompt $" { pass "up from marker4" }
1006 timeout { fail "up from marker4" ; return }
1009 -re "$prompt $" { fail "continue to marker4" ; return }
1010 timeout { fail "(timeout) continue to marker4" ; return }
1013 send "print localval\n"
1015 -re ".* = 30\r\n$prompt $" { pass "bad value for localval, innermost scope" }
1017 fail "bad value for localval, innermost scope" ; return
1020 fail "(timeout) bad value for localval, innermost scope" ; return
1023 send "print localval1\n"
1025 -re ".* = 11\r\n$prompt $" { pass "bad value for localval1" }
1026 -re "$prompt $" { fail "bad value for localval1" ; return }
1027 timeout { fail "(timeout) bad value for localval1" ; return }
1029 send "print localval2\n"
1031 -re ".* = 12\r\n$prompt $" { pass "bad value for localval2" }
1032 -re "$prompt $" { fail "bad value for localval2" ; return }
1033 timeout { fail "(timeout) bad value for localval2" ; return }
1035 send "print localval3\n"
1037 -re ".* = 13\r\n$prompt $" { pass "bad value for localval3" }
1038 -re "$prompt $" { fail "bad value for localval3" ; return }
1039 timeout { fail "(timeout) bad value for localval3" ; return }
1043 # Start with a fresh gdb.
1047 gdb_reinitialize_dir $srcdir/$subdir
1048 gdb_load $objdir/$subdir/$binfile
1050 if [istarget "*-*-vxworks*"] {
1054 # Test that variables in various segments print out correctly before
1055 # the program is run.
1057 # AIX--sections get mapped to the same address so we can't get the right one.
1058 setup_xfail "rs6000-*-*"
1060 gdb_test "print 'scope0.c'::filelocal_ro" "= 201"
1062 # gdb currently cannot access bss memory on some targets if the inferior
1064 send "print 'scope0.c'::filelocal_bss\n"
1066 -re " = 0\r\n$prompt $" {
1067 pass "print 'scope0.c'::filelocal_bss before run"
1069 -re "Cannot access memory.*$prompt $" {
1071 fail "print 'scope0.c'::filelocal_bss before run"
1074 fail "print 'scope0.c'::filelocal_bss before run"
1077 fail "print 'scope0.c'::filelocal_bss before run"
1081 # AIX--sections get mapped to the same address so we can't get the right one.
1082 setup_xfail "rs6000-*-*"
1084 gdb_test "print 'scope0.c'::filelocal" "= 1" \
1085 "print 'scope0.c'::filelocal before run"
1087 if [runto main] then { test_at_main }
1088 if [istarget "mips-idt-*"] then {
1089 # Restart because IDT/SIM runs out of file descriptors.
1092 gdb_reinitialize_dir $srcdir/$subdir
1093 gdb_load $objdir/$subdir/$binfile
1095 if [runto foo] then { test_at_foo }
1096 if [istarget "mips-idt-*"] then {
1097 # Restart because IDT/SIM runs out of file descriptors.
1100 gdb_reinitialize_dir $srcdir/$subdir
1101 gdb_load $objdir/$subdir/$binfile
1103 if [runto bar] then { test_at_bar }
1104 if [istarget "mips-idt-*"] then {
1105 # Restart because IDT/SIM runs out of file descriptors.
1108 gdb_reinitialize_dir $srcdir/$subdir
1109 gdb_load $objdir/$subdir/$binfile
1111 if [runto localscopes] then { test_at_localscopes }
1112 if [istarget "mips-idt-*"] then {
1113 # Restart because IDT/SIM runs out of file descriptors.
1116 gdb_reinitialize_dir $srcdir/$subdir
1117 gdb_load $objdir/$subdir/$binfile
1119 if [runto autovars] then { test_at_autovars }
1121 if [istarget "*-*-vxworks*"] {