1995-03-14 21:25:19 +00:00
# Copyright (C) 1992, 1994 Free Software Foundation, Inc.
1994-06-07 01:57:15 +00:00
# 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
1995-08-12 22:11:33 +00:00
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
1994-06-07 01:57:15 +00:00
# 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
1997-01-29 09:40:31 +00:00
set testfile "scope"
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/scope0.c ${srcdir}/${subdir}/scope1.c" "${binfile}" executable {debug}] != "" } {
perror "Couldn't compile scope0.c to object"
return -1
1994-06-07 01:57:15 +00:00
}
1997-01-29 09:40:31 +00:00
# Create and source the file that provides information about the compiler
# used to compile the test case.
if [get_compiler_info ${binfile}] {
return -1;
}
1995-08-16 07:37:19 +00:00
1994-06-07 01:57:15 +00:00
# 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 {} {
1997-02-20 22:13:52 +00:00
global gdb_prompt
1994-06-07 01:57:15 +00:00
global decimal
global det_file
global srcdir
global subdir
1995-08-16 07:37:19 +00:00
global gcc_compiled
1994-06-07 01:57:15 +00:00
# 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.
1997-02-20 22:13:52 +00:00
if [gdb_test "next" "$decimal.*foo \\(\\);" "next over init() in main" "$decimal.*init \\(\\);" "next"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope0.c::filelocal, which is 1
1997-02-20 22:13:52 +00:00
if [gdb_test "print filelocal" "\\\$$decimal = 1" "print filelocal" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope0.c::filelocal_bss, which is 101
1997-02-20 22:13:52 +00:00
if [gdb_test "print filelocal_bss" "\\\$$decimal = 101" "print filelocal_bss" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope0.c::filelocal_ro, which is 201
1995-08-12 22:11:33 +00:00
# No clue why the powerpc fails this test.
setup_xfail "powerpc-*-*"
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
if [gdb_test "print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1995-08-12 22:11:33 +00:00
setup_xfail "powerpc-*-*"
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::filelocal, which is 2
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::filelocal_bss, which is 102
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::filelocal_ro, which is 202
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::foo::funclocal, which is 3
1997-01-29 09:40:31 +00:00
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
1997-02-20 22:13:52 +00:00
if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::foo::funclocal_ro, which is 203
1997-02-20 22:13:52 +00:00
if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::bar::funclocal, which is 4
1997-02-20 22:13:52 +00:00
if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
}
proc test_at_foo {} {
1997-02-20 22:13:52 +00:00
global gdb_prompt
1994-06-07 01:57:15 +00:00
global decimal
global det_file
global srcdir
global subdir
1995-08-16 07:37:19 +00:00
global gcc_compiled
1994-06-07 01:57:15 +00:00
1997-02-20 22:13:52 +00:00
if [gdb_test "next" ".*bar \\(\\);" "" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope0.c::filelocal, which is 1
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-12 22:11:33 +00:00
# Print scope0.c::filelocal_bss, which is 101
1994-06-07 01:57:15 +00:00
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-12 22:11:33 +00:00
# Print scope0.c::filelocal_ro, which is 201
1994-06-07 01:57:15 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1995-08-12 22:11:33 +00:00
setup_xfail "powerpc-*-*"
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-12 22:11:33 +00:00
gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo"
1994-06-07 01:57:15 +00:00
1995-08-12 22:11:33 +00:00
# Print scope1.c::filelocal, which is 2
1994-06-07 01:57:15 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-12 22:11:33 +00:00
gdb_test "print filelocal_bss" "\\\$$decimal = 102" \
"print filelocal_bss at foo"
1994-06-07 01:57:15 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"
1994-06-07 01:57:15 +00:00
1995-08-12 22:11:33 +00:00
gdb_test "print filelocal_ro" "\\\$$decimal = 202" \
"print filelocal_ro at foo"
1994-06-07 01:57:15 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"
1994-06-07 01:57:15 +00:00
# Print scope1.c::foo::funclocal, which is 3
1995-08-12 22:11:33 +00:00
gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo"
1994-06-07 01:57:15 +00:00
1997-01-29 09:40:31 +00:00
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
1995-08-12 22:11:33 +00:00
gdb_test "print foo::funclocal" "\\\$$decimal = 3" \
"print foo::funclocal at foo"
1994-06-07 01:57:15 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-01-29 09:40:31 +00:00
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
1997-02-20 22:13:52 +00:00
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"
1994-06-07 01:57:15 +00:00
# Print scope1.c::foo::funclocal_bss, which is 103
1995-08-12 22:11:33 +00:00
gdb_test "print funclocal_bss" "\\\$$decimal = 103" \
"print funclocal_bss at foo"
1994-06-07 01:57:15 +00:00
1997-01-29 09:40:31 +00:00
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
1995-08-12 22:11:33 +00:00
gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \
"print foo::funclocal_bss at foo"
1994-06-07 01:57:15 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-01-29 09:40:31 +00:00
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
1997-02-20 22:13:52 +00:00
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"
1994-06-07 01:57:15 +00:00
# Print scope1.c::foo::funclocal_ro, which is 203
1995-08-12 22:11:33 +00:00
gdb_test "print funclocal_ro" "\\\$$decimal = 203" \
"print funclocal_ro at foo"
1994-06-07 01:57:15 +00:00
1997-01-29 09:40:31 +00:00
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
1995-08-12 22:11:33 +00:00
gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \
"print foo::funclocal_ro at foo"
1994-06-07 01:57:15 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-01-29 09:40:31 +00:00
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
1997-02-20 22:13:52 +00:00
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"
1994-06-07 01:57:15 +00:00
# Print scope1.c::bar::funclocal, which is 4
1997-01-29 09:40:31 +00:00
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
1995-08-12 22:11:33 +00:00
gdb_test "print bar::funclocal" "\\\$$decimal = 4" \
"print bar::funclocal at foo"
1994-06-07 01:57:15 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-01-29 09:40:31 +00:00
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
1997-02-20 22:13:52 +00:00
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"
1994-06-07 01:57:15 +00:00
}
proc test_at_bar {} {
1997-02-20 22:13:52 +00:00
global gdb_prompt
1994-06-07 01:57:15 +00:00
global decimal
global det_file
global srcdir
global subdir
1995-08-16 07:37:19 +00:00
global gcc_compiled
1994-06-07 01:57:15 +00:00
1997-02-20 22:13:52 +00:00
if [gdb_test "next" ".*" "" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope0.c::filelocal, which is 1
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope0.c::filelocal_bss, which is 101
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope0.c::filelocal_ro, which is 201
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1995-08-12 22:11:33 +00:00
setup_xfail "powerpc-*-*"
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::filelocal, which is 2
1997-02-20 22:13:52 +00:00
if [gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at bar" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::filelocal_bss, which is 102
1997-02-20 22:13:52 +00:00
if [gdb_test "print filelocal_bss" "\\\$$decimal = 102" "print filelocal_bss at bar" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::filelocal_ro, which is 202
1997-02-20 22:13:52 +00:00
if [gdb_test "print filelocal_ro" "\\\$$decimal = 202" "print filelocal_ro in test_at_bar" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::foo::funclocal, which is 3
1997-01-29 09:40:31 +00:00
if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
1997-02-20 22:13:52 +00:00
if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal at bar" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::foo::funclocal_bss, which is 103
1997-02-20 22:13:52 +00:00
if [gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" "print foo::funclocal_bss at bar" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::foo::funclocal_ro, which is 203
1997-02-20 22:13:52 +00:00
if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro at bar" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::bar::funclocal, which is 4
1997-02-20 22:13:52 +00:00
if [gdb_test "print funclocal" "\\\$$decimal = 4" "print funclocal at bar" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal at bar" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
# Print scope1.c::bar::funclocal_bss, which is 104
1997-02-20 22:13:52 +00:00
if [gdb_test "print funclocal_bss" "\\\$$decimal = 104" "print funclocal_bss at bar" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
if [gdb_test "print bar::funclocal_bss" "\\\$$decimal = 104" "print bar::funclocal_bss at bar" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1995-08-16 07:37:19 +00:00
if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1997-02-20 22:13:52 +00:00
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"] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
}
1995-08-12 22:11:33 +00:00
# This test has little to do with local scopes, but it is in scope.exp anyway.
# That's life.
1994-06-07 01:57:15 +00:00
proc test_at_autovars {} {
1997-02-20 22:13:52 +00:00
global gdb_prompt
1994-06-07 01:57:15 +00:00
global decimal
global hex
global srcfile
# Test symbol table lookup with 100 local (auto) variables.
1997-02-20 22:13:52 +00:00
gdb_breakpoint marker1
1994-06-07 01:57:15 +00:00
1997-02-20 22:13:52 +00:00
if [gdb_test "cont" "Break.* marker1 \\(\\) at .*:$decimal.*" "continue to marker1"] {
return;
}
if [gdb_test "up" ".*" "" ] {
return ;
1994-06-07 01:57:15 +00:00
}
set count 0
while {$count < 100} {
1997-02-20 22:13:52 +00:00
if [gdb_test "print i$count" ".* = $count" "" ] {
return ;
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
1994-06-07 01:57:15 +00:00
set count [expr $count+1]
}
clear_xfail "*-*-*"
pass "$count auto variables correctly initialized"
# Test that block variable sorting is not screwing us.
1995-03-14 21:25:19 +00:00
gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order"
1994-06-07 01:57:15 +00:00
}
proc test_at_localscopes {} {
1997-02-20 22:13:52 +00:00
global gdb_prompt
1994-06-07 01:57:15 +00:00
global decimal
global hex
global srcfile
1997-02-20 22:13:52 +00:00
gdb_breakpoint marker2
gdb_breakpoint marker3
gdb_breakpoint marker4
if [gdb_test "cont" "Break.* marker2 \\(\\) at .*:$decimal.*" "continue to marker2"] {
return;
}
if [gdb_test "up" ".*" "" ] {
return ;
1994-06-07 01:57:15 +00:00
}
# Should be at first (outermost) scope. Check values.
1995-08-12 22:11:33 +00:00
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"
1994-06-07 01:57:15 +00:00
1995-08-12 22:11:33 +00:00
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 }
1994-06-07 01:57:15 +00:00
# Should be at next (first nested) scope. Check values.
1995-08-12 22:11:33 +00:00
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"
1994-06-07 01:57:15 +00:00
# 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
1995-08-12 22:11:33 +00:00
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"
1994-06-07 01:57:15 +00:00
}
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
1997-01-29 09:40:31 +00:00
gdb_load ${binfile}
1994-06-07 01:57:15 +00:00
1995-03-22 04:52:25 +00:00
if [istarget "*-*-vxworks*"] {
1994-06-07 01:57:15 +00:00
set timeout 120
1997-01-29 09:40:31 +00:00
verbose "Timeout is now $timeout seconds" 2
1994-06-07 01:57:15 +00:00
}
# 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-*-*"
1995-08-12 22:11:33 +00:00
setup_xfail "powerpc-*-*"
1994-06-07 01:57:15 +00:00
gdb_test "print 'scope0.c'::filelocal_ro" "= 201"
# gdb currently cannot access bss memory on some targets if the inferior
# is not running.
1995-08-22 19:09:39 +00:00
#
# For PA boards using monitor/remote-pa.c, the bss test is going to
# randomly fail. We've already put remote-pa on the target stack,
# so we actually read memory from the board. Problem is crt0.o
# is responsible for clearing bss and that hasnt' happened yet.
setup_xfail "hppa*-*-*pro*"
1997-01-29 09:40:31 +00:00
send_gdb "print 'scope0.c'::filelocal_bss\n"
1997-02-24 05:43:35 +00:00
gdb_expect {
1997-02-20 22:13:52 +00:00
-re " = 0\r\n$gdb_prompt $" {
1995-03-24 14:13:35 +00:00
pass "print 'scope0.c'::filelocal_bss before run"
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
-re "Cannot access memory.*$gdb_prompt $" {
1994-06-07 01:57:15 +00:00
setup_xfail "*-*-*"
1995-03-24 14:13:35 +00:00
fail "print 'scope0.c'::filelocal_bss before run"
1994-06-07 01:57:15 +00:00
}
1997-02-20 22:13:52 +00:00
-re ".*$gdb_prompt $" {
1995-03-24 14:13:35 +00:00
fail "print 'scope0.c'::filelocal_bss before run"
1994-06-07 01:57:15 +00:00
}
default {
1995-03-24 14:13:35 +00:00
fail "print 'scope0.c'::filelocal_bss before run"
1994-06-07 01:57:15 +00:00
}
}
1995-03-14 21:25:19 +00:00
gdb_test "print 'scope0.c'::filelocal" "= 1" \
"print 'scope0.c'::filelocal before run"
1994-06-07 01:57:15 +00:00
1995-08-12 22:11:33 +00:00
if [runto_main] then { test_at_main }
1994-06-07 01:57:15 +00:00
if [istarget "mips-idt-*"] then {
# Restart because IDT/SIM runs out of file descriptors.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
1997-01-29 09:40:31 +00:00
gdb_load ${binfile}
1994-06-07 01:57:15 +00:00
}
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
1997-01-29 09:40:31 +00:00
gdb_load ${binfile}
1994-06-07 01:57:15 +00:00
}
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
1997-01-29 09:40:31 +00:00
gdb_load ${binfile}
1994-06-07 01:57:15 +00:00
}
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
1997-01-29 09:40:31 +00:00
gdb_load ${binfile}
1994-06-07 01:57:15 +00:00
}
if [runto autovars] then { test_at_autovars }
1995-03-22 04:52:25 +00:00
if [istarget "*-*-vxworks*"] {
1994-06-07 01:57:15 +00:00
set timeout 120
1997-01-29 09:40:31 +00:00
verbose "Timeout is now $timeout seconds" 2
1994-06-07 01:57:15 +00:00
}