old-cross-binutils/gdb/testsuite/gdb.base/scope.exp
Fred Fish ce102e96e6 * gdb.base/Makefile.in: Add action to .c.o transformation
rule that generates a .ci file for each .o file and remove
	explicit .c.o rules except for callfuncs.o.
	* gdb.c++/Makefile.in:  Add .cc.o transformation rule that
	generates a .ci file for each .o file and remove explicit
	.cc.o rules.
	(clean): Remove *.tmp *.ci files.
	(EXECUTABLES): Remove templ-info.exp.
	* gdb.base/compiler.c: New file.
	* gdb.c++/compiler.cc: New file
	* gdb.base/scope.exp: Source gdb.base/scope.ci.
	Change rs6000-*-* xfail for
	"print 'scope0.c'::filelocal_ro" and
	"print 'scope1.c'::filelocal" and
	"print 'scope1.c'::filelocal_bss" and
	"print 'scope1.c'::filelocal_ro" and
	"print 'scope1.c'::foo::funclocal" and
	"print 'scope1.c'::foo::funclocal_ro" and
	"print 'scope1.c'::bar::funclocal" and
	"print 'scope0.c'::filelocal_ro" and
	"print 'scope1.c'::filelocal at foo" and
	"print 'scope1.c'::filelocal_bss at foo" and
	"print 'scope1.c'::filelocal_ro at foo" and
	"print 'scope1.c'::foo::funclocal at foo" and
	"print 'scope1.c'::foo::funclocal_bss at foo" and
	"print 'scope1.c'::foo::funclocal_ro at foo" and
	"print 'scope1.c'::bar::funclocal at foo" and
	"print 'scope0.c'::filelocal_ro" and
	"print 'scope1.c'::filelocal" and
	"print 'scope1.c'::filelocal_bss" and
	"print 'scope1.c'::filelocal_ro" and
	"print 'scope1.c'::foo::funclocal" and
	"print 'scope1.c'::foo::funclocal_bss" and
	"print 'scope1.c'::foo::funclocal_ro" and
	"print 'scope1.c'::bar::funclocal" and
	"print 'scope1.c'::bar::funclocal_bss"
	to only be xfail'd when not compiled with gcc.
	Add rs6000-*-* xfail for
	"print 'scope0.c'::filelocal_bss before run"
	when compiled with gcc.
	(test_at_main): Add rs6000-*-* xfail for
	"print filelocal_ro in test_at_main"
	when compiled with gcc.
	* gdb.base/ptype.exp: Source gdb.base/ptype.ci.
 	Add rs6000-*-aix* xfail for
	"whatis unnamed typedef'd enum (compiler bug in IBM's xlc)" and
	"ptype t_char_array",  not compiled with gcc.
	* gdb.base/list.exp (test_list_function):  Add rs6000-*-*
	xfail for "list foo (in include file)" when gcc	compiled.
	* gdb.base/funcargs.exp: Source gdb.base/funcargs.ci
 	(integral_args): Add rs6000-*-* xfail for
	"run to call0a" if not compiled with gcc.
	(unsigned_integral_args): Add rs6000-*-* xfail for
	"run to call1a" if not compiled with gcc.
	(float_and_integral_args):  Add rs6000-*-* xfail for
	"run to call2a" if not compiled with gcc and for
	"continue to call2b" for any compiler.
	Add rs6000-*-* xfail to
	"print f1 after run to call2a" for gcc compiled.
	(discard_and_shuffle): Add rs6000-*-* xfail for
	"run to call6a".
	(shuffle_round_robin): Add rs6000-*-* xfail for
	"backtrace from call7a" if not compiled with gcc.
	Add rs6000-*-* xfail for
	"backtrace from call7b" if compiled with gcc.
	(call_after_alloca): Add rs6000-*-* xfail for
	"print c in call_after_alloca" and
	"print s in call_after_alloca" and
	"backtrace from call_after_alloca_subr"
	if not compiled with gcc.
	(localvars_in_indirect_call): Add rs6000-*-* xfail for
	"print c in localvars_in_indirect_call" and
	"print c in localvars_in_indirect_call" and
	"backtrace in indirectly called function" and
	"stepping into indirectly called function"
	if not compiled with gcc.
	(localvars_after_alloca): Add rs6000-*-* xfail for
	"print c after runto localvars_after_alloca" and
	"print s after runto localvars_after_alloca" and
	"print i after runto localvars_after_alloca" and
	"print l after runto localvars_after_alloca"
	for all compilers.
	* gdb.base/whatis.exp: Source gdb.base/whatis.ci rather
	than whatis-info.exp.
	* gdb.base/opaque.exp: Source gdb.base/opaque0.ci rather
	than opaque-info.exp.
	Setup rs6000-*-* xfail for
	"ptype on opaque struct pointer (statically)" and
	"ptype on opaque struct pointer (dynamically)" when
	not compiled with gcc.
	* gdb.base/callfuncs.exp: Source gdb.base/callfuncs.ci
	rather than callf-info.exp.
	(do_function_calls):  Add clear_xfail for rs6000-*-* for
	"p t_float_values2(3.14159,float_val2)".  Seems to work
	fine there, both with xlc and gcc.  Need to find out what
	it is doing right and fix other platforms.
	* gdb.base/callfuncs.exp: Add rs6000-*-* xfail for
	"call inferior func with struct - returns int",
	"call inferior func with struct - returns long",
	"call inferior func with struct - returns float",
	"call inferior func with struct - returns double",
	"call inferior func with struct - returns char *",
	but only if not gcc compiled (presumes xlc compiled).
	Change rs6000-*-* xfails for
	"call inferior func with struct - returns char" and
	" call inferior func with struct -  returns short" to only
	xfail if not using gcc.
	(clean mostlyclean):  Remove *.ci and *.tmp files.
	* gdb.c++/templates.exp: Source gdb.c++/templates.ci rather
	than templ-info.exp.
	* gdb.base/langs.exp:  Source gdb.base/langs.ci.
	Add rs6000-*-* xfail for "up to foo in langs.exp"
	"up to cppsub_ in langs.exp" and "up to fsub in langs.exp"
 	when not gcc compiled.
