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