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