1995-08-16 07:37:19 +00:00

997 lines
29 KiB
Text

# Copyright (C) 1992, 1994 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# This file was written by Fred Fish. (fnf@cygnus.com)
if $tracelevel then {
strace $tracelevel
}
set prms_id 0
set bug_id 0
set binfile "scope"
set srcfile $binfile.c
if ![file exists $objdir/$subdir/$binfile] then {
perror "$objdir/$subdir/$binfile does not exist."
return 0
}
source gdb.base/scope0.ci
# Test locating various things when stopped just inside main, after
# running init(). To prevent cascading of errors, we report the
# first one and quit. If all pass, then we print the pass results.
proc test_at_main {} {
global prompt
global decimal
global det_file
global srcdir
global subdir
global gcc_compiled
# skip past init. There may be a call to __main at the start of
# main, so the first next may only get us to the init call.
send "next\n"
expect {
-re "$decimal.*foo \\(\\);\r\n$prompt $" {
pass "next over init() in main"
}
-re "$decimal.*init \\(\\);\r\n$prompt $"\
{ send "next\n" ; exp_continue }
-re "$prompt $" { fail "next over init() in main" ; return }
timeout { fail "(timeout) next over init() in main" ; return }
}
# Print scope0.c::filelocal, which is 1
send "print filelocal\n"
expect {
-re "\\\$$decimal = 1\r\n$prompt $" { pass "print filelocal" }
-re "$prompt $" { fail "print filelocal" ; return }
timeout {
fail "(timeout) print filelocal" ; return
}
}
send "print 'scope0.c'::filelocal\n"
expect {
-re "\\\$$decimal = 1\r\n$prompt $" {
pass "print 'scope0.c'::filelocal at main"
}
-re "No symbol \"scope0.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope0.c'::filelocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope0.c'::filelocal at main" ; return }
timeout {
fail "(timeout) print 'scope0.c'::filelocal at main" ; return
}
}
# Print scope0.c::filelocal_bss, which is 101
send "print filelocal_bss\n"
expect {
-re "\\\$$decimal = 101\r\n$prompt $" {
pass "print filelocal_bss"
}
-re "$prompt $" { fail "print filelocal_bss" ; return }
timeout {
fail "(timeout) print filelocal_bss" ; return
}
}
send "print 'scope0.c'::filelocal_bss\n"
expect {
-re "\\\$$decimal = 101\r\n$prompt $" {
pass "print 'scope0.c'::filelocal_bss in test_at_main"
}
-re "No symbol \"scope0.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
exp_continue
}
-re "$prompt $" {
fail "print 'scope0.c'::filelocal_bss in test_at_main" ; return
}
timeout {
fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_main"
return
}
}
# Print scope0.c::filelocal_ro, which is 201
# No clue why the powerpc fails this test.
setup_xfail "powerpc-*-*"
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print filelocal_ro\n"
expect {
-re "\\\$$decimal = 201\r\n$prompt $" {
pass "print filelocal_ro in test_at_main"
}
-re "$prompt $" {
fail "print filelocal_ro in test_at_main"
return
}
timeout {
fail "(timeout) print filelocal_ro in test_at_main"
return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
setup_xfail "powerpc-*-*"
send "print 'scope0.c'::filelocal_ro\n"
expect {
-re "\\\$$decimal = 201\r\n$prompt $" {
pass "print 'scope0.c'::filelocal_ro"
}
-re "No symbol \"scope0.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
timeout {
fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
}
}
# Print scope1.c::filelocal, which is 2
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::filelocal\n"
expect {
-re "\\\$$decimal = 2\r\n$prompt $" {
pass "print 'scope1.c'::filelocal"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::filelocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::filelocal" ; return }
timeout {
fail "(timeout) print 'scope1.c'::filelocal" ; return
}
}
# Print scope1.c::filelocal_bss, which is 102
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::filelocal_bss\n"
expect {
-re "\\\$$decimal = 102\r\n$prompt $" {
pass "print 'scope1.c'::filelocal_bss"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::filelocal_bss" ; return }
timeout {
fail "(timeout) print 'scope1.c'::filelocal_bss" ; return
}
}
# Print scope1.c::filelocal_ro, which is 202
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::filelocal_ro\n"
expect {
-re "\\\$$decimal = 202\r\n$prompt $" {
pass "print 'scope1.c'::filelocal_ro"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
exp_continue
}
-re "$prompt " {fail "print 'scope1.c'::filelocal_ro" ; return }
timeout {
fail "(timeout) print 'scope1.c'::filelocal_ro" ; return
}
}
# Print scope1.c::foo::funclocal, which is 3
send "print foo::funclocal\n"
expect {
-re "\\\$$decimal = 3\r\n$prompt $" { pass "print foo::funclocal" }
-re "$prompt $" { fail "print foo::funclocal" ; return }
timeout {
fail "(timeout) print foo::funclocal" ; return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::foo::funclocal\n"
expect {
-re "\\\$$decimal = 3\r\n$prompt $" {
pass "print 'scope1.c'::foo::funclocal"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::foo::funclocal" ; return }
timeout {
fail "(timeout) print 'scope1.c'::foo::funclocal" ; return
}
}
# Print scope1.c::foo::funclocal_ro, which is 203
send "print foo::funclocal_ro\n"
expect {
-re "\\\$$decimal = 203\r\n$prompt $" {
pass "print foo::funclocal_ro"
}
-re "$prompt $" { fail "print foo::funclocal_ro" ; return }
timeout {
fail "(timeout) print foo::funclocal_ro" ; return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::foo::funclocal_ro\n"
expect {
-re "\\\$$decimal = 203\r\n$prompt $" {
pass "print 'scope1.c'::foo::funclocal_ro" }
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro" ; return }
timeout {
fail "(timeout) print 'scope1.c'::foo::funclocal_ro" ; return
}
}
# Print scope1.c::bar::funclocal, which is 4
send "print bar::funclocal\n"
expect {
-re "\\\$$decimal = 4\r\n$prompt $" { pass "print bar::funclocal" }
-re "$prompt $" { fail "print bar::funclocal" ; return }
timeout {
fail "(timeout) print bar::funclocal" ; return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::bar::funclocal\n"
expect {
-re "\\\$$decimal = 4\r\n$prompt $" {
pass "print 'scope1.c'::bar::funclocal"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::bar::funclocal" ; return }
timeout {
fail "print 'scope1.c'::bar::funclocal" ; return
}
}
}
proc test_at_foo {} {
global prompt
global decimal
global det_file
global srcdir
global subdir
global gcc_compiled
send "next\n"
expect {
-re ".*bar \\(\\);\r\n$prompt $" {}
-re "$prompt $" { fail "continue to foo()" ; return }
timeout { fail "(timeout) continue to foo()" ; return }
}
# Print scope0.c::filelocal, which is 1
send "print 'scope0.c'::filelocal\n"
expect {
-re "\\\$$decimal = 1\r\n$prompt $" {
pass "print 'scope0.c'::filelocal at foo"
}
-re "No symbol \"scope0.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope0.c'::filelocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope0.c'::filelocal at foo" ; return }
timeout {
fail "(timeout) print 'scope0.c'::filelocal at foo" ; return
}
}
# Print scope0.c::filelocal_bss, which is 101
send "print 'scope0.c'::filelocal_bss\n"
expect {
-re "\\\$$decimal = 101\r\n$prompt $" {
pass "print 'scope0.c'::filelocal_bss in test_at_foo"
}
-re "No symbol \"scope0.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
exp_continue
}
-re "$prompt $" {
fail "print 'scope0.c'::filelocal_bss in test_at_foo"
return
}
timeout {
fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_foo"
return
}
}
# Print scope0.c::filelocal_ro, which is 201
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
setup_xfail "powerpc-*-*"
send "print 'scope0.c'::filelocal_ro\n"
expect {
-re "\\\$$decimal = 201\r\n$prompt $" { pass "print 'scope0.c'::filelocal_ro" }
-re "No symbol \"scope0.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
timeout {
fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
}
}
gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo"
# Print scope1.c::filelocal, which is 2
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::filelocal\n"
expect {
-re "\\\$$decimal = 2\r\n$prompt $" {
pass "print 'scope1.c'::filelocal at foo"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::filelocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::filelocal at foo" ; return }
timeout {
fail "(timeout) print 'scope1.c'::filelocal at foo" ; return
}
}
gdb_test "print filelocal_bss" "\\\$$decimal = 102" \
"print filelocal_bss at foo"
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::filelocal_bss\n"
expect {
-re "\\\$$decimal = 102\r\n$prompt $" {
pass "print 'scope1.c'::filelocal_bss at foo"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::filelocal_bss at foo" }
timeout {
fail "(timeout) print 'scope1.c'::filelocal_bss at foo"
}
}
gdb_test "print filelocal_ro" "\\\$$decimal = 202" \
"print filelocal_ro at foo"
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::filelocal_ro\n"
expect {
-re "\\\$$decimal = 202\r\n$prompt $" { pass "print 'scope1.c'::filelocal_ro at foo" }
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::filelocal_ro at foo" }
timeout {
fail "(timeout) print 'scope1.c'::filelocal_ro at foo"
}
}
# Print scope1.c::foo::funclocal, which is 3
gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo"
gdb_test "print foo::funclocal" "\\\$$decimal = 3" \
"print foo::funclocal at foo"
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::foo::funclocal\n"
expect {
-re "\\\$$decimal = 3\r\n$prompt $" {
pass "print 'scope1.c'::foo::funclocal at foo"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::foo::funclocal at foo" }
timeout {
fail "(timeout) print 'scope1.c'::foo::funclocal at foo"
}
}
# Print scope1.c::foo::funclocal_bss, which is 103
gdb_test "print funclocal_bss" "\\\$$decimal = 103" \
"print funclocal_bss at foo"
gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \
"print foo::funclocal_bss at foo"
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::foo::funclocal_bss\n"
expect {
-re "\\\$$decimal = 103\r\n$prompt $" {
pass "print 'scope1.c'::foo::funclocal_bss at foo"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n"
exp_continue
}
-re "$prompt $" {
fail "print 'scope1.c'::foo::funclocal_bss at foo"
}
timeout {
fail "(timeout) print 'scope1.c'::foo::funclocal_bss at foo"
}
}
# Print scope1.c::foo::funclocal_ro, which is 203
gdb_test "print funclocal_ro" "\\\$$decimal = 203" \
"print funclocal_ro at foo"
gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \
"print foo::funclocal_ro at foo"
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::foo::funclocal_ro\n"
expect {
-re "\\\$$decimal = 203\r\n$prompt $" {
pass "print 'scope1.c'::foo::funclocal_ro at foo"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro at foo" }
timeout {
fail "(timeout) print 'scope1.c'::foo::funclocal_ro at foo"
}
}
# Print scope1.c::bar::funclocal, which is 4
gdb_test "print bar::funclocal" "\\\$$decimal = 4" \
"print bar::funclocal at foo"
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::bar::funclocal\n"
expect {
-re "\\\$$decimal = 4\r\n$prompt $" {
pass "print 'scope1.c'::bar::funclocal at foo"
}
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::bar::funclocal at foo" }
timeout {
fail "(timeout) print 'scope1.c'::bar::funclocal at foo"
}
}
}
proc test_at_bar {} {
global prompt
global decimal
global det_file
global srcdir
global subdir
global gcc_compiled
send "next\n"
expect {
-re ".*$prompt $" {}
timeout { fail "next in bar()" ; return }
}
# Print scope0.c::filelocal, which is 1
send "print 'scope0.c'::filelocal\n"
expect {
-re "\\\$$decimal = 1\r\n$prompt $" {
pass "print 'scope0.c'::filelocal at bar"
}
-re "No symbol \"scope0.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope0.c'::filelocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope0.c'::filelocal at bar" ; return }
timeout {
fail "(timeout) print 'scope0.c'::filelocal at bar" ; return
}
}
# Print scope0.c::filelocal_bss, which is 101
send "print 'scope0.c'::filelocal_bss\n"
expect {
-re "\\\$$decimal = 101\r\n$prompt $" {
pass "print 'scope0.c'::filelocal_bss in test_at_bar"
}
-re "No symbol \"scope0.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
exp_continue
}
-re "$prompt $" {
fail "print 'scope0.c'::filelocal_bss in test_at_bar"
return
}
timeout {
fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_bar"
return
}
}
# Print scope0.c::filelocal_ro, which is 201
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
setup_xfail "powerpc-*-*"
send "print 'scope0.c'::filelocal_ro\n"
expect {
-re "\\\$$decimal = 201\r\n$prompt $" { pass "print 'scope0.c'::filelocal_ro" }
-re "No symbol \"scope0.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
timeout {
fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
}
}
# Print scope1.c::filelocal, which is 2
send "print filelocal\n"
expect {
-re "\\\$$decimal = 2\r\n$prompt $" { pass "print filelocal" }
-re "$prompt $" { fail "print filelocal" ; return }
timeout {
fail "(timeout) print filelocal" ; return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::filelocal\n"
expect {
-re "\\\$$decimal = 2\r\n$prompt $" { pass "print 'scope1.c'::filelocal" }
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::filelocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::filelocal" ; return }
timeout {
fail "(timeout) print 'scope1.c'::filelocal" ; return
}
}
# Print scope1.c::filelocal_bss, which is 102
send "print filelocal_bss\n"
expect {
-re "\\\$$decimal = 102\r\n$prompt $" { pass "print filelocal_bss" }
-re "$prompt $" { fail "print filelocal_bss" ; return }
timeout {
fail "(timeout) print filelocal_bss" ; return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::filelocal_bss\n"
expect {
-re "\\\$$decimal = 102\r\n$prompt $" { pass "print 'scope1.c'::filelocal_bss" }
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::filelocal_bss" ; return }
timeout {
fail "(timeout) print 'scope1.c'::filelocal_bss" ; return
}
}
# Print scope1.c::filelocal_ro, which is 202
send "print filelocal_ro\n"
expect {
-re "\\\$$decimal = 202\r\n$prompt $" {
pass "print filelocal_ro in test_at_bar"
}
-re "$prompt $" {
fail "print filelocal_ro in test_at_bar"
return
}
timeout {
fail "(timeout) print filelocal_ro in test_at_bar"
return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::filelocal_ro\n"
expect {
-re "\\\$$decimal = 202\r\n$prompt $" { pass "print 'scope1.c'::filelocal_ro" }
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::filelocal_ro" ; return }
timeout {
fail "(timeout) print 'scope1.c'::filelocal_ro" ; return
}
}
# Print scope1.c::foo::funclocal, which is 3
send "print foo::funclocal\n"
expect {
-re "\\\$$decimal = 3\r\n$prompt $" { pass "print foo::funclocal" }
-re "$prompt $" { fail "print foo::funclocal" ; return }
timeout {
fail "(timeout) print foo::funclocal" ; return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::foo::funclocal\n"
expect {
-re "\\\$$decimal = 3\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal" }
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::foo::funclocal" ; return }
timeout {
fail "(timeout) print 'scope1.c'::foo::funclocal" ; return
}
}
# Print scope1.c::foo::funclocal_bss, which is 103
send "print foo::funclocal_bss\n"
expect {
-re "\\\$$decimal = 103\r\n$prompt $" { pass "print foo::funclocal_bss" }
-re "$prompt $" { fail "print foo::funclocal_bss" ; return }
timeout {
fail "(timeout) print foo::funclocal_bss" ; return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::foo::funclocal_bss\n"
expect {
-re "\\\$$decimal = 103\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal_bss" }
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_bss" ; return }
timeout {
fail "(timeout) print 'scope1.c'::foo::funclocal_bss" ; return
}
}
# Print scope1.c::foo::funclocal_ro, which is 203
send "print foo::funclocal_ro\n"
expect {
-re "\\\$$decimal = 203\r\n$prompt $" { pass "print foo::funclocal_ro" }
-re "$prompt $" { fail "print foo::funclocal_ro" ; return }
timeout {
fail "(timeout) print foo::funclocal_ro" ; return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::foo::funclocal_ro\n"
expect {
-re "\\\$$decimal = 203\r\n$prompt $" { pass "print 'scope1.c'::foo::funclocal_ro" }
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro" ; return }
timeout {
fail "(timeout) print 'scope1.c'::foo::funclocal_ro" ; return
}
}
# Print scope1.c::bar::funclocal, which is 4
send "print funclocal\n"
expect {
-re "\\\$$decimal = 4\r\n$prompt $" { pass "print funclocal" }
-re "$prompt $" { fail "print funclocal" ; return }
timeout {
fail "(timeout) print funclocal" ; return
}
}
send "print bar::funclocal\n"
expect {
-re "\\\$$decimal = 4\r\n$prompt $" { pass "print bar::funclocal" }
-re "$prompt $" { fail "print bar::funclocal" ; return }
timeout {
fail "(timeout) print bar::funclocal" ; return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::bar::funclocal\n"
expect {
-re "\\\$$decimal = 4\r\n$prompt $" { pass "print 'scope1.c'::bar::funclocal" }
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::bar::funclocal" ; return }
timeout {
fail "(timeout) print 'scope1.c'::bar::funclocal" ; return
}
}
# Print scope1.c::bar::funclocal_bss, which is 104
send "print funclocal_bss\n"
expect {
-re "\\\$$decimal = 104\r\n$prompt $" { pass "print funclocal_bss" }
-re "$prompt $" { fail "print funclocal_bss" ; return }
timeout {
fail "(timeout) print funclocal_bss" ; return
}
}
send "print bar::funclocal_bss\n"
expect {
-re "\\\$$decimal = 104\r\n$prompt $" { pass "print bar::funclocal_bss" }
-re "$prompt $" { fail "print bar::funclocal_bss" ; return }
timeout {
fail "(timeout) print bar::funclocal_bss" ; return
}
}
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope1.c'::bar::funclocal_bss\n"
expect {
-re "\\\$$decimal = 104\r\n$prompt $" { pass "print 'scope1.c'::bar::funclocal_bss" }
-re "No symbol \"scope1.c\" in current context.*$prompt $" {
send "print '$srcdir/$subdir/scope1.c'::bar::funclocal_bss\n"
exp_continue
}
-re "$prompt $" { fail "print 'scope1.c'::bar::funclocal_bss" ; return }
timeout {
fail "(timeout) print 'scope1.c'::bar::funclocal_bss" ; return
}
}
}
# This test has little to do with local scopes, but it is in scope.exp anyway.
# That's life.
proc test_at_autovars {} {
global prompt
global decimal
global hex
global srcfile
# Test symbol table lookup with 100 local (auto) variables.
send "break marker1\n" ; expect -re ".*$prompt $"
send "cont\n"
expect {
-re "Break.* marker1 \\(\\) at .*:$decimal.*$prompt $" {
send "up\n"
expect {
-re ".*$prompt $" {}
timeout { fail "up from marker1" ; return }
}
}
-re "$prompt $" { fail "continue to marker1" ; return }
timeout { fail "(timeout) continue to marker1" ; return }
}
set count 0
while {$count < 100} {
send "print i$count\n"
expect {
-re ".* = $count\r\n$prompt $" {}
-re "$prompt $" {
fail "bad value for auto variable i$count"; return
}
timeout {
fail "(timeout) bad value for auto variable i$count"; return
}
}
set count [expr $count+1]
}
clear_xfail "*-*-*"
pass "$count auto variables correctly initialized"
# Test that block variable sorting is not screwing us.
gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order"
}
proc test_at_localscopes {} {
global prompt
global decimal
global hex
global srcfile
send "break marker2\n" ; expect -re ".*$prompt $"
send "break marker3\n" ; expect -re ".*$prompt $"
send "break marker4\n" ; expect -re ".*$prompt $"
send "cont\n"
expect {
-re "Break.* marker2 \\(\\) at .*:$decimal.*$prompt $" {
send "up\n"
expect {
-re ".*$prompt $" {}
timeout { fail "up from marker2" ; return }
}
}
-re "$prompt $" { fail "continue to marker2" ; return }
timeout { fail "(timeout) continue to marker2" ; return }
}
# Should be at first (outermost) scope. Check values.
gdb_test "print localval" " = 10" "print localval, outer scope"
gdb_test "print localval1" " = 11" "print localval1, outer scope"
gdb_test "print localval2" "No symbol \"localval2\" in current context." \
"print localval2, outer scope"
gdb_test "print localval3" "No symbol \"localval3\" in current context." \
"print localval3, outer scope"
if [gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \
"continue to marker3 in scope.exp"] then { return }
if [gdb_test "up" "" "up from marker3 in scope.exp"] then { return }
# Should be at next (first nested) scope. Check values.
gdb_test "print localval" " = 20" \
"print localval, first nested scope"
gdb_test "print localval1" " = 11" "print localval1, first nested scope"
gdb_test "print localval2" " = 12" "print localval2, first nested scope"
gdb_test "print localval3" "No symbol \"localval3\" in current context." \
"print localval3, first nested scope"
# This test will only fail if the file was compiled by gcc, but
# there's no way to check that.
setup_xfail "a29k-*-udi" 2423
if [gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \
"continue to marker4 in scope.exp"] then { return }
if [gdb_test "up" "" "up from marker4 in scope.exp"] then { return }
gdb_test "print localval" " = 30" "print localval, innermost scope"
gdb_test "print localval1" " = 11" "print localval1, innermost scope"
gdb_test "print localval2" " = 12" "print localval2, innermost scope"
gdb_test "print localval3" " = 13" "print localval3, innermost scope"
}
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $objdir/$subdir/$binfile
if [istarget "*-*-vxworks*"] {
set timeout 120
}
# Test that variables in various segments print out correctly before
# the program is run.
# AIX--sections get mapped to the same address so we can't get the right one.
setup_xfail "rs6000-*-*"
setup_xfail "powerpc-*-*"
gdb_test "print 'scope0.c'::filelocal_ro" "= 201"
# gdb currently cannot access bss memory on some targets if the inferior
# is not running.
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
send "print 'scope0.c'::filelocal_bss\n"
expect {
-re " = 0\r\n$prompt $" {
pass "print 'scope0.c'::filelocal_bss before run"
}
-re "Cannot access memory.*$prompt $" {
setup_xfail "*-*-*"
fail "print 'scope0.c'::filelocal_bss before run"
}
-re ".*$prompt $" {
fail "print 'scope0.c'::filelocal_bss before run"
}
default {
fail "print 'scope0.c'::filelocal_bss before run"
}
}
# AIX--sections get mapped to the same address so we can't get the right one.
setup_xfail "rs6000-*-*"
gdb_test "print 'scope0.c'::filelocal" "= 1" \
"print 'scope0.c'::filelocal before run"
if [runto_main] then { test_at_main }
if [istarget "mips-idt-*"] then {
# Restart because IDT/SIM runs out of file descriptors.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $objdir/$subdir/$binfile
}
if [runto foo] then { test_at_foo }
if [istarget "mips-idt-*"] then {
# Restart because IDT/SIM runs out of file descriptors.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $objdir/$subdir/$binfile
}
if [runto bar] then { test_at_bar }
if [istarget "mips-idt-*"] then {
# Restart because IDT/SIM runs out of file descriptors.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $objdir/$subdir/$binfile
}
if [runto localscopes] then { test_at_localscopes }
if [istarget "mips-idt-*"] then {
# Restart because IDT/SIM runs out of file descriptors.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $objdir/$subdir/$binfile
}
if [runto autovars] then { test_at_autovars }
if [istarget "*-*-vxworks*"] {
set timeout 120
}