Home | History | Annotate | Line # | Download | only in gdb.base
scope.exp revision 1.8
      1  1.8  christos # Copyright 1992-2019 Free Software Foundation, Inc.
      2  1.1  christos 
      3  1.1  christos # This program is free software; you can redistribute it and/or modify
      4  1.1  christos # it under the terms of the GNU General Public License as published by
      5  1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6  1.1  christos # (at your option) any later version.
      7  1.1  christos #
      8  1.1  christos # This program is distributed in the hope that it will be useful,
      9  1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  1.1  christos # GNU General Public License for more details.
     12  1.1  christos #
     13  1.1  christos # You should have received a copy of the GNU General Public License
     14  1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  1.1  christos 
     16  1.1  christos # This file was written by Fred Fish. (fnf (at) cygnus.com)
     17  1.1  christos 
     18  1.1  christos 
     19  1.1  christos standard_testfile scope0.c scope1.c
     20  1.1  christos 
     21  1.8  christos if {[build_executable "failed to build" ${testfile} \
     22  1.1  christos 	 [list $srcfile $srcfile2] {debug}]} {
     23  1.1  christos     return -1
     24  1.1  christos }
     25  1.1  christos 
     26  1.1  christos # Create and source the file that provides information about the compiler
     27  1.1  christos # used to compile the test case.
     28  1.1  christos if [get_compiler_info] {
     29  1.1  christos     return -1
     30  1.1  christos }
     31  1.1  christos 
     32  1.1  christos # Test locating various things when stopped just inside main, after
     33  1.1  christos # running init0().  To prevent cascading of errors, we report the
     34  1.1  christos # first one and quit.  If all pass, then we print the pass results.
     35  1.1  christos 
     36  1.1  christos proc test_at_main {} {
     37  1.1  christos     global gdb_prompt
     38  1.1  christos     global decimal
     39  1.1  christos     global det_file
     40  1.1  christos     global srcdir
     41  1.1  christos     global subdir
     42  1.1  christos 
     43  1.1  christos     # skip past init0.
     44  1.1  christos     # This used to do an extra "next" if the first one didn't get us
     45  1.1  christos     # over the call to init0, to handle calls to __main in the
     46  1.1  christos     # prologue, etc.  But if a breakpoint at main doesn't leave us on
     47  1.1  christos     # the first line of real code in the function, that's a GDB bug.
     48  1.1  christos     gdb_test "next" "$decimal.*foo \\(\\);" "next over init0() in main"
     49  1.1  christos 
     50  1.1  christos     # Print scope0.c::filelocal, which is 1
     51  1.1  christos 
     52  1.1  christos     if [gdb_test "print filelocal" "\\\$$decimal = 1" "print filelocal" ] {
     53  1.1  christos       gdb_suppress_tests
     54  1.1  christos     }
     55  1.1  christos 
     56  1.1  christos 
     57  1.1  christos     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"] {
     58  1.1  christos       gdb_suppress_tests
     59  1.1  christos     }
     60  1.1  christos 
     61  1.1  christos 
     62  1.1  christos     # Print scope0.c::filelocal_bss, which is 101
     63  1.1  christos 
     64  1.1  christos     if [gdb_test "print filelocal_bss" "\\\$$decimal = 101" "print filelocal_bss" ] {
     65  1.1  christos       gdb_suppress_tests
     66  1.1  christos     }
     67  1.1  christos 
     68  1.1  christos 
     69  1.1  christos     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"] {
     70  1.1  christos       gdb_suppress_tests
     71  1.1  christos     }
     72  1.1  christos 
     73  1.1  christos 
     74  1.1  christos     # Print scope0.c::filelocal_ro, which is 201
     75  1.1  christos 
     76  1.1  christos     # No clue why the rs6000 fails this test.
     77  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
     78  1.1  christos     if [gdb_test "print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main" ] {
     79  1.1  christos       gdb_suppress_tests
     80  1.1  christos     }
     81  1.1  christos 
     82  1.1  christos 
     83  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
     84  1.1  christos     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"] {
     85  1.1  christos       gdb_suppress_tests
     86  1.1  christos     }
     87  1.1  christos 
     88  1.1  christos 
     89  1.1  christos     # Print scope1.c::filelocal, which is 2
     90  1.1  christos 
     91  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
     92  1.1  christos     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"] {
     93  1.1  christos       gdb_suppress_tests
     94  1.1  christos     }
     95  1.1  christos 
     96  1.1  christos 
     97  1.1  christos     # Print scope1.c::filelocal_bss, which is 102
     98  1.1  christos 
     99  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    100  1.1  christos     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"] {
    101  1.1  christos       gdb_suppress_tests
    102  1.1  christos     }
    103  1.1  christos 
    104  1.1  christos 
    105  1.1  christos     # Print scope1.c::filelocal_ro, which is 202
    106  1.1  christos 
    107  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    108  1.1  christos     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"] {
    109  1.1  christos       gdb_suppress_tests
    110  1.1  christos     }
    111  1.1  christos 
    112  1.1  christos 
    113  1.1  christos     # Print scope1.c::foo::funclocal, which is 3
    114  1.1  christos 
    115  1.1  christos     if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal" ] {
    116  1.1  christos       gdb_suppress_tests
    117  1.1  christos     }
    118  1.1  christos 
    119  1.1  christos 
    120  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    121  1.1  christos     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"] {
    122  1.1  christos       gdb_suppress_tests
    123  1.1  christos     }
    124  1.1  christos 
    125  1.1  christos 
    126  1.1  christos     # Print scope1.c::foo::funclocal_ro, which is 203
    127  1.1  christos 
    128  1.1  christos     if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro" ] {
    129  1.1  christos       gdb_suppress_tests
    130  1.1  christos     }
    131  1.1  christos 
    132  1.1  christos 
    133  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    134  1.1  christos     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"] {
    135  1.1  christos       gdb_suppress_tests
    136  1.1  christos     }
    137  1.1  christos 
    138  1.1  christos 
    139  1.1  christos     # Print scope1.c::bar::funclocal, which is 4
    140  1.1  christos 
    141  1.1  christos     if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal" ] {
    142  1.1  christos       gdb_suppress_tests
    143  1.1  christos     }
    144  1.1  christos 
    145  1.1  christos 
    146  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    147  1.1  christos     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"] {
    148  1.1  christos       gdb_suppress_tests
    149  1.1  christos     }
    150  1.1  christos     gdb_stop_suppressing_tests
    151  1.1  christos 
    152  1.1  christos }
    153  1.1  christos 
    154  1.1  christos proc test_at_foo {} {
    155  1.1  christos     global gdb_prompt
    156  1.1  christos     global decimal
    157  1.1  christos     global det_file
    158  1.1  christos     global srcdir
    159  1.1  christos     global subdir
    160  1.1  christos 
    161  1.1  christos     if [gdb_test "next" ".*bar \\(\\);" "" ] {
    162  1.1  christos       gdb_suppress_tests
    163  1.1  christos     }
    164  1.1  christos 
    165  1.1  christos 
    166  1.1  christos     # Print scope0.c::filelocal, which is 1
    167  1.1  christos 
    168  1.1  christos     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"] {
    169  1.1  christos       gdb_suppress_tests
    170  1.1  christos     }
    171  1.1  christos 
    172  1.1  christos 
    173  1.1  christos     # Print scope0.c::filelocal_bss, which is 101
    174  1.1  christos 
    175  1.1  christos     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"] {
    176  1.1  christos       gdb_suppress_tests
    177  1.1  christos     }
    178  1.1  christos 
    179  1.1  christos 
    180  1.1  christos     # Print scope0.c::filelocal_ro, which is 201
    181  1.1  christos 
    182  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    183  1.1  christos     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"] {
    184  1.1  christos       gdb_suppress_tests
    185  1.1  christos     }
    186  1.1  christos 
    187  1.1  christos 
    188  1.1  christos     gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo"
    189  1.1  christos 
    190  1.1  christos     # Print scope1.c::filelocal, which is 2
    191  1.1  christos 
    192  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    193  1.1  christos     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"] {
    194  1.1  christos       gdb_suppress_tests
    195  1.1  christos     }
    196  1.1  christos 
    197  1.1  christos 
    198  1.1  christos     gdb_test "print filelocal_bss" "\\\$$decimal = 102" \
    199  1.1  christos 	"print filelocal_bss at foo"
    200  1.1  christos 
    201  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    202  1.1  christos     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"
    203  1.1  christos 
    204  1.1  christos 
    205  1.1  christos     gdb_test "print filelocal_ro" "\\\$$decimal = 202" \
    206  1.1  christos 	"print filelocal_ro at foo"
    207  1.1  christos 
    208  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    209  1.1  christos     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"
    210  1.1  christos 
    211  1.1  christos 
    212  1.1  christos     # Print scope1.c::foo::funclocal, which is 3
    213  1.1  christos 
    214  1.1  christos     gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo"
    215  1.1  christos 
    216  1.1  christos     gdb_test "print foo::funclocal" "\\\$$decimal = 3" \
    217  1.1  christos 	"print foo::funclocal at foo"
    218  1.1  christos 
    219  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    220  1.1  christos     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"
    221  1.1  christos 
    222  1.1  christos 
    223  1.1  christos     # Print scope1.c::foo::funclocal_bss, which is 103
    224  1.1  christos 
    225  1.1  christos     gdb_test "print funclocal_bss" "\\\$$decimal = 103" \
    226  1.1  christos 	"print funclocal_bss at foo"
    227  1.1  christos 
    228  1.1  christos     gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \
    229  1.1  christos 	"print foo::funclocal_bss at foo"
    230  1.1  christos 
    231  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    232  1.1  christos     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"
    233  1.1  christos 
    234  1.1  christos 
    235  1.1  christos     # Print scope1.c::foo::funclocal_ro, which is 203
    236  1.1  christos 
    237  1.1  christos     gdb_test "print funclocal_ro" "\\\$$decimal = 203" \
    238  1.1  christos 	"print funclocal_ro at foo"
    239  1.1  christos 
    240  1.1  christos     gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \
    241  1.1  christos 	"print foo::funclocal_ro at foo"
    242  1.1  christos 
    243  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    244  1.1  christos     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"
    245  1.1  christos 
    246  1.1  christos 
    247  1.1  christos     # Print scope1.c::bar::funclocal, which is 4
    248  1.1  christos 
    249  1.1  christos     gdb_test "print bar::funclocal" "\\\$$decimal = 4" \
    250  1.1  christos 	"print bar::funclocal at foo"
    251  1.1  christos 
    252  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    253  1.1  christos     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"
    254  1.1  christos     gdb_stop_suppressing_tests
    255  1.1  christos 
    256  1.1  christos }
    257  1.1  christos 
    258  1.1  christos proc test_at_bar {} {
    259  1.1  christos     global gdb_prompt
    260  1.1  christos     global decimal
    261  1.1  christos     global det_file
    262  1.1  christos     global srcdir
    263  1.1  christos     global subdir
    264  1.1  christos 
    265  1.1  christos     if [gdb_test "next" ".*" "" ] {
    266  1.1  christos       gdb_suppress_tests
    267  1.1  christos     }
    268  1.1  christos 
    269  1.1  christos 
    270  1.1  christos     # Print scope0.c::filelocal, which is 1
    271  1.1  christos 
    272  1.1  christos     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"] {
    273  1.1  christos       gdb_suppress_tests
    274  1.1  christos     }
    275  1.1  christos 
    276  1.1  christos 
    277  1.1  christos    # Print scope0.c::filelocal_bss, which is 101
    278  1.1  christos 
    279  1.1  christos     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"] {
    280  1.1  christos       gdb_suppress_tests
    281  1.1  christos     }
    282  1.1  christos 
    283  1.1  christos 
    284  1.1  christos    # Print scope0.c::filelocal_ro, which is 201
    285  1.1  christos 
    286  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    287  1.1  christos     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"] {
    288  1.1  christos       gdb_suppress_tests
    289  1.1  christos     }
    290  1.1  christos 
    291  1.1  christos 
    292  1.1  christos     # Print scope1.c::filelocal, which is 2
    293  1.1  christos 
    294  1.1  christos     if [gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at bar" ] {
    295  1.1  christos       gdb_suppress_tests
    296  1.1  christos     }
    297  1.1  christos 
    298  1.1  christos 
    299  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    300  1.1  christos     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"] {
    301  1.1  christos       gdb_suppress_tests
    302  1.1  christos     }
    303  1.1  christos 
    304  1.1  christos 
    305  1.1  christos     # Print scope1.c::filelocal_bss, which is 102
    306  1.1  christos 
    307  1.1  christos     if [gdb_test "print filelocal_bss" "\\\$$decimal = 102" "print filelocal_bss at bar" ] {
    308  1.1  christos       gdb_suppress_tests
    309  1.1  christos     }
    310  1.1  christos 
    311  1.1  christos 
    312  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    313  1.1  christos     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"] {
    314  1.1  christos       gdb_suppress_tests
    315  1.1  christos     }
    316  1.1  christos 
    317  1.1  christos 
    318  1.1  christos     # Print scope1.c::filelocal_ro, which is 202
    319  1.1  christos 
    320  1.1  christos     if [gdb_test "print filelocal_ro" "\\\$$decimal = 202" "print filelocal_ro in test_at_bar" ] {
    321  1.1  christos       gdb_suppress_tests
    322  1.1  christos     }
    323  1.1  christos 
    324  1.1  christos 
    325  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    326  1.1  christos     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"] {
    327  1.1  christos       gdb_suppress_tests
    328  1.1  christos     }
    329  1.1  christos 
    330  1.1  christos 
    331  1.1  christos     # Print scope1.c::foo::funclocal, which is 3
    332  1.1  christos 
    333  1.1  christos     if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal at bar" ] {
    334  1.1  christos       gdb_suppress_tests
    335  1.1  christos     }
    336  1.1  christos 
    337  1.1  christos 
    338  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    339  1.1  christos     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"] {
    340  1.1  christos       gdb_suppress_tests
    341  1.1  christos     }
    342  1.1  christos 
    343  1.1  christos 
    344  1.1  christos     # Print scope1.c::foo::funclocal_bss, which is 103
    345  1.1  christos 
    346  1.1  christos     if [gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" "print foo::funclocal_bss at bar" ] {
    347  1.1  christos       gdb_suppress_tests
    348  1.1  christos     }
    349  1.1  christos 
    350  1.1  christos 
    351  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    352  1.1  christos     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"] {
    353  1.1  christos       gdb_suppress_tests
    354  1.1  christos     }
    355  1.1  christos 
    356  1.1  christos 
    357  1.1  christos     # Print scope1.c::foo::funclocal_ro, which is 203
    358  1.1  christos 
    359  1.1  christos     if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro at bar" ] {
    360  1.1  christos       gdb_suppress_tests
    361  1.1  christos     }
    362  1.1  christos 
    363  1.1  christos 
    364  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    365  1.1  christos     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"] {
    366  1.1  christos       gdb_suppress_tests
    367  1.1  christos     }
    368  1.1  christos 
    369  1.1  christos 
    370  1.1  christos     # Print scope1.c::bar::funclocal, which is 4
    371  1.1  christos 
    372  1.1  christos     if [gdb_test "print funclocal" "\\\$$decimal = 4" "print funclocal at bar" ] {
    373  1.1  christos       gdb_suppress_tests
    374  1.1  christos     }
    375  1.1  christos 
    376  1.1  christos 
    377  1.1  christos     if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal at bar" ] {
    378  1.1  christos       gdb_suppress_tests
    379  1.1  christos     }
    380  1.1  christos 
    381  1.1  christos 
    382  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    383  1.1  christos     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"] {
    384  1.1  christos       gdb_suppress_tests
    385  1.1  christos     }
    386  1.1  christos 
    387  1.1  christos 
    388  1.1  christos     # Print scope1.c::bar::funclocal_bss, which is 104
    389  1.1  christos 
    390  1.1  christos     if [gdb_test "print funclocal_bss" "\\\$$decimal = 104" "print funclocal_bss at bar" ] {
    391  1.1  christos       gdb_suppress_tests
    392  1.1  christos     }
    393  1.1  christos 
    394  1.1  christos 
    395  1.1  christos     if [gdb_test "print bar::funclocal_bss" "\\\$$decimal = 104" "print bar::funclocal_bss at bar" ] {
    396  1.1  christos       gdb_suppress_tests
    397  1.1  christos     }
    398  1.1  christos 
    399  1.1  christos 
    400  1.1  christos     if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
    401  1.1  christos     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"] {
    402  1.1  christos       gdb_suppress_tests
    403  1.1  christos     }
    404  1.1  christos     gdb_stop_suppressing_tests
    405  1.1  christos 
    406  1.1  christos }
    407  1.1  christos 
    408  1.1  christos # This test has little to do with local scopes, but it is in scope.exp anyway.
    409  1.1  christos # That's life.
    410  1.1  christos 
    411  1.1  christos proc test_at_autovars {} {
    412  1.1  christos     global gdb_prompt
    413  1.1  christos     global decimal
    414  1.1  christos     global hex
    415  1.1  christos     global srcfile
    416  1.1  christos 
    417  1.1  christos     # Test symbol table lookup with 100 local (auto) variables.
    418  1.1  christos 
    419  1.1  christos     gdb_breakpoint marker1
    420  1.1  christos 
    421  1.1  christos     if [gdb_test "cont" "Break.* marker1 \\(\\) at .*:$decimal.*" "continue to marker1"] {
    422  1.1  christos 	gdb_suppress_tests
    423  1.1  christos     }
    424  1.1  christos 
    425  1.1  christos     if [gdb_test "up" ".*autovars.*" "up from marker1 in scope.exp" ] {
    426  1.1  christos 	gdb_suppress_tests
    427  1.1  christos     }
    428  1.1  christos 
    429  1.1  christos     set count 0
    430  1.1  christos     while {$count < 100} {
    431  1.1  christos 	if [gdb_test "print i$count" ".* = $count" "" ] {
    432  1.1  christos 	  gdb_suppress_tests
    433  1.1  christos 	}
    434  1.1  christos 
    435  1.1  christos 	set count [expr $count+1]
    436  1.1  christos     }
    437  1.1  christos     clear_xfail "*-*-*"
    438  1.1  christos     pass "$count auto variables correctly initialized"
    439  1.1  christos 
    440  1.1  christos     # Test that block variable sorting is not screwing us.
    441  1.1  christos     gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order"
    442  1.1  christos }
    443  1.1  christos 
    444  1.1  christos proc test_at_localscopes {} {
    445  1.1  christos     global gdb_prompt
    446  1.1  christos     global decimal
    447  1.1  christos     global hex
    448  1.1  christos     global srcfile
    449  1.1  christos 
    450  1.1  christos     gdb_breakpoint marker2
    451  1.1  christos     gdb_breakpoint marker3
    452  1.1  christos     gdb_breakpoint marker4
    453  1.1  christos 
    454  1.1  christos     if [gdb_test "cont" "Break.* marker2 \\(\\) at .*:$decimal.*" "continue to marker2"] {
    455  1.1  christos 	gdb_suppress_tests
    456  1.1  christos     }
    457  1.1  christos     if [gdb_test "up" ".*localscopes.*" "up from marker2 in scopes.exp" ] {
    458  1.1  christos 	gdb_suppress_tests
    459  1.1  christos     }
    460  1.1  christos 
    461  1.1  christos     # Should be at first (outermost) scope.  Check values.
    462  1.1  christos 
    463  1.1  christos     gdb_test "print localval" " = 10" "print localval, outer scope"
    464  1.1  christos     gdb_test "print localval1" " = 11" "print localval1, outer scope"
    465  1.1  christos     gdb_test "print localval2" "No symbol \"localval2\" in current context." \
    466  1.1  christos 	"print localval2, outer scope"
    467  1.1  christos     gdb_test "print localval3" "No symbol \"localval3\" in current context." \
    468  1.1  christos 	"print localval3, outer scope"
    469  1.1  christos 
    470  1.1  christos     if [gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \
    471  1.1  christos 	"continue to marker3 in scope.exp"] then { gdb_suppress_tests }
    472  1.1  christos     if [gdb_test "up" ".*localscopes.*" "up from marker3 in scope.exp"] {
    473  1.1  christos 	gdb_suppress_tests
    474  1.1  christos     }
    475  1.1  christos 
    476  1.1  christos     # Should be at next (first nested) scope.  Check values.
    477  1.1  christos 
    478  1.1  christos     gdb_test "print localval" " = 20" \
    479  1.1  christos 	"print localval, first nested scope"
    480  1.1  christos     gdb_test "print localval1" " = 11" "print localval1, first nested scope"
    481  1.1  christos     gdb_test "print localval2" " = 12" "print localval2, first nested scope"
    482  1.1  christos     gdb_test "print localval3" "No symbol \"localval3\" in current context." \
    483  1.1  christos 	"print localval3, first nested scope"
    484  1.1  christos 
    485  1.1  christos     # This test will only fail if the file was compiled by gcc, but
    486  1.1  christos     # there's no way to check that.
    487  1.1  christos     if [gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \
    488  1.1  christos 	"continue to marker4 in scope.exp"] then { gdb_suppress_tests }
    489  1.1  christos     if [gdb_test "up" ".*localscopes.*" "up from marker4 in scope.exp"] {
    490  1.1  christos 	gdb_suppress_tests
    491  1.1  christos     }
    492  1.1  christos 
    493  1.1  christos     gdb_test "print localval" " = 30" "print localval, innermost scope"
    494  1.1  christos     gdb_test "print localval1" " = 11" "print localval1, innermost scope"
    495  1.1  christos     gdb_test "print localval2" " = 12" "print localval2, innermost scope"
    496  1.1  christos     gdb_test "print localval3" " = 13" "print localval3, innermost scope"
    497  1.1  christos     gdb_stop_suppressing_tests
    498  1.1  christos }
    499  1.1  christos 
    500  1.8  christos # Note, we don't pass a binfile to clean_restart because we need to
    501  1.8  christos # avoid gdb_load here.  With remote targets, gdb_load connects to the
    502  1.8  christos # remote target, and we specificaly want the following tests to run
    503  1.8  christos # before the program is started.
    504  1.8  christos clean_restart
    505  1.8  christos gdb_file_cmd $binfile
    506  1.8  christos 
    507  1.1  christos # Test that variables in various segments print out correctly before
    508  1.1  christos # the program is run.
    509  1.1  christos 
    510  1.1  christos # AIX--sections get mapped to the same address so we can't get the right one.
    511  1.1  christos setup_xfail "rs6000-*-*"
    512  1.1  christos 
    513  1.1  christos gdb_test "print 'scope0.c'::filelocal_ro" "= 201"
    514  1.1  christos 
    515  1.8  christos # Check that gdb can access bss memory if the inferior is not running.
    516  1.1  christos #
    517  1.8  christos # Note the care above about avoiding gdb_load.  Otherwise, for
    518  1.8  christos # embedded stub-like boards, this test would randomly fail.  If we'd
    519  1.8  christos # already put target remote on the target stack, we'd read memory from
    520  1.8  christos # the board instead of the program's binary, and we would have
    521  1.8  christos # connected before crt0.o had had a chance to clear bss.
    522  1.8  christos gdb_test "print 'scope0.c'::filelocal_bss" "= 0" \
    523  1.8  christos     "print 'scope0.c'::filelocal_bss before run"
    524  1.1  christos 
    525  1.1  christos gdb_test "print 'scope0.c'::filelocal" "= 1" \
    526  1.1  christos     "print 'scope0.c'::filelocal before run"
    527  1.1  christos 
    528  1.1  christos if [runto_main] then { test_at_main }
    529  1.1  christos if [runto foo] then { test_at_foo }
    530  1.1  christos if [runto bar] then { test_at_bar }
    531  1.1  christos if [runto localscopes] then { test_at_localscopes }
    532  1.1  christos if [runto autovars] then { test_at_autovars }
    533