1 # Copyright
1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003,
2 #
2004 Free Software Foundation
, Inc.
4 # This
program is free software
; you can redistribute it and
/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation
; either version
2 of the License
, or
7 #
(at your option
) any later version.
9 # This
program is distributed in the hope that it will be useful
,
10 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License
for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this
program; if not
, write to the Free Software
16 # Foundation
, Inc.
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
18 # Please email
any bugs
, comments
, and
/or additions to this file to
:
19 # bug
-gdb@prep.ai.mit.edu
21 # This file was written by Fred Fish.
(fnf@cygnus.com
)
31 set binfile $
{objdir
}/$
{subdir
}/$
{testfile
}
34 if { [gdb_compile
"${srcdir}/${subdir}/scope0.c" "${binfile}0.o" object {debug}] != "" } {
35 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
38 if { [gdb_compile
"${srcdir}/${subdir}/scope1.c" "${binfile}1.o" object {debug}] != "" } {
39 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
42 if { [gdb_compile
"${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } {
43 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
46 # Create and source the file that provides information about the compiler
47 # used to
compile the test case.
48 if [get_compiler_info $
{binfile
}] {
52 # Test locating various things when stopped just inside main
, after
53 # running init0
(). To prevent cascading of errors
, we
report the
54 # first one and quit.
If all pass
, then we print the pass results.
56 proc test_at_main
{} {
65 # This used to
do an extra
"next" if the first one didn't get us
66 # over the
call to init0
, to handle calls to __main in the
67 # prologue
, etc. But
if a breakpoint at main doesn
't leave us on
68 # the first line of real code in the function, that's a GDB bug.
69 gdb_test
"next" "$decimal.*foo \\(\\);" "next over init0() in main"
71 # Print scope0.c
::filelocal
, which is
1
73 if [gdb_test
"print filelocal" "\\\$$decimal = 1" "print filelocal" ] {
78 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"] {
83 # Print scope0.c
::filelocal_bss
, which is
101
85 if [gdb_test
"print filelocal_bss" "\\\$$decimal = 101" "print filelocal_bss" ] {
90 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"] {
95 # Print scope0.c
::filelocal_ro
, which is
201
97 # No clue why the rs6000 fails this test.
98 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
99 if [gdb_test
"print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main" ] {
104 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
105 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"] {
110 # Print scope1.c
::filelocal
, which is
2
112 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
113 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"] {
118 # Print scope1.c
::filelocal_bss
, which is
102
120 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
121 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"] {
126 # Print scope1.c
::filelocal_ro
, which is
202
128 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
129 if {$hp_cc_compiler
} then { setup_xfail
"hppa2.0w-*-*" 11747CLLbs}
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"] {
135 # Print scope1.c
::foo
::funclocal
, which is
3
137 if [gdb_test
"print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal" ] {
142 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
143 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"] {
148 # Print scope1.c
::foo
::funclocal_ro
, which is
203
150 if [gdb_test
"print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro" ] {
155 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
156 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"] {
161 # Print scope1.c
::bar
::funclocal
, which is
4
163 if [gdb_test
"print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal" ] {
168 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
169 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"] {
172 gdb_stop_suppressing_tests
;
176 proc test_at_foo
{} {
183 if [gdb_test
"next" ".*bar \\(\\);" "" ] {
188 # Print scope0.c
::filelocal
, which is
1
190 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"] {
195 # Print scope0.c
::filelocal_bss
, which is
101
197 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"] {
202 # Print scope0.c
::filelocal_ro
, which is
201
204 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
205 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"] {
210 gdb_test
"print filelocal" "\\\$$decimal = 2" "print filelocal at foo"
212 # Print scope1.c
::filelocal
, which is
2
214 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
215 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"] {
220 gdb_test
"print filelocal_bss" "\\\$$decimal = 102" \
221 "print filelocal_bss at foo"
223 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
224 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"
227 gdb_test
"print filelocal_ro" "\\\$$decimal = 202" \
228 "print filelocal_ro at foo"
230 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
231 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"
234 # Print scope1.c
::foo
::funclocal
, which is
3
236 gdb_test
"print funclocal" "\\\$$decimal = 3" "print funclocal at foo"
238 gdb_test
"print foo::funclocal" "\\\$$decimal = 3" \
239 "print foo::funclocal at foo"
241 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
242 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"
245 # Print scope1.c
::foo
::funclocal_bss
, which is
103
247 gdb_test
"print funclocal_bss" "\\\$$decimal = 103" \
248 "print funclocal_bss at foo"
250 gdb_test
"print foo::funclocal_bss" "\\\$$decimal = 103" \
251 "print foo::funclocal_bss at foo"
253 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
254 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"
257 # Print scope1.c
::foo
::funclocal_ro
, which is
203
259 gdb_test
"print funclocal_ro" "\\\$$decimal = 203" \
260 "print funclocal_ro at foo"
262 gdb_test
"print foo::funclocal_ro" "\\\$$decimal = 203" \
263 "print foo::funclocal_ro at foo"
265 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
266 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"
269 # Print scope1.c
::bar
::funclocal
, which is
4
271 gdb_test
"print bar::funclocal" "\\\$$decimal = 4" \
272 "print bar::funclocal at foo"
274 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
275 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"
276 gdb_stop_suppressing_tests
;
280 proc test_at_bar
{} {
287 if [gdb_test
"next" ".*" "" ] {
292 # Print scope0.c
::filelocal
, which is
1
294 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"] {
299 # Print scope0.c
::filelocal_bss
, which is
101
301 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"] {
306 # Print scope0.c
::filelocal_ro
, which is
201
308 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
309 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"] {
314 # Print scope1.c
::filelocal
, which is
2
316 if [gdb_test
"print filelocal" "\\\$$decimal = 2" "print filelocal at bar" ] {
321 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
322 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"] {
327 # Print scope1.c
::filelocal_bss
, which is
102
329 if [gdb_test
"print filelocal_bss" "\\\$$decimal = 102" "print filelocal_bss at bar" ] {
334 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
335 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"] {
340 # Print scope1.c
::filelocal_ro
, which is
202
342 if [gdb_test
"print filelocal_ro" "\\\$$decimal = 202" "print filelocal_ro in test_at_bar" ] {
347 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
348 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"] {
353 # Print scope1.c
::foo
::funclocal
, which is
3
355 if [gdb_test
"print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal at bar" ] {
360 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
361 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"] {
366 # Print scope1.c
::foo
::funclocal_bss
, which is
103
368 if [gdb_test
"print foo::funclocal_bss" "\\\$$decimal = 103" "print foo::funclocal_bss at bar" ] {
373 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
374 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"] {
379 # Print scope1.c
::foo
::funclocal_ro
, which is
203
381 if [gdb_test
"print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro at bar" ] {
386 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
387 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"] {
392 # Print scope1.c
::bar
::funclocal
, which is
4
394 if [gdb_test
"print funclocal" "\\\$$decimal = 4" "print funclocal at bar" ] {
399 if [gdb_test
"print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal at bar" ] {
404 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
405 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"] {
410 # Print scope1.c
::bar
::funclocal_bss
, which is
104
412 if [gdb_test
"print funclocal_bss" "\\\$$decimal = 104" "print funclocal_bss at bar" ] {
417 if [gdb_test
"print bar::funclocal_bss" "\\\$$decimal = 104" "print bar::funclocal_bss at bar" ] {
422 if { [test_compiler_info gcc
-*-*] } then { setup_xfail
"rs6000-*-*" }
423 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"] {
426 gdb_stop_suppressing_tests
;
430 # This test has little to
do with local scopes
, but it is in scope.exp anyway.
433 proc test_at_autovars {} {
439 # Test symbol table lookup with 100 local (auto) variables.
441 gdb_breakpoint marker1
443 if [gdb_test "cont" "Break.* marker1 \\(\\) at .*:$decimal.*" "continue to marker1"] {
447 if [gdb_test "up" ".*autovars.*" "up from marker1 in scope.exp" ] {
452 while {$count < 100} {
453 if [gdb_test "print i$count" ".* = $count" "" ] {
457 set count [expr $count+1]
460 pass "$count auto variables correctly initialized"
462 # Test that block variable sorting is not screwing us.
463 gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order"
466 proc test_at_localscopes {} {
472 gdb_breakpoint marker2
473 gdb_breakpoint marker3
474 gdb_breakpoint marker4
476 if [gdb_test "cont" "Break.* marker2 \\(\\) at .*:$decimal.*" "continue to marker2"] {
479 if [gdb_test "up" ".*localscopes.*" "up from marker2 in scopes.exp" ] {
483 # Should be at first (outermost) scope. Check values.
485 gdb_test "print localval" " = 10" "print localval, outer scope"
486 gdb_test "print localval1" " = 11" "print localval1, outer scope"
487 gdb_test "print localval2" "No symbol \"localval2\" in current context." \
488 "print localval2, outer scope"
489 gdb_test "print localval3" "No symbol \"localval3\" in current context." \
490 "print localval3, outer scope"
492 if [gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \
493 "continue to marker3 in scope.exp"] then { gdb_suppress_tests }
494 if [gdb_test "up" ".*localscopes.*" "up from marker3 in scope.exp"] {
498 # Should be at next (first nested) scope. Check values.
500 gdb_test "print localval" " = 20" \
501 "print localval, first nested scope"
502 gdb_test "print localval1" " = 11" "print localval1, first nested scope"
503 gdb_test "print localval2" " = 12" "print localval2, first nested scope"
504 gdb_test "print localval3" "No symbol \"localval3\" in current context." \
505 "print localval3, first nested scope"
507 # This test will only fail if the file was compiled by gcc, but
508 # there's no way to check that.
509 if [gdb_test
"cont" "Break.* marker4.*at .*:$decimal.*" \
510 "continue to marker4 in scope.exp"] then { gdb_suppress_tests }
511 if [gdb_test
"up" ".*localscopes.*" "up from marker4 in scope.exp"] {
515 gdb_test
"print localval" " = 30" "print localval, innermost scope"
516 gdb_test
"print localval1" " = 11" "print localval1, innermost scope"
517 gdb_test
"print localval2" " = 12" "print localval2, innermost scope"
518 gdb_test
"print localval3" " = 13" "print localval3, innermost scope"
519 gdb_stop_suppressing_tests
;
522 # Start with a fresh gdb.
526 gdb_reinitialize_dir $srcdir
/$subdir
529 if [istarget
"*-*-vxworks*"] {
531 verbose
"Timeout is now $timeout seconds" 2
534 # Test that variables in various segments print out correctly before
535 # the
program is run.
537 # AIX
--sections
get mapped to the same address so we can
't get the right one.
538 setup_xfail "rs6000-*-*"
540 gdb_test "print 'scope0.c
'::filelocal_ro" "= 201"
542 # gdb currently cannot access bss memory on some targets if the inferior
545 # For PA boards using monitor/remote-pa.c, the bss test is going to
546 # randomly fail. We've already put remote
-pa
on the target stack
,
547 # so we actually read memory from the board. Problem is crt0.o
548 # is responsible
for clearing bss and that hasnt
' happened yet.
550 # This is a problem for all non-native targets. -- manson
551 if [is_remote target] {
552 unsupported "print 'scope0.c
'::filelocal_bss before run"
554 gdb_test "print 'scope0.c
'::filelocal_bss" "= 0" \
555 "print 'scope0.c
'::filelocal_bss before run"
558 gdb_test "print 'scope0.c
'::filelocal" "= 1" \
559 "print 'scope0.c
'::filelocal before run"
561 if [runto_main] then { test_at_main }
562 if [istarget "mips-idt-*"] then {
563 # Restart because IDT/SIM runs out of file descriptors.
566 gdb_reinitialize_dir $srcdir/$subdir
569 if [runto foo] then { test_at_foo }
570 if [istarget "mips-idt-*"] then {
571 # Restart because IDT/SIM runs out of file descriptors.
574 gdb_reinitialize_dir $srcdir/$subdir
577 if [runto bar] then { test_at_bar }
578 if [istarget "mips-idt-*"] then {
579 # Restart because IDT/SIM runs out of file descriptors.
582 gdb_reinitialize_dir $srcdir/$subdir
585 if [runto localscopes] then { test_at_localscopes }
586 if [istarget "mips-idt-*"] then {
587 # Restart because IDT/SIM runs out of file descriptors.
590 gdb_reinitialize_dir $srcdir/$subdir
593 if [runto autovars] then { test_at_autovars }
595 if [istarget "*-*-vxworks*"] {
597 verbose "Timeout is now $timeout seconds" 2