Major revision to testsuites for cross-testing and DOS testing support.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / scope.exp
1 # Copyright (C) 1992, 1994 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Fred Fish. (fnf@cygnus.com)
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 set prms_id 0
27 set bug_id 0
28
29 set testfile "scope"
30 set binfile ${objdir}/${subdir}/${testfile}
31 if { [gdb_compile "${srcdir}/${subdir}/scope0.c ${srcdir}/${subdir}/scope1.c" "${binfile}" executable {debug}] != "" } {
32 perror "Couldn't compile scope0.c to object"
33 return -1
34 }
35
36 # Create and source the file that provides information about the compiler
37 # used to compile the test case.
38 if [get_compiler_info ${binfile}] {
39 return -1;
40 }
41
42 # Test locating various things when stopped just inside main, after
43 # running init(). To prevent cascading of errors, we report the
44 # first one and quit. If all pass, then we print the pass results.
45
46 proc test_at_main {} {
47 global prompt
48 global decimal
49 global det_file
50 global srcdir
51 global subdir
52 global gcc_compiled
53
54 # skip past init. There may be a call to __main at the start of
55 # main, so the first next may only get us to the init call.
56 send_gdb "next\n"
57 expect {
58 -re "$decimal.*foo \\(\\);\r\n$prompt $" {
59 pass "next over init() in main"
60 }
61 -re "$decimal.*init \\(\\);\r\n$prompt $"\
62 { send_gdb "next\n" ; exp_continue }
63 -re "$prompt $" { fail "next over init() in main" ; return }
64 timeout { fail "(timeout) next over init() in main" ; return }
65 }
66
67 # Print scope0.c::filelocal, which is 1
68
69 send_gdb "print filelocal\n"
70 expect {
71 -re "\\\$$decimal = 1\r\n$prompt $" { pass "print filelocal" }
72 -re "$prompt $" { fail "print filelocal" ; return }
73 timeout {
74 fail "(timeout) print filelocal" ; return
75 }
76 }
77
78 send_gdb "print 'scope0.c'::filelocal\n"
79 expect {
80 -re "\\\$$decimal = 1\r\n$prompt $" {
81 pass "print 'scope0.c'::filelocal at main"
82 }
83 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
84 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal\n"
85 exp_continue
86 }
87 -re "$prompt $" { fail "print 'scope0.c'::filelocal at main" ; return }
88 timeout {
89 fail "(timeout) print 'scope0.c'::filelocal at main" ; return
90 }
91 }
92
93 # Print scope0.c::filelocal_bss, which is 101
94
95 send_gdb "print filelocal_bss\n"
96 expect {
97 -re "\\\$$decimal = 101\r\n$prompt $" {
98 pass "print filelocal_bss"
99 }
100 -re "$prompt $" { fail "print filelocal_bss" ; return }
101 timeout {
102 fail "(timeout) print filelocal_bss" ; return
103 }
104 }
105
106 send_gdb "print 'scope0.c'::filelocal_bss\n"
107 expect {
108 -re "\\\$$decimal = 101\r\n$prompt $" {
109 pass "print 'scope0.c'::filelocal_bss in test_at_main"
110 }
111 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
112 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
113 exp_continue
114 }
115 -re "$prompt $" {
116 fail "print 'scope0.c'::filelocal_bss in test_at_main" ; return
117 }
118 timeout {
119 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_main"
120 return
121 }
122 }
123
124 # Print scope0.c::filelocal_ro, which is 201
125
126 # No clue why the powerpc fails this test.
127 setup_xfail "powerpc-*-*"
128 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
129 send_gdb "print filelocal_ro\n"
130 expect {
131 -re "\\\$$decimal = 201\r\n$prompt $" {
132 pass "print filelocal_ro in test_at_main"
133 }
134 -re "$prompt $" {
135 fail "print filelocal_ro in test_at_main"
136 return
137 }
138 timeout {
139 fail "(timeout) print filelocal_ro in test_at_main"
140 return
141 }
142 }
143
144 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
145 setup_xfail "powerpc-*-*"
146 send_gdb "print 'scope0.c'::filelocal_ro\n"
147 expect {
148 -re "\\\$$decimal = 201\r\n$prompt $" {
149 pass "print 'scope0.c'::filelocal_ro"
150 }
151 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
152 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
153 exp_continue
154 }
155 -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
156 timeout {
157 fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
158 }
159 }
160
161 # Print scope1.c::filelocal, which is 2
162
163 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
164 send_gdb "print 'scope1.c'::filelocal\n"
165 expect {
166 -re "\\\$$decimal = 2\r\n$prompt $" {
167 pass "print 'scope1.c'::filelocal"
168 }
169 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
170 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal\n"
171 exp_continue
172 }
173 -re "$prompt $" { fail "print 'scope1.c'::filelocal" ; return }
174 timeout {
175 fail "(timeout) print 'scope1.c'::filelocal" ; return
176 }
177 }
178
179 # Print scope1.c::filelocal_bss, which is 102
180
181 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
182 send_gdb "print 'scope1.c'::filelocal_bss\n"
183 expect {
184 -re "\\\$$decimal = 102\r\n$prompt $" {
185 pass "print 'scope1.c'::filelocal_bss"
186 }
187 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
188 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
189 exp_continue
190 }
191 -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss" ; return }
192 timeout {
193 fail "(timeout) print 'scope1.c'::filelocal_bss" ; return
194 }
195 }
196
197 # Print scope1.c::filelocal_ro, which is 202
198
199 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
200 send_gdb "print 'scope1.c'::filelocal_ro\n"
201 expect {
202 -re "\\\$$decimal = 202\r\n$prompt $" {
203 pass "print 'scope1.c'::filelocal_ro"
204 }
205 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
206 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
207 exp_continue
208 }
209 -re "$prompt " {fail "print 'scope1.c'::filelocal_ro" ; return }
210 timeout {
211 fail "(timeout) print 'scope1.c'::filelocal_ro" ; return
212 }
213 }
214
215 # Print scope1.c::foo::funclocal, which is 3
216
217 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
218 send_gdb "print foo::funclocal\n"
219 expect {
220 -re "\\\$$decimal = 3\r\n$prompt $" { pass "print foo::funclocal" }
221 -re "$prompt $" { fail "print foo::funclocal" ; return }
222 timeout {
223 fail "(timeout) print foo::funclocal" ; return
224 }
225 }
226
227 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
228 send_gdb "print 'scope1.c'::foo::funclocal\n"
229 expect {
230 -re "\\\$$decimal = 3\r\n$prompt $" {
231 pass "print 'scope1.c'::foo::funclocal"
232 }
233 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
234 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
235 exp_continue
236 }
237 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal" ; return }
238 timeout {
239 fail "(timeout) print 'scope1.c'::foo::funclocal" ; return
240 }
241 }
242
243 # Print scope1.c::foo::funclocal_ro, which is 203
244
245 send_gdb "print foo::funclocal_ro\n"
246 expect {
247 -re "\\\$$decimal = 203\r\n$prompt $" {
248 pass "print foo::funclocal_ro"
249 }
250 -re "$prompt $" { fail "print foo::funclocal_ro" ; return }
251 timeout {
252 fail "(timeout) print foo::funclocal_ro" ; return
253 }
254 }
255
256 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
257 send_gdb "print 'scope1.c'::foo::funclocal_ro\n"
258 expect {
259 -re "\\\$$decimal = 203\r\n$prompt $" {
260 pass "print 'scope1.c'::foo::funclocal_ro" }
261 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
262 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
263 exp_continue
264 }
265 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro" ; return }
266 timeout {
267 fail "(timeout) print 'scope1.c'::foo::funclocal_ro" ; return
268 }
269 }
270
271 # Print scope1.c::bar::funclocal, which is 4
272
273 send_gdb "print bar::funclocal\n"
274 expect {
275 -re "\\\$$decimal = 4\r\n$prompt $" { pass "print bar::funclocal" }
276 -re "$prompt $" { fail "print bar::funclocal" ; return }
277 timeout {
278 fail "(timeout) print bar::funclocal" ; return
279 }
280 }
281
282 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
283 send_gdb "print 'scope1.c'::bar::funclocal\n"
284 expect {
285 -re "\\\$$decimal = 4\r\n$prompt $" {
286 pass "print 'scope1.c'::bar::funclocal"
287 }
288 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
289 send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
290 exp_continue
291 }
292 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal" ; return }
293 timeout {
294 fail "(timeout) print 'scope1.c'::bar::funclocal" ; return
295 }
296 }
297 }
298
299 proc test_at_foo {} {
300 global prompt
301 global decimal
302 global det_file
303 global srcdir
304 global subdir
305 global gcc_compiled
306
307 send_gdb "next\n"
308 expect {
309 -re ".*bar \\(\\);\r\n$prompt $" {}
310 -re "$prompt $" { fail "continue to foo()" ; return }
311 timeout { fail "(timeout) continue to foo()" ; return }
312 }
313
314 # Print scope0.c::filelocal, which is 1
315
316 send_gdb "print 'scope0.c'::filelocal\n"
317 expect {
318 -re "\\\$$decimal = 1\r\n$prompt $" {
319 pass "print 'scope0.c'::filelocal at foo"
320 }
321 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
322 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal\n"
323 exp_continue
324 }
325 -re "$prompt $" { fail "print 'scope0.c'::filelocal at foo" ; return }
326 timeout {
327 fail "(timeout) print 'scope0.c'::filelocal at foo" ; return
328 }
329 }
330
331 # Print scope0.c::filelocal_bss, which is 101
332
333 send_gdb "print 'scope0.c'::filelocal_bss\n"
334 expect {
335 -re "\\\$$decimal = 101\r\n$prompt $" {
336 pass "print 'scope0.c'::filelocal_bss in test_at_foo"
337 }
338 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
339 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
340 exp_continue
341 }
342 -re "$prompt $" {
343 fail "print 'scope0.c'::filelocal_bss in test_at_foo"
344 return
345 }
346 timeout {
347 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_foo"
348 return
349 }
350 }
351
352 # Print scope0.c::filelocal_ro, which is 201
353
354 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
355 setup_xfail "powerpc-*-*"
356 send_gdb "print 'scope0.c'::filelocal_ro\n"
357 expect {
358 -re "\\\$$decimal = 201\r\n$prompt $" { pass "print 'scope0.c'::filelocal_ro" }
359 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
360 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
361 exp_continue
362 }
363 -re "$prompt $" { fail "print 'scope0.c'::filelocal_ro" ; return }
364 timeout {
365 fail "(timeout) print 'scope0.c'::filelocal_ro" ; return
366 }
367 }
368
369 gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo"
370
371 # Print scope1.c::filelocal, which is 2
372
373 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
374 send_gdb "print 'scope1.c'::filelocal\n"
375 expect {
376 -re "\\\$$decimal = 2\r\n$prompt $" {
377 pass "print 'scope1.c'::filelocal at foo"
378 }
379 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
380 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal\n"
381 exp_continue
382 }
383 -re "$prompt $" { fail "print 'scope1.c'::filelocal at foo" ; return }
384 timeout {
385 fail "(timeout) print 'scope1.c'::filelocal at foo" ; return
386 }
387 }
388
389 gdb_test "print filelocal_bss" "\\\$$decimal = 102" \
390 "print filelocal_bss at foo"
391
392 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
393 send_gdb "print 'scope1.c'::filelocal_bss\n"
394 expect {
395 -re "\\\$$decimal = 102\r\n$prompt $" {
396 pass "print 'scope1.c'::filelocal_bss at foo"
397 }
398 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
399 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
400 exp_continue
401 }
402 -re "$prompt $" { fail "print 'scope1.c'::filelocal_bss at foo" }
403 timeout {
404 fail "(timeout) print 'scope1.c'::filelocal_bss at foo"
405 }
406 }
407
408 gdb_test "print filelocal_ro" "\\\$$decimal = 202" \
409 "print filelocal_ro at foo"
410
411 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
412 send_gdb "print 'scope1.c'::filelocal_ro\n"
413 expect {
414 -re "\\\$$decimal = 202\r\n$prompt $" { pass "print 'scope1.c'::filelocal_ro at foo" }
415 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
416 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
417 exp_continue
418 }
419 -re "$prompt $" { fail "print 'scope1.c'::filelocal_ro at foo" }
420 timeout {
421 fail "(timeout) print 'scope1.c'::filelocal_ro at foo"
422 }
423 }
424
425 # Print scope1.c::foo::funclocal, which is 3
426
427 gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo"
428
429 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
430 gdb_test "print foo::funclocal" "\\\$$decimal = 3" \
431 "print foo::funclocal at foo"
432
433 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
434 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
435 send_gdb "print 'scope1.c'::foo::funclocal\n"
436 expect {
437 -re "\\\$$decimal = 3\r\n$prompt $" {
438 pass "print 'scope1.c'::foo::funclocal at foo"
439 }
440 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
441 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
442 exp_continue
443 }
444 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal at foo" }
445 timeout {
446 fail "(timeout) print 'scope1.c'::foo::funclocal at foo"
447 }
448 }
449
450 # Print scope1.c::foo::funclocal_bss, which is 103
451
452 gdb_test "print funclocal_bss" "\\\$$decimal = 103" \
453 "print funclocal_bss at foo"
454
455 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
456 gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \
457 "print foo::funclocal_bss at foo"
458
459 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
460 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
461 send_gdb "print 'scope1.c'::foo::funclocal_bss\n"
462 expect {
463 -re "\\\$$decimal = 103\r\n$prompt $" {
464 pass "print 'scope1.c'::foo::funclocal_bss at foo"
465 }
466 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
467 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n"
468 exp_continue
469 }
470 -re "$prompt $" {
471 fail "print 'scope1.c'::foo::funclocal_bss at foo"
472 }
473 timeout {
474 fail "(timeout) print 'scope1.c'::foo::funclocal_bss at foo"
475 }
476 }
477
478 # Print scope1.c::foo::funclocal_ro, which is 203
479
480 gdb_test "print funclocal_ro" "\\\$$decimal = 203" \
481 "print funclocal_ro at foo"
482
483 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
484 gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \
485 "print foo::funclocal_ro at foo"
486
487 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
488 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
489 send_gdb "print 'scope1.c'::foo::funclocal_ro\n"
490 expect {
491 -re "\\\$$decimal = 203\r\n$prompt $" {
492 pass "print 'scope1.c'::foo::funclocal_ro at foo"
493 }
494 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
495 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
496 exp_continue
497 }
498 -re "$prompt $" { fail "print 'scope1.c'::foo::funclocal_ro at foo" }
499 timeout {
500 fail "(timeout) print 'scope1.c'::foo::funclocal_ro at foo"
501 }
502 }
503
504 # Print scope1.c::bar::funclocal, which is 4
505
506 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
507 gdb_test "print bar::funclocal" "\\\$$decimal = 4" \
508 "print bar::funclocal at foo"
509
510 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
511 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
512 send_gdb "print 'scope1.c'::bar::funclocal\n"
513 expect {
514 -re "\\\$$decimal = 4\r\n$prompt $" {
515 pass "print 'scope1.c'::bar::funclocal at foo"
516 }
517 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
518 send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
519 exp_continue
520 }
521 -re "$prompt $" { fail "print 'scope1.c'::bar::funclocal at foo" }
522 timeout {
523 fail "(timeout) print 'scope1.c'::bar::funclocal at foo"
524 }
525 }
526 }
527
528 proc test_at_bar {} {
529 global prompt
530 global decimal
531 global det_file
532 global srcdir
533 global subdir
534 global gcc_compiled
535
536 send_gdb "next\n"
537 expect {
538 -re ".*$prompt $" {}
539 timeout { fail "(timeout) next in bar()" ; return }
540 }
541
542 # Print scope0.c::filelocal, which is 1
543
544 send_gdb "print 'scope0.c'::filelocal\n"
545 expect {
546 -re "\\\$$decimal = 1\r\n$prompt $" {
547 pass "print 'scope0.c'::filelocal at bar"
548 }
549 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
550 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal\n"
551 exp_continue
552 }
553 -re "$prompt $" {
554 fail "print 'scope0.c'::filelocal at bar" ; return
555 }
556 timeout {
557 fail "(timeout) print 'scope0.c'::filelocal at bar" ; return
558 }
559 }
560
561 # Print scope0.c::filelocal_bss, which is 101
562
563 send_gdb "print 'scope0.c'::filelocal_bss\n"
564 expect {
565 -re "\\\$$decimal = 101\r\n$prompt $" {
566 pass "print 'scope0.c'::filelocal_bss in test_at_bar"
567 }
568 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
569 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_bss\n"
570 exp_continue
571 }
572 -re "$prompt $" {
573 fail "print 'scope0.c'::filelocal_bss in test_at_bar"
574 return
575 }
576 timeout {
577 fail "(timeout) print 'scope0.c'::filelocal_bss in test_at_bar"
578 return
579 }
580 }
581
582 # Print scope0.c::filelocal_ro, which is 201
583
584 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
585 setup_xfail "powerpc-*-*"
586 send_gdb "print 'scope0.c'::filelocal_ro\n"
587 expect {
588 -re "\\\$$decimal = 201\r\n$prompt $" {
589 pass "print 'scope0.c'::filelocal_ro at bar"
590 }
591 -re "No symbol \"scope0.c\" in current context.*$prompt $" {
592 send_gdb "print '$srcdir/$subdir/scope0.c'::filelocal_ro\n"
593 exp_continue
594 }
595 -re "$prompt $" {
596 fail "print 'scope0.c'::filelocal_ro at bar" ; return
597 }
598 timeout {
599 fail "(timeout) print 'scope0.c'::filelocal_ro at bar" ; return
600 }
601 }
602
603 # Print scope1.c::filelocal, which is 2
604
605 send_gdb "print filelocal\n"
606 expect {
607 -re "\\\$$decimal = 2\r\n$prompt $" {
608 pass "print filelocal at bar"
609 }
610 -re "$prompt $" {
611 fail "print filelocal at bar" ; return
612 }
613 timeout {
614 fail "(timeout) print filelocal at bar" ; return
615 }
616 }
617
618 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
619 send_gdb "print 'scope1.c'::filelocal\n"
620 expect {
621 -re "\\\$$decimal = 2\r\n$prompt $" {
622 pass "print 'scope1.c'::filelocal at bar"
623 }
624 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
625 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal\n"
626 exp_continue
627 }
628 -re "$prompt $" {
629 fail "print 'scope1.c'::filelocal at bar" ; return
630 }
631 timeout {
632 fail "(timeout) print 'scope1.c'::filelocal at bar" ; return
633 }
634 }
635
636 # Print scope1.c::filelocal_bss, which is 102
637
638 send_gdb "print filelocal_bss\n"
639 expect {
640 -re "\\\$$decimal = 102\r\n$prompt $" {
641 pass "print filelocal_bss at bar"
642 }
643 -re "$prompt $" {
644 fail "print filelocal_bss at bar" ; return
645 }
646 timeout {
647 fail "(timeout) print filelocal_bss at bar" ; return
648 }
649 }
650
651 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
652 send_gdb "print 'scope1.c'::filelocal_bss\n"
653 expect {
654 -re "\\\$$decimal = 102\r\n$prompt $" {
655 pass "print 'scope1.c'::filelocal_bss at bar"
656 }
657 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
658 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_bss\n"
659 exp_continue
660 }
661 -re "$prompt $" {
662 fail "print 'scope1.c'::filelocal_bss at bar" ; return
663 }
664 timeout {
665 fail "(timeout) print 'scope1.c'::filelocal_bss at bar" ; return
666 }
667 }
668
669 # Print scope1.c::filelocal_ro, which is 202
670
671 send_gdb "print filelocal_ro\n"
672 expect {
673 -re "\\\$$decimal = 202\r\n$prompt $" {
674 pass "print filelocal_ro in test_at_bar"
675 }
676 -re "$prompt $" {
677 fail "print filelocal_ro in test_at_bar"
678 return
679 }
680 timeout {
681 fail "(timeout) print filelocal_ro in test_at_bar"
682 return
683 }
684 }
685
686 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
687 send_gdb "print 'scope1.c'::filelocal_ro\n"
688 expect {
689 -re "\\\$$decimal = 202\r\n$prompt $" {
690 pass "print 'scope1.c'::filelocal_ro at bar"
691 }
692 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
693 send_gdb "print '$srcdir/$subdir/scope1.c'::filelocal_ro\n"
694 exp_continue
695 }
696 -re "$prompt $" {
697 fail "print 'scope1.c'::filelocal_ro at bar" ; return
698 }
699 timeout {
700 fail "(timeout) print 'scope1.c'::filelocal_ro at bar" ; return
701 }
702 }
703
704 # Print scope1.c::foo::funclocal, which is 3
705
706 if {!$gcc_compiled} then { setup_xfail "hppa*-*-hpux*" }
707 send_gdb "print foo::funclocal\n"
708 expect {
709 -re "\\\$$decimal = 3\r\n$prompt $" {
710 pass "print foo::funclocal at bar"
711 }
712 -re "$prompt $" {
713 fail "print foo::funclocal at bar" ; return
714 }
715 timeout {
716 fail "(timeout) print foo::funclocal at bar" ; return
717 }
718 }
719
720 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
721 send_gdb "print 'scope1.c'::foo::funclocal\n"
722 expect {
723 -re "\\\$$decimal = 3\r\n$prompt $" {
724 pass "print 'scope1.c'::foo::funclocal at bar"
725 }
726 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
727 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal\n"
728 exp_continue
729 }
730 -re "$prompt $" {
731 fail "print 'scope1.c'::foo::funclocal at bar" ; return
732 }
733 timeout {
734 fail "(timeout) print 'scope1.c'::foo::funclocal at bar" ; return
735 }
736 }
737
738 # Print scope1.c::foo::funclocal_bss, which is 103
739
740 send_gdb "print foo::funclocal_bss\n"
741 expect {
742 -re "\\\$$decimal = 103\r\n$prompt $" {
743 pass "print foo::funclocal_bss at bar"
744 }
745 -re "$prompt $" {
746 fail "print foo::funclocal_bss at bar" ; return
747 }
748 timeout {
749 fail "(timeout) print foo::funclocal_bss at bar" ; return
750 }
751 }
752
753 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
754 send_gdb "print 'scope1.c'::foo::funclocal_bss\n"
755 expect {
756 -re "\\\$$decimal = 103\r\n$prompt $" {
757 pass "print 'scope1.c'::foo::funclocal_bss at bar"
758 }
759 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
760 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss\n"
761 exp_continue
762 }
763 -re "$prompt $" {
764 fail "print 'scope1.c'::foo::funclocal_bss at bar" ; return
765 }
766 timeout {
767 fail "(timeout) print 'scope1.c'::foo::funclocal_bss at bar" ; return
768 }
769 }
770
771 # Print scope1.c::foo::funclocal_ro, which is 203
772
773 send_gdb "print foo::funclocal_ro\n"
774 expect {
775 -re "\\\$$decimal = 203\r\n$prompt $" {
776 pass "print foo::funclocal_ro at bar"
777 }
778 -re "$prompt $" {
779 fail "print foo::funclocal_ro at bar" ; return
780 }
781 timeout {
782 fail "(timeout) print foo::funclocal_ro at bar" ; return
783 }
784 }
785
786 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
787 send_gdb "print 'scope1.c'::foo::funclocal_ro\n"
788 expect {
789 -re "\\\$$decimal = 203\r\n$prompt $" {
790 pass "print 'scope1.c'::foo::funclocal_ro at bar"
791 }
792 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
793 send_gdb "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro\n"
794 exp_continue
795 }
796 -re "$prompt $" {
797 fail "print 'scope1.c'::foo::funclocal_ro at bar" ; return
798 }
799 timeout {
800 fail "(timeout) print 'scope1.c'::foo::funclocal_ro at bar" ; return
801 }
802 }
803
804 # Print scope1.c::bar::funclocal, which is 4
805
806 send_gdb "print funclocal\n"
807 expect {
808 -re "\\\$$decimal = 4\r\n$prompt $" {
809 pass "print funclocal at bar"
810 }
811 -re "$prompt $" {
812 fail "print funclocal at bar" ; return
813 }
814 timeout {
815 fail "(timeout) print funclocal at bar" ; return
816 }
817 }
818
819 send_gdb "print bar::funclocal\n"
820 expect {
821 -re "\\\$$decimal = 4\r\n$prompt $" {
822 pass "print bar::funclocal at bar"
823 }
824 -re "$prompt $" {
825 fail "print bar::funclocal at bar" ; return
826 }
827 timeout {
828 fail "(timeout) print bar::funclocal at bar" ; return
829 }
830 }
831
832 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
833 send_gdb "print 'scope1.c'::bar::funclocal\n"
834 expect {
835 -re "\\\$$decimal = 4\r\n$prompt $" {
836 pass "print 'scope1.c'::bar::funclocal at bar"
837 }
838 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
839 send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal\n"
840 exp_continue
841 }
842 -re "$prompt $" {
843 fail "print 'scope1.c'::bar::funclocal at bar" ; return
844 }
845 timeout {
846 fail "(timeout) print 'scope1.c'::bar::funclocal at bar" ; return
847 }
848 }
849
850 # Print scope1.c::bar::funclocal_bss, which is 104
851
852 send_gdb "print funclocal_bss\n"
853 expect {
854 -re "\\\$$decimal = 104\r\n$prompt $" {
855 pass "print funclocal_bss at bar"
856 }
857 -re "$prompt $" {
858 fail "print funclocal_bss at bar" ; return
859 }
860 timeout {
861 fail "(timeout) print funclocal_bss at bar" ; return
862 }
863 }
864
865 send_gdb "print bar::funclocal_bss\n"
866 expect {
867 -re "\\\$$decimal = 104\r\n$prompt $" {
868 pass "print bar::funclocal_bss at bar"
869 }
870 -re "$prompt $" {
871 fail "print bar::funclocal_bss at bar" ; return
872 }
873 timeout {
874 fail "(timeout) print bar::funclocal_bss at bar" ; return
875 }
876 }
877
878 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
879 send_gdb "print 'scope1.c'::bar::funclocal_bss\n"
880 expect {
881 -re "\\\$$decimal = 104\r\n$prompt $" {
882 pass "print 'scope1.c'::bar::funclocal_bss at bar"
883 }
884 -re "No symbol \"scope1.c\" in current context.*$prompt $" {
885 send_gdb "print '$srcdir/$subdir/scope1.c'::bar::funclocal_bss\n"
886 exp_continue
887 }
888 -re "$prompt $" {
889 fail "print 'scope1.c'::bar::funclocal_bss at bar" ; return
890 }
891 timeout {
892 fail "(timeout) print 'scope1.c'::bar::funclocal_bss at bar" ; return
893 }
894 }
895 }
896
897 # This test has little to do with local scopes, but it is in scope.exp anyway.
898 # That's life.
899
900 proc test_at_autovars {} {
901 global prompt
902 global decimal
903 global hex
904 global srcfile
905
906 # Test symbol table lookup with 100 local (auto) variables.
907
908 send_gdb "break marker1\n" ; expect -re ".*$prompt $"
909
910 send_gdb "cont\n"
911 expect {
912 -re "Break.* marker1 \\(\\) at .*:$decimal.*$prompt $" {
913 send_gdb "up\n"
914 expect {
915 -re ".*$prompt $" {}
916 timeout { fail "(timeout) up from marker1" ; return }
917 }
918 }
919 -re "$prompt $" { fail "continue to marker1" ; return }
920 timeout { fail "(timeout) continue to marker1" ; return }
921 }
922
923 set count 0
924 while {$count < 100} {
925 send_gdb "print i$count\n"
926 expect {
927 -re ".* = $count\r\n$prompt $" {}
928 -re "$prompt $" {
929 fail "bad value for auto variable i$count"; return
930 }
931 timeout {
932 fail "(timeout) bad value for auto variable i$count"; return
933 }
934 }
935 set count [expr $count+1]
936 }
937 clear_xfail "*-*-*"
938 pass "$count auto variables correctly initialized"
939
940 # Test that block variable sorting is not screwing us.
941 gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order"
942 }
943
944 proc test_at_localscopes {} {
945 global prompt
946 global decimal
947 global hex
948 global srcfile
949
950 send_gdb "break marker2\n" ; expect -re ".*$prompt $"
951 send_gdb "break marker3\n" ; expect -re ".*$prompt $"
952 send_gdb "break marker4\n" ; expect -re ".*$prompt $"
953
954 send_gdb "cont\n"
955 expect {
956 -re "Break.* marker2 \\(\\) at .*:$decimal.*$prompt $" {
957 send_gdb "up\n"
958 expect {
959 -re ".*$prompt $" {}
960 timeout { fail "(timeout) up from marker2" ; return }
961 }
962 }
963 -re "$prompt $" { fail "continue to marker2" ; return }
964 timeout { fail "(timeout) continue to marker2" ; return }
965 }
966
967 # Should be at first (outermost) scope. Check values.
968
969 gdb_test "print localval" " = 10" "print localval, outer scope"
970 gdb_test "print localval1" " = 11" "print localval1, outer scope"
971 gdb_test "print localval2" "No symbol \"localval2\" in current context." \
972 "print localval2, outer scope"
973 gdb_test "print localval3" "No symbol \"localval3\" in current context." \
974 "print localval3, outer scope"
975
976 if [gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \
977 "continue to marker3 in scope.exp"] then { return }
978 if [gdb_test "up" "" "up from marker3 in scope.exp"] then { return }
979
980 # Should be at next (first nested) scope. Check values.
981
982 gdb_test "print localval" " = 20" \
983 "print localval, first nested scope"
984 gdb_test "print localval1" " = 11" "print localval1, first nested scope"
985 gdb_test "print localval2" " = 12" "print localval2, first nested scope"
986 gdb_test "print localval3" "No symbol \"localval3\" in current context." \
987 "print localval3, first nested scope"
988
989 # This test will only fail if the file was compiled by gcc, but
990 # there's no way to check that.
991 setup_xfail "a29k-*-udi" 2423
992 if [gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \
993 "continue to marker4 in scope.exp"] then { return }
994 if [gdb_test "up" "" "up from marker4 in scope.exp"] then { return }
995
996 gdb_test "print localval" " = 30" "print localval, innermost scope"
997 gdb_test "print localval1" " = 11" "print localval1, innermost scope"
998 gdb_test "print localval2" " = 12" "print localval2, innermost scope"
999 gdb_test "print localval3" " = 13" "print localval3, innermost scope"
1000 }
1001
1002 # Start with a fresh gdb.
1003
1004 gdb_exit
1005 gdb_start
1006 gdb_reinitialize_dir $srcdir/$subdir
1007 gdb_load ${binfile}
1008
1009 if [istarget "*-*-vxworks*"] {
1010 set timeout 120
1011 verbose "Timeout is now $timeout seconds" 2
1012 }
1013
1014 # Test that variables in various segments print out correctly before
1015 # the program is run.
1016
1017 # AIX--sections get mapped to the same address so we can't get the right one.
1018 setup_xfail "rs6000-*-*"
1019 setup_xfail "powerpc-*-*"
1020
1021 gdb_test "print 'scope0.c'::filelocal_ro" "= 201"
1022
1023 # gdb currently cannot access bss memory on some targets if the inferior
1024 # is not running.
1025 #
1026 # For PA boards using monitor/remote-pa.c, the bss test is going to
1027 # randomly fail. We've already put remote-pa on the target stack,
1028 # so we actually read memory from the board. Problem is crt0.o
1029 # is responsible for clearing bss and that hasnt' happened yet.
1030 setup_xfail "hppa*-*-*pro*"
1031 send_gdb "print 'scope0.c'::filelocal_bss\n"
1032 expect {
1033 -re " = 0\r\n$prompt $" {
1034 pass "print 'scope0.c'::filelocal_bss before run"
1035 }
1036 -re "Cannot access memory.*$prompt $" {
1037 setup_xfail "*-*-*"
1038 fail "print 'scope0.c'::filelocal_bss before run"
1039 }
1040 -re ".*$prompt $" {
1041 fail "print 'scope0.c'::filelocal_bss before run"
1042 }
1043 default {
1044 fail "print 'scope0.c'::filelocal_bss before run"
1045 }
1046 }
1047
1048 gdb_test "print 'scope0.c'::filelocal" "= 1" \
1049 "print 'scope0.c'::filelocal before run"
1050
1051 if [runto_main] then { test_at_main }
1052 if [istarget "mips-idt-*"] then {
1053 # Restart because IDT/SIM runs out of file descriptors.
1054 gdb_exit
1055 gdb_start
1056 gdb_reinitialize_dir $srcdir/$subdir
1057 gdb_load ${binfile}
1058 }
1059 if [runto foo] then { test_at_foo }
1060 if [istarget "mips-idt-*"] then {
1061 # Restart because IDT/SIM runs out of file descriptors.
1062 gdb_exit
1063 gdb_start
1064 gdb_reinitialize_dir $srcdir/$subdir
1065 gdb_load ${binfile}
1066 }
1067 if [runto bar] then { test_at_bar }
1068 if [istarget "mips-idt-*"] then {
1069 # Restart because IDT/SIM runs out of file descriptors.
1070 gdb_exit
1071 gdb_start
1072 gdb_reinitialize_dir $srcdir/$subdir
1073 gdb_load ${binfile}
1074 }
1075 if [runto localscopes] then { test_at_localscopes }
1076 if [istarget "mips-idt-*"] then {
1077 # Restart because IDT/SIM runs out of file descriptors.
1078 gdb_exit
1079 gdb_start
1080 gdb_reinitialize_dir $srcdir/$subdir
1081 gdb_load ${binfile}
1082 }
1083 if [runto autovars] then { test_at_autovars }
1084
1085 if [istarget "*-*-vxworks*"] {
1086 set timeout 120
1087 verbose "Timeout is now $timeout seconds" 2
1088 }
This page took 0.053547 seconds and 5 git commands to generate.