* gdb.base/funcargs.exp: Avoid ever setting more than 8
[external/binutils.git] / gdb / testsuite / gdb.base / funcargs.exp
1 # Copyright (C) 1992, 1994, 1995 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 "funcargs"
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 #
38 # Locate actual args; integral types.
39 #
40
41 proc integral_args {} {
42     global prompt
43     global det_file
44     global gcc_compiled
45
46     delete_breakpoints
47
48     send "break call0a\n" ; expect -re ".*$prompt $"
49     send "break call0b\n" ; expect -re ".*$prompt $"
50     send "break call0c\n" ; expect -re ".*$prompt $"
51     send "break call0d\n" ; expect -re ".*$prompt $"
52     send "break call0e\n" ; expect -re ".*$prompt $"
53
54     # Run; should stop at call0a and print actual arguments.
55     # The a29k fails all of these tests, perhaps because the prologue
56     # code is broken.
57     setup_xfail "a29k-*-udi"
58     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
59     gdb_run_cmd
60     expect {
61         -re ".* call0a \\(c=97 'a', s=1, i=2, l=3\\) .*$prompt $" {
62             pass "run to call0a"
63         }
64         -re "$prompt $"  { fail "run to call0a" ; return }
65         timeout { fail "(timeout) run to call0a" ; return }
66     }
67
68     # Print each arg as a double check to see if we can print
69     # them here as well as with backtrace.
70     gdb_test "print c" ".* = 97 'a'" "print c after run to call0a" 
71     gdb_test "print s" ".* = 1" "print s after run to call0a"
72     gdb_test "print i" ".* = 2" "print i after run to call0a"
73     gdb_test "print l " ".* = 3" "print l after run to call0a"
74
75     # Continue; should stop at call0b and print actual arguments.
76     if [gdb_test "cont" ".* call0b \\(s=1, i=2, l=3, c=97 'a'\\) .*" "continue to call0b"] {
77         return 
78     }
79
80     # Continue; should stop at call0c and print actual arguments.
81     if [gdb_test "cont" ".* call0c \\(i=2, l=3, c=97 'a', s=1\\) .*" "continue to call0c"] {
82         return
83     }
84
85     # Continue; should stop at call0d and print actual arguments.
86     if [gdb_test "cont" ".* call0d \\(l=3, c=97 'a', s=1, i=2\\) .*" "continue to call0d";] {
87         return
88     }
89
90     # Continue; should stop at call0e and print actual arguments.
91     if [gdb_test "cont" ".* call0e \\(c1=97 'a', l=3, c2=97 'a', i=2, c3=97 'a', s=1, c4=97 'a', c5=97 'a'\\) .*" "continue to call0e" ] {
92         return
93     }
94 }
95
96 #
97 # Locate actual args; unsigned integral types.
98 #
99
100 proc unsigned_integral_args {} {
101     global prompt
102     global det_file
103     global gcc_compiled
104
105     delete_breakpoints
106
107     send "break call1a\n" ; expect -re ".*$prompt $"
108     send "break call1b\n" ; expect -re ".*$prompt $"
109     send "break call1c\n" ; expect -re ".*$prompt $"
110     send "break call1d\n" ; expect -re ".*$prompt $"
111     send "break call1e\n" ; expect -re ".*$prompt $"
112
113     # Run; should stop at call1a and print actual arguments.
114     # The a29k fails all of these tests, perhaps because the prologue
115     # code is broken.
116     setup_xfail "a29k-*-udi"
117     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
118     gdb_run_cmd
119     expect {
120         -re ".* call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*$prompt $" {
121             pass "run to call1a"
122         }
123         -re "$prompt $" { fail "run to call1a" ; return }
124         timeout { fail "(timeout) run to call1a" ; return }
125     }
126
127     # Print each arg as a double check to see if we can print
128     # them here as well as with backtrace.
129     gdb_test "print uc" ".* = 98 'b'"
130     gdb_test "print us" ".* = 6"
131     gdb_test "print ui" ".* = 7"
132     gdb_test "print ul" ".* = 8"
133     
134     # Continue; should stop at call1b and print actual arguments.
135     if [gdb_test "cont" ".* call1b \\(us=6, ui=7, ul=8, uc=98 'b'\\) .*" "continue to call1b"] {
136         return 
137     }
138
139     # Continue; should stop at call1c and print actual arguments.
140     if [gdb_test "cont" ".* call1c \\(ui=7, ul=8, uc=98 'b', us=6\\) .*" "continue to call1c"] {
141         return 
142     }
143
144     # Continue; should stop at call1d and print actual arguments.
145     if [gdb_test "cont" ".* call1d \\(ul=8, uc=98 'b', us=6, ui=7\\) .*" "continue to call1d"] {
146         return
147     }
148
149     # Continue; should stop at call1e and print actual arguments.
150     if [gdb_test "cont" ".* call1e \\(uc1=98 'b', ul=8, uc2=98 'b', ui=7, uc3=98 'b', us=6, uc4=98 'b', uc5=98 'b'\\) .*" "continue to call1e"] {
151         return
152     }
153 }
154
155 #
156 # Locate actual args; integrals mixed with floating point.
157 #
158
159 proc float_and_integral_args {} {
160     global prompt
161     global det_file
162     global gcc_compiled
163
164     delete_breakpoints
165
166     send "break call2a\n" ; expect -re ".*$prompt $"
167     send "break call2b\n" ; expect -re ".*$prompt $"
168     send "break call2c\n" ; expect -re ".*$prompt $"
169     send "break call2d\n" ; expect -re ".*$prompt $"
170     send "break call2e\n" ; expect -re ".*$prompt $"
171     send "break call2f\n" ; expect -re ".*$prompt $"
172     send "break call2g\n" ; expect -re ".*$prompt $"
173     send "break call2h\n" ; expect -re ".*$prompt $"
174
175     # Run; should stop at call2a and print actual arguments.
176
177     setup_xfail "i960-*-*" 1813
178     # The a29k fails all of these tests, perhaps because the prologue
179     # code is broken.
180     setup_xfail "a29k-*-udi"
181     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
182     gdb_run_cmd
183     expect {
184         -re ".* call2a \\(c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$prompt $" { pass "run to call2a" }
185         -re "$prompt $" { fail "run to call2a" ; return }
186         timeout { fail "(timeout) run to call2a" ; return }
187     }
188
189     # Print each arg as a double check to see if we can print
190     gdb_test "print c" ".* = 97 'a'" "print c after run to call2a"
191     gdb_test "print f1" ".* = 4" "print f1 after run to call2a"
192     gdb_test "print s" ".* = 1" "print s after run to call2a"
193     gdb_test "print d1" ".* = 5" "print d1 after run to call2a"
194     gdb_test "print i" ".* = 2" "print i after run to call2a"
195     gdb_test "print f2" ".* = 4" "print f2 after run to call2a"
196     gdb_test "print l" ".* = 3" "print l after run to call2a"
197     gdb_test "print d2" ".* = 5" "print d2 after run to call2a"
198
199     setup_xfail "rs6000-*-*"
200     # Continue; should stop at call2b and print actual arguments.
201     if [gdb_test "cont" ".* call2b \\(f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5, c=97 'a'\\) .*" "continue to call2b"] {
202         return
203     }
204
205     # Continue; should stop at call2c and print actual arguments.
206     if [gdb_test "cont" ".* call2c \\(s=1, d1=5, i=2, f2=4, l=3, d2=5, c=97 'a', f1=4\\) .*" "continue to call2c"] {
207         return
208     }
209
210     # Continue; should stop at call2d and print actual arguments.
211     if [gdb_test "cont" ".* call2d \\(d1=5, i=2, f2=4, l=3, d2=5, c=97 'a', f1=4, s=1\\) .*" "continue to call2d"] {
212         return
213     }
214
215     # Continue; should stop at call2e and print actual arguments.
216     if [gdb_test "cont" ".* call2e \\(i=2, f2=4, l=3, d2=5, c=97 'a', f1=4, s=1, d1=5\\) .*" "continue to call2e"] {
217         return
218     }
219
220     # Continue; should stop at call2f and print actual arguments.
221     if [gdb_test "cont" ".* call2f \\(f2=4, l=3, d2=5, c=97 'a', f1=4, s=1, d1=5, i=2\\) .*" "continue to call2f"] {
222         return
223     }
224
225     # Continue; should stop at call2g and print actual arguments.
226     if [gdb_test "cont" ".* call2g \\(l=3, d2=5, c=97 'a', f1=4, s=1, d1=5, i=2, f2=4\\) .*" "continue to call2g"] {
227         return
228     }
229
230     # Continue; should stop at call2h and print actual arguments.
231     if [gdb_test "cont" ".* call2h \\(d2=5, c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3\\) .*" "continue to call2h"] {
232         return
233     }
234
235     # monitor only allows 8 breakpoints; w89k board allows 10, so
236     # break them up into two groups.
237     delete_breakpoints
238     send "break call2i\n" ; expect -re ".*$prompt $"
239
240     # Continue; should stop at call2i and print actual arguments.
241     if [gdb_test "cont" ".* call2i \\(c1=97 'a', f1=4, c2=97 'a', c3=97 'a', d1=5, c4=97 'a', c5=97 'a', c6=97 'a', f2=4, s=1, c7=97 'a', d2=5\\) .*" "continue to call2i"] {
242         return
243     }
244 }
245
246 #
247 # Locate actual args; dereference pointers to ints and floats.
248 #
249
250 proc pointer_args {} {
251     global prompt
252     global hex
253     global det_file
254
255     delete_breakpoints
256
257     send "break call3a\n" ; expect -re ".*$prompt $"
258     send "break call3b\n" ; expect -re ".*$prompt $"
259     send "break call3c\n" ; expect -re ".*$prompt $"
260
261     # Run; should stop at call3a and print actual arguments.
262     # Try dereferencing the arguments.
263
264     # The a29k fails all of these tests, perhaps because the prologue
265     # code is broken.
266     setup_xfail "a29k-*-udi"
267     gdb_run_cmd
268     expect {
269         -re ".* call3a \\(cp=$hex \"a\", sp=$hex, ip=$hex, lp=$hex\\) .*$prompt $" { pass "run to call3a" }
270         -re "$prompt $" { fail "run to call3a" ; return }
271         timeout { fail "(timeout) run to call3a" ; return }
272     }
273
274     gdb_test "print *cp" ".* = 97 'a'"
275     gdb_test "print *sp" ".* = 1"
276     gdb_test "print *ip" ".* = 2"
277     gdb_test "print *lp" ".* = 3"
278
279     # Continue; should stop at call3b and print actual arguments.
280     # Try dereferencing the arguments.
281     if [gdb_test "cont" ".* call3b \\(ucp=$hex \"b\", usp=$hex, uip=$hex, ulp=$hex\\) .*" "continue to call3b"] {
282         return
283     }
284
285     gdb_test "print *ucp" ".* = 98 'b'"
286     gdb_test "print *usp" ".* = 6"
287     gdb_test "print *uip" ".* = 7"
288     gdb_test "print *ulp" ".* = 8"
289
290     # Continue; should stop at call3c and print actual arguments.
291     # Try dereferencing the arguments.
292     if [gdb_test "cont" ".* call3c \\(fp=$hex, dp=$hex\\) .*" "continue to call3c"] {
293         return
294     }
295
296     gdb_test "print *fp" ".* = 4"
297     gdb_test "print *dp" ".* = 5"
298
299     pass "locate actual args, pointer types"
300 }
301
302 #
303 # Locate actual args; structures and unions passed by reference.
304 #
305
306 proc structs_by_reference {} {
307     global prompt
308     global hex
309     global det_file
310
311     delete_breakpoints
312
313     send "break call4a\n" ; expect -re ".*$prompt $"
314     send "break call4b\n" ; expect -re ".*$prompt $"
315
316     # Run; should stop at call4a and print actual arguments.
317     # Try dereferencing the arguments.
318
319     # The a29k fails all of these tests, perhaps because the prologue
320     # code is broken.
321     setup_xfail "a29k-*-udi"
322     gdb_run_cmd
323     expect {
324         -re ".* call4a \\(stp=$hex\\) .*$prompt $" {
325             pass "run to call4a"
326         }
327         -re "$prompt $" { fail "run to call4a" ; return }
328         timeout { fail "(timeout) run to call4a" ; return }
329     }
330
331     gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}"
332
333     # Continue; should stop at call4b and print actual arguments.
334     # Try dereferencing the arguments.
335
336     gdb_test "cont" ".* call4b \\(unp=$hex\\) .*" "continue to call4b"
337
338     gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}"
339
340     pass "locate actual args, structs/unions passed by reference"
341 }
342
343 #
344 # Locate actual args; structures and unions passed by value.
345 #
346
347 proc structs_by_value {} {
348     global prompt
349     global hex
350     global det_file
351
352     delete_breakpoints
353
354     send "break call5a\n" ; expect -re ".*$prompt $"
355     send "break call5b\n" ; expect -re ".*$prompt $"
356
357     # Run; should stop at call5a and print actual arguments.
358     # Try dereferencing the arguments.
359
360     # The a29k fails all of these tests, perhaps because the prologue
361     # code is broken.
362     setup_xfail "a29k-*-udi"
363     gdb_run_cmd
364     expect {
365         -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$prompt $" {
366             pass "run to call5a"
367         }
368         -re "$prompt $" { fail "run to call5a" ; return }
369         timeout { fail "(timeout) run to call5a" ; return }
370     }
371
372     gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}"
373
374     # Continue; should stop at call5b and print actual arguments.
375     # Try dereferencing the arguments.
376     gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \
377         "continue to call5b"
378
379     gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}"
380 }
381
382 #
383 # Locate actual args; discard, shuffle, and call
384 #
385
386 proc discard_and_shuffle {} {
387     global prompt
388     global hex
389     global decimal
390     global det_file
391
392     delete_breakpoints
393
394     send "break call6a\n" ; expect -re ".*$prompt $"
395     send "break call6b\n" ; expect -re ".*$prompt $"
396     send "break call6c\n" ; expect -re ".*$prompt $"
397     send "break call6d\n" ; expect -re ".*$prompt $"
398     send "break call6e\n" ; expect -re ".*$prompt $"
399     send "break call6f\n" ; expect -re ".*$prompt $"
400     send "break call6g\n" ; expect -re ".*$prompt $"
401     send "break call6h\n" ; expect -re ".*$prompt $"
402
403     # Run; should stop at call6a and print actual arguments.
404     # Print backtrace.
405
406     # The a29k fails all of these tests, perhaps because the prologue
407     # code is broken.
408     setup_xfail "a29k-*-udi"
409     gdb_run_cmd
410     expect {
411         -re ".*Breakpoint $decimal, call6a .*$prompt $" { pass "run to call6a" }
412         -re "$prompt $" { fail "run to call6a" ; return }
413         timeout { fail "(timeout) run to call6a" ; return }
414     }
415
416     setup_xfail "rs6000-*-*"
417     send "backtrace 100\n"
418     expect {
419         -re "backtrace 100\[\r\n\]+
420 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
421 .* main \\(.*\\) .*\r
422 $prompt $" { pass "backtrace from call6a" }
423         -re "$prompt $" { fail "backtrace from call6a" ; return }
424         timeout { fail "(timeout) backtrace from call6a" ; return }
425     }
426
427     # Continue; should stop at call6b and print actual arguments.
428     # Print backtrace.
429
430     send "continue\n"
431     expect {
432         -re ".*Breakpoint $decimal, call6b .*$prompt $" { pass "continue to call6b" }
433         -re "$prompt $" { fail "continue to call6b" ; return }
434         timeout { fail "(timeout) continue to call6b" ; return }
435     }
436
437     send "backtrace 100\n"
438     expect {
439         -re "backtrace 100\[\r\n]+
440 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
441 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
442 .* main \\(.*\\) .*\r
443 $prompt $" { pass "backtrace from call6b" }
444         -re "$prompt $" { fail "backtrace from call6b" ; return }
445         timeout { fail "(timeout) backtrace from call6b" ; return }
446     }
447
448     # Continue; should stop at call6c and print actual arguments.
449     # Print backtrace.
450
451     send "continue\n"
452     expect {
453         -re ".*Breakpoint $decimal, call6c .*$prompt $" { pass "continue to call6c" }
454         -re "$prompt $" { fail "continue to call6c" ; return }
455         timeout { fail "(timeout) continue to call6c" ; return }
456     }
457
458     send "backtrace 100\n"
459     expect {
460         -re "backtrace 100\[\r\n\]+
461 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
462 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
463 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
464 .* main \\(.*\\) .*\r
465 $prompt $" { pass "backtrace from call6c" }
466         -re "$prompt $" { fail "backtrace from call6c" ; return }
467         timeout { fail "(timeout) backtrace from call6c" ; return }
468     }
469
470     # Continue; should stop at call6d and print actual arguments.
471     # Print backtrace.
472
473     send "continue\n"
474     expect {
475         -re ".*Breakpoint $decimal, call6d .*$prompt $" { pass "continue to call6d" }
476         -re "$prompt $" { fail "continue to call6d" ; return }
477         timeout { fail "(timeout) continue to call6d" ; return }
478     }
479
480     send "backtrace 100\n"
481     expect {
482         -re "backtrace 100\[\r\n\]+
483 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
484 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
485 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
486 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
487 .* main \\(.*\\) .*\r
488 $prompt $" { pass "backtrace from call6d" }
489         -re "$prompt $" { fail "backtrace from call6d" ; return }
490         timeout { fail "(timeout) backtrace from call6d" ; return }
491     }
492
493     # Continue; should stop at call6e and print actual arguments.
494     # Print backtrace.
495
496     send "continue\n"
497     expect {
498         -re ".*Breakpoint $decimal, call6e .*$prompt $" { pass "continue to call6e" }
499         -re "$prompt $" { fail "continue to call6e" ; return }
500         timeout { fail "(timeout) continue to call6e" ; return }
501     }
502
503     send "backtrace 100\n"
504     expect {
505         -re "backtrace 100\[\r\n\]+
506 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
507 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
508 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
509 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
510 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
511 .* main \\(.*\\) .*\r
512 $prompt $" { pass "backtrace from call6e" }
513         -re "$prompt $" { fail "backtrace from call6e" ; return }
514         timeout { fail "(timeout) backtrace from call6e" ; return }
515     }
516
517     # Continue; should stop at call6f and print actual arguments.
518     # Print backtrace.
519
520     send "continue\n"
521     expect {
522         -re ".*Breakpoint $decimal, call6f .*$prompt $" { pass "continue to call6f" }
523         -re "$prompt $" { fail "continue to call6f" ; return }
524         timeout { fail "(timeout) continue to call6f" ; return }
525     }
526
527     send "backtrace 100\n"
528     expect {
529         -re "backtrace 100\[\r\n\]+
530 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
531 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
532 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
533 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
534 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
535 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
536 .* main \\(.*\\) .*\r
537 $prompt $" { pass "backtrace from call6f" }
538         -re "$prompt $" { fail "backtrace from call6f" ; return }
539         timeout { fail "(timeout) backtrace from call6f" ; return }
540     }
541
542     # Continue; should stop at call6g and print actual arguments.
543     # Print backtrace.
544
545     send "continue\n"
546     expect {
547         -re ".*Breakpoint $decimal, call6g .*$prompt $" { pass "continue to call6g" }
548         -re "$prompt $" { fail "continue to call6g" ; return }
549         timeout { fail "(timeout) continue to call6g" ; return }
550     }
551
552     send "backtrace 100\n"
553     expect {
554         -re "backtrace 100\[\r\n\]+
555 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\r
556 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
557 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
558 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
559 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
560 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
561 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
562 .* main \\(.*\\) .*\r
563 $prompt $" { pass "backtrace from call6g" }
564         -re "$prompt $" { fail "backtrace from call6g" ; return }
565         timeout { fail "(timeout) backtrace from call6g" ; return }
566     }
567
568     # Continue; should stop at call6h and print actual arguments.
569     # Print backtrace.
570
571     send "continue\n"
572     expect {
573         -re ".*Breakpoint $decimal, call6h .*$prompt $" { pass "continue to call6h" }
574         -re "$prompt $" { fail "continue to call6h" ; return }
575         timeout { fail "(timeout) continue to call6h" ; return }
576     }
577
578     send "backtrace 100\n"
579     expect {
580         -re "backtrace 100\[\r\n\]+
581 .* call6h \\(us=6, ui=7, ul=8\\) .*\r
582 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\r
583 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
584 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
585 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
586 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
587 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
588 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
589 .* main \\(.*\\) .*\r
590 $prompt $" { pass "backtrace from call6h" }
591         -re "$prompt $" { fail "backtrace from call6h" ; return }
592         timeout { fail "(timeout) backtrace from call6h" ; return }
593     }
594
595     # monitor only allows 8 breakpoints; w89k board allows 10, so
596     # break them up into two groups.
597     delete_breakpoints
598     send "break call6i\n" ; expect -re ".*$prompt $"
599     send "break call6j\n" ; expect -re ".*$prompt $"
600     send "break call6k\n" ; expect -re ".*$prompt $"
601
602     # Continue; should stop at call6i and print actual arguments.
603     # Print backtrace.
604
605     send "continue\n"
606     expect {
607         -re ".*Breakpoint $decimal, call6i .*$prompt $" { pass "continue to call6i" }
608         -re "$prompt $" { fail "continue to call6i" ; return }
609         timeout { fail "(timeout) continue to call6i" ; return }
610     }
611
612     send "backtrace 100\n"
613     expect {
614         -re "backtrace 100\[\r\n\]+
615 .* call6i \\(ui=7, ul=8\\) .*\r
616 .* call6h \\(us=6, ui=7, ul=8\\) .*\r
617 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\r
618 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
619 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
620 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
621 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
622 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
623 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
624 .* main \\(.*\\) .*\r
625 $prompt $" { pass "backtrace from call6i" }
626         -re "$prompt $" { fail "backtrace from call6i" ; return }
627         timeout { fail "(timeout) backtrace from call6i" ; return }
628     }
629
630     # Continue; should stop at call6j and print actual arguments.
631     # Print backtrace.
632
633     send "continue\n"
634     expect {
635         -re ".*Breakpoint $decimal, call6j .*$prompt $" { pass "continue to call6j" }
636         -re "$prompt $" { fail "continue to call6j" ; return }
637         timeout { fail "(timeout) continue to call6j" ; return }
638     }
639
640     send "backtrace 100\n"
641     expect {
642         -re "backtrace 100\[\r\n\]+
643 .* call6j \\(ul=8\\) .*\r
644 .* call6i \\(ui=7, ul=8\\) .*\r
645 .* call6h \\(us=6, ui=7, ul=8\\) .*\r
646 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\r
647 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
648 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
649 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
650 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
651 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
652 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
653 .* main \\(.*\\) .*\r
654 $prompt $" { pass "backtrace from call6j" }
655         -re "$prompt $" { fail "backtrace from call6j" ; return }
656         timeout { fail "(timeout) backtrace from call6j" ; return }
657     }
658
659     # Continue; should stop at call6k and print actual arguments.
660     # Print backtrace.
661     # This fails on i960-*-vxworks because gdb gets confused by
662     # breakpoints on adjacent instructions.
663     setup_xfail "i960-*-vxworks" 1786
664     send "continue\n"
665     expect {
666         -re ".*Breakpoint $decimal, call6k .*$prompt $" {
667             pass "continue to call6k"
668         }
669         -re "$prompt $" { fail "continue to call6k"; return }
670         timeout { fail "(timeout) continue to call6k"; return }
671     }
672
673     send "backtrace 100\n"
674     expect {
675         -re "backtrace 100\[\r\n\]+
676 .* call6k \\(\\) .*\r
677 .* call6j \\(ul=8\\) .*\r
678 .* call6i \\(ui=7, ul=8\\) .*\r
679 .* call6h \\(us=6, ui=7, ul=8\\) .*\r
680 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\r
681 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
682 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
683 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
684 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
685 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
686 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
687 .* main \\(.*\\) .*\r
688 $prompt $" { pass "backtrace from call6k" }
689         -re "$prompt $" { fail "backtrace from call6k" ; return }
690         timeout { fail "(timeout) backtrace from call6k" ; return }
691     }
692 }
693
694 #
695 # Locate actual args; shuffle round robin and call
696 #
697
698 proc shuffle_round_robin {} {
699     global prompt
700     global hex
701     global decimal
702     global det_file
703     global gcc_compiled
704
705     delete_breakpoints
706
707     send "break call7a\n" ; expect -re ".*$prompt $"
708     send "break call7b\n" ; expect -re ".*$prompt $"
709     send "break call7c\n" ; expect -re ".*$prompt $"
710     send "break call7d\n" ; expect -re ".*$prompt $"
711     send "break call7e\n" ; expect -re ".*$prompt $"
712     send "break call7f\n" ; expect -re ".*$prompt $"
713     send "break call7g\n" ; expect -re ".*$prompt $"
714     send "break call7h\n" ; expect -re ".*$prompt $"
715
716     # Run; should stop at call7a and print actual arguments.
717     # Print backtrace.
718
719     # The a29k fails all of these tests, perhaps because the prologue
720     # code is broken.
721     setup_xfail "a29k-*-udi"
722     gdb_run_cmd
723     expect {
724         -re ".*Breakpoint $decimal, call7a .*$prompt $" {
725             pass "run to call7a"
726         }
727         -re "$prompt $" { fail "run to call7a" ; return }
728         timeout { fail "(timeout) run to call7a" ; return }
729     }
730
731     setup_xfail "i960-*-*" 1813
732     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
733     send "backtrace 100\n"
734     expect {
735         -re "backtrace 100\[\r\n\]+
736 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
737 .* main \\(.*\\) .*\r
738 $prompt $" { pass "backtrace from call7a" }
739         -re "$prompt $" { fail "backtrace from call7a" ; return }
740         timeout { fail "(timeout) backtrace from call7a" ; return }
741     }
742
743     # Continue; should stop at call7b and print actual arguments.
744     # Print backtrace.
745
746     send "continue\n"
747     expect {
748         -re ".*Breakpoint $decimal, call7b .*$prompt $" { pass "continue to call7b" }
749         -re "$prompt $" { fail "continue to call7b" ; return }
750         timeout { fail "(timeout) continue to call7b" ; return }
751     }
752
753     if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
754     send "backtrace 100\n"
755     expect {
756         -re "backtrace 100\[\r\n\]+
757 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
758 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
759 .* main \\(.*\\) .*\r
760 $prompt $" { pass "backtrace from call7b" }
761         -re "$prompt $" { fail "backtrace from call7b" ; return }
762         timeout { fail "(timeout) backtrace from call7b" ; return }
763     }
764
765     # Continue; should stop at call7c and print actual arguments.
766     # Print backtrace.
767
768     send "continue\n"
769     expect {
770         -re ".*Breakpoint $decimal, call7c .*$prompt $" { pass "continue to call7c" }
771         -re "$prompt $" { fail "continue to call7c" ; return }
772         timeout { fail "(timeout) continue to call7c" ; return }
773     }
774
775     send "backtrace 100\n"
776     expect {
777         -re "backtrace 100\[\r\n\]+
778 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
779 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
780 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
781 .* main \\(.*\\) .*\r
782 $prompt $" { pass "backtrace from call7c" }
783         -re "$prompt $" { fail "backtrace from call7c" ; return }
784         timeout { fail "(timeout) backtrace from call7c" ; return }
785     }
786
787     # Continue; should stop at call7d and print actual arguments.
788     # Print backtrace.
789
790     send "continue\n"
791     expect {
792         -re ".*Breakpoint $decimal, call7d .*$prompt $" { pass "continue to call7d" }
793         -re "$prompt $" { fail "continue to call7d" ; return }
794         timeout { fail "(timeout) continue to call7d" ; return }
795     }
796
797     send "backtrace 100\n"
798     expect {
799         -re "backtrace 100\[\r\n\]+
800 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
801 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
802 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
803 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
804 .* main \\(.*\\) .*\r
805 $prompt $" { pass "backtrace from call7d" }
806         -re "$prompt $" { fail "backtrace from call7d" ; return }
807         timeout { fail "(timeout) backtrace from call7d" ; return }
808     }
809
810     # Continue; should stop at call7e and print actual arguments.
811     # Print backtrace.
812
813     send "continue\n"
814     expect {
815         -re "Breakpoint $decimal, call7e .*$prompt $" { pass "continue to call7e" }
816         -re "$prompt $" { fail "continue to call7e" ; return }
817         timeout { fail "(timeout) continue to call7e" ; return }
818     }
819
820     send "backtrace 100\n"
821     expect {
822         -re "backtrace 100\[\r\n\]+
823 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
824 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
825 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
826 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
827 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
828 .* main \\(.*\\) .*\r
829 $prompt $" { pass "backtrace from call7e" }
830         -re "$prompt $" { fail "backtrace from call7e" ; return }
831         timeout { fail "(timeout) backtrace from call7e" ; return }
832     }
833
834     # Continue; should stop at call7f and print actual arguments.
835     # Print backtrace.
836
837     send "continue\n"
838     expect {
839         -re ".*Breakpoint $decimal, call7f .*$prompt $" { pass "continue to call7f" }
840         -re "$prompt $" { fail "continue to call7f" ; return }
841         timeout { fail "(timeout) continue to call7f" ; return }
842     }
843
844     send "backtrace 100\n"
845     expect {
846         -re "backtrace 100\[\r\n\]+
847 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
848 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
849 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
850 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
851 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
852 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
853 .* main \\(.*\\) .*\r
854 $prompt $" { pass "backtrace from call7f" }
855         -re "$prompt $" { fail "backtrace from call7f" ; return }
856         timeout { fail "(timeout) backtrace from call7f" ; return }
857     }
858
859     # Continue; should stop at call7g and print actual arguments.
860     # Print backtrace.
861
862     send "continue\n"
863     expect {
864         -re ".*Breakpoint $decimal, call7g .*$prompt $" { pass "continue to call7g" }
865         -re "$prompt $" { fail "continue to call7g" ; return }
866         timeout { fail "(timeout) continue to call7g" ; return }
867     }
868
869     send "backtrace 100\n"
870     expect {
871         -re "backtrace 100\[\r\n\]+
872 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\r
873 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
874 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
875 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
876 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
877 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
878 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
879 .* main \\(.*\\) .*\r
880 $prompt $" { pass "backtrace from call7g" }
881         -re "$prompt $" { fail "backtrace from call7g" ; return }
882         timeout { fail "(timeout) backtrace from call7g" ; return }
883     }
884
885     # Continue; should stop at call7h and print actual arguments.
886     # Print backtrace.
887
888     send "continue\n"
889     expect {
890         -re ".*Breakpoint $decimal, call7h .*$prompt $" { pass "continue to call7h" }
891         -re "$prompt $" { fail "continue to call7h" ; return }
892         timeout { fail "(timeout) continue to call7h" ; return }
893     }
894
895     send "backtrace 100\n"
896     expect {
897         -re "backtrace 100\[\r\n\]+
898 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\r
899 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\r
900 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
901 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
902 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
903 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
904 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
905 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
906 .* main \\(.*\\) .*\r
907 $prompt $" { pass "backtrace from call7h" }
908         -re "$prompt $" { fail "backtrace from call7h" ; return }
909         timeout { fail "(timeout) backtrace from call7h" ; return }
910     }
911
912     # Continue; should stop at call7i and print actual arguments.
913     # Print backtrace.
914
915     send "continue\n"
916     expect {
917         -re ".*Breakpoint $decimal, call7i .*$prompt $" { pass "continue to call7i" }
918         -re "$prompt $" { fail "continue to call7i" ; return }
919         timeout { fail "(timeout) continue to call7i" ; return }
920     }
921
922     send "backtrace 100\n"
923     expect {
924         -re "backtrace 100\[\r\n\]+
925 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\r
926 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\r
927 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\r
928 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
929 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
930 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
931 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
932 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
933 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
934 .* main \\(.*\\) .*\r
935 $prompt $" { pass "backtrace from call7i" }
936         -re "$prompt $" { fail "backtrace from call7i" ; return }
937         timeout { fail "(timeout) backtrace from call7i" ; return }
938     }
939
940     # monitor only allows 8 breakpoints; w89k board allows 10, so
941     # break them up into two groups.
942     delete_breakpoints
943     send "break call7i\n" ; expect -re ".*$prompt $"
944     send "break call7j\n" ; expect -re ".*$prompt $"
945     send "break call7k\n" ; expect -re ".*$prompt $"
946
947     # Continue; should stop at call7j and print actual arguments.
948     # Print backtrace.
949
950     send "continue\n"
951     expect {
952         -re ".*Breakpoint $decimal, call7j .*$prompt $" { pass "continue to call7j" }
953         -re "$prompt $" { fail "continue to call7j" ; return }
954         timeout { fail "(timeout) continue to call7j" ; return }
955     }
956
957     send "backtrace 100\n"
958     expect {
959         -re "backtrace 100\[\r\n\]+
960 .* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) .*\r
961 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\r
962 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\r
963 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\r
964 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
965 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
966 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
967 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
968 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
969 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
970 .* main \\(.*\\) .*\r
971 $prompt $" { pass "backtrace from call7j" }
972         -re "$prompt $" { fail "backtrace from call7j" ; return }
973         timeout { fail "(timeout) backtrace from call7j" ; return }
974     }
975
976     # Continue; should stop at call7k and print actual arguments.
977     # Print backtrace.
978
979     send "continue\n"
980     expect {
981         -re ".*Breakpoint $decimal, call7k .*$prompt $" { pass "continue to call7k" }
982         -re "$prompt $" { fail "continue to call7k" ; return }
983         timeout { fail "(timeout) continue to call7k" ; return }
984     }
985
986     send "backtrace 100\n"
987     expect {
988         -re "backtrace 100\[\r\n\]+
989 .* call7k \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
990 .* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) .*\r
991 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\r
992 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\r
993 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\r
994 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
995 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
996 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
997 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
998 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
999 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
1000 .* main \\(.*\\) .*\r
1001 $prompt $" { pass "backtrace from call7k" }
1002         -re "$prompt $" { fail "backtrace from call7k" ; return }
1003         timeout { fail "(timeout) backtrace from call7k" ; return }
1004     }
1005 }
1006
1007 #
1008 # Locate actual args; recursive passing of structs by value
1009 #
1010
1011 proc recursive_structs_by_value {} {
1012     global prompt
1013     global hex
1014     global decimal
1015     global det_file
1016
1017     delete_breakpoints
1018
1019     send "break hitbottom\n" ; expect -re ".*$prompt $"
1020
1021     # Run; should stop at hitbottom and print actual arguments.
1022     # Print backtrace.
1023     gdb_run_cmd
1024     expect {
1025         -re ".*Breakpoint $decimal, hitbottom .*$prompt $" { pass "run to hitbottom" }
1026         -re "$prompt $" { fail "run to hitbottom" ; return }
1027         timeout { fail "(timeout) run to hitbottom" ; return }
1028     }
1029
1030     # The a29k fails all of these tests, perhaps because the prologue
1031     # code is broken.
1032     setup_xfail "a29k-*-udi"
1033     send "backtrace 100\n"
1034     expect {
1035         -re "backtrace 100\[\r\n\]+
1036 .* hitbottom \\(\\) .*\r
1037 .* recurse \\(a=\{s = 0, i = 0, l = 0\}, depth=0\\) .*\r
1038 .* recurse \\(a=\{s = 1, i = 1, l = 1\}, depth=1\\) .*\r
1039 .* recurse \\(a=\{s = 2, i = 2, l = 2\}, depth=2\\) .*\r
1040 .* recurse \\(a=\{s = 3, i = 3, l = 3\}, depth=3\\) .*\r
1041 .* recurse \\(a=\{s = 4, i = 4, l = 4\}, depth=4\\) .*\r
1042 .* test_struct_args \\(\\) .*\r
1043 .* main \\(.*\\) .*\r
1044 $prompt $" { pass "recursive passing of structs by value" }
1045         -re "$prompt $" { fail "recursive passing of structs by value" ; return }
1046         timeout { fail "(timeout) recursive passing of structs by value" ; return }
1047     }
1048 }
1049
1050 proc funcargs_reload { } {
1051     global objdir
1052     global subdir
1053     global binfile
1054     global srcdir
1055
1056     if [istarget "mips-idt-*"] then {
1057         # Restart because IDT/SIM runs out of file descriptors.
1058         gdb_exit
1059         gdb_start
1060         gdb_reinitialize_dir $srcdir/$subdir
1061         gdb_load $objdir/$subdir/$binfile
1062     }
1063 }
1064
1065 #
1066 # Test for accessing local stack variables in functions which call alloca
1067 #
1068 proc localvars_after_alloca { } {
1069     global prompt
1070     global hex
1071     global decimal
1072     global gcc_compiled
1073
1074     if { ! [ runto localvars_after_alloca ] } then { return 0 }
1075
1076     # Print each arg as a double check to see if we can print
1077     # them here as well as with backtrace.
1078
1079     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1080     gdb_test "print c" " = 97 'a'" "print c after runto localvars_after_alloca"
1081     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1082     gdb_test "print s" " = 1" "print s after runto localvars_after_alloca"
1083     gdb_test "print i" " = 2" "print i after runto localvars_after_alloca"
1084     gdb_test "print l" " = 3" "print l after runto localvars_after_alloca"
1085
1086     send "next\n"
1087     expect {
1088         -re ".*$prompt $" { pass "next in localvars_after_alloca()" }
1089         timeout { fail "next in localvars_after_alloca()" ; return }
1090     }
1091
1092     # Print each arg as a double check to see if we can print
1093     # them here as well as with backtrace.
1094
1095     gdb_test "print c" " = 97 'a'" "print c in localvars_after_alloca"
1096     gdb_test "print s" " = 1" "print s in localvars_after_alloca"
1097     gdb_test "print i" " = 2" "print i in localvars_after_alloca"
1098     gdb_test "print l" " = 3" "print l in localvars_after_alloca"
1099
1100     gdb_test "backtrace 8" "#0.*localvars_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" "backtrace after alloca"
1101 }
1102
1103 proc call_after_alloca { } {
1104     global prompt
1105     global hex
1106     global decimal
1107     global gcc_compiled
1108
1109     if { ! [ runto call_after_alloca_subr ] } then { return 0 }
1110
1111     # Print each arg as a double check to see if we can print
1112     # them here as well as with backtrace.
1113
1114     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1115     gdb_test "print c" " = 97 'a'" "print c in call_after_alloca"
1116     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1117     gdb_test "print s" " = 1" "print s in call_after_alloca"
1118     gdb_test "print i" " = 2" "print i in call_after_alloca"
1119     gdb_test "print l" " = 3" "print l in call_after_alloca"
1120
1121     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1122     gdb_test "backtrace 8" "#0.*call_after_alloca_subr \\(c=97 'a', s=1, i=2, l=3, uc=98 'b', us=11, ui=12, ul=13\\).*#1.*call_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#2.*main.*" "backtrace from call_after_alloca_subr"
1123 }
1124
1125 #
1126 # Test for accessing local stack variables, backtraces, finish,
1127 # and finally stepping into indirect calls.  The point is that on the PA
1128 # these use a funky `dyncall' mechanism which GDB needs to know about.
1129 #
1130 proc localvars_in_indirect_call { } {
1131     global prompt
1132     global hex
1133     global decimal
1134     global gcc_compiled
1135
1136     # Can not use "runto call0a" as call0a is called several times
1137     # during single run.  Instead stop in a marker function and
1138     # take control from there.
1139     if { ! [ runto marker_indirect_call ] } then { return 0 }
1140
1141     # break on the next call to call0a, then delete all the breakpoints
1142     # and start testing.
1143     gdb_test "break call0a" "Breakpoint .*" \
1144         "break call0a in localvars_in_indirect_call"
1145     gdb_test "continue" "call0a .*" "continue in localvars_in_indirect_call"
1146     delete_breakpoints
1147     
1148     # Print each arg as a double check to see if we can print
1149     # them here as well as with backtrace.
1150
1151     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1152     gdb_test "print c" " = 97 'a'" "print c in localvars_in_indirect_call"
1153     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1154     gdb_test "print s" " = 1" "print s in localvars_in_indirect_call"
1155     gdb_test "print i" " = 2" "print i in localvars_in_indirect_call"
1156     gdb_test "print l" " = 3" "print l in localvars_in_indirect_call"
1157
1158     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1159     gdb_test "backtrace 8" \
1160         "#0.*call0a \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" \
1161         "backtrace in indirectly called function"
1162
1163     # 
1164     # "finish" brings us back to main.  We then will try to step through
1165     # the second indirect call.  
1166     # On some targets (e.g. m68k) gdb will stop from the finish in midline
1167     # of the first indirect call. This is due to stack adjustment instructions
1168     # after the indirect call. In these cases we will step till we hit the
1169     # second indirect call.
1170     #
1171
1172     send "finish\n"
1173     expect {
1174         -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$prompt $" {
1175             send "step\n"
1176             exp_continue
1177         }
1178         -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$prompt $" {
1179             pass "finish from indirectly called function"
1180         }
1181         -re ".*$prompt $" {
1182             fail "finish from indirectly called function"
1183             return
1184         }
1185         default { fail "finish from indirectly called function" ; return }
1186     }
1187
1188     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1189     gdb_test "step" "call0a \\(c=97 'a', s=1, i=2, l=3\\).*" \
1190         "stepping into indirectly called function"
1191 }
1192
1193 # Start with a fresh gdb.
1194 #
1195 # Test for stepping into indirect calls which may have trampolines (possibly
1196 # cascaded) on both the call path and the return path.
1197 # to handle trampolines.
1198 #
1199 proc test_stepping_over_trampolines { } {
1200     global prompt
1201     global hex
1202     global decimal
1203
1204     # Stop in a marker function and take control from there.
1205     if { ! [ runto marker_call_with_trampolines ] } then { return 0 }
1206
1207     # Cater for gdb stopping in midline, see comment for finish above.
1208     send "finish\n"
1209     expect {
1210         -re "marker_call_with_trampolines ..;.*$prompt $" {
1211             send "step\n"
1212             exp_continue
1213         }
1214         -re "pointer_to_call_with_trampolines.*$prompt $" {
1215             pass "finish from marker_call_with_trampolines"
1216         }
1217         -re ".*$prompt $" {
1218             fail "finish from marker_call_with_trampolines"
1219         }
1220         default { fail "finish from marker_call_with_trampolines" ; return 0 }
1221     }
1222
1223     # Try to step into the target function.
1224     gdb_test "step" "call_with_trampolines \\(d1=5\\).*" \
1225         "stepping into function called with trampolines"
1226
1227     # Make we can backtrace and the argument looks correct.  */
1228     gdb_test "backtrace 8" "#0.*call_with_trampolines \\(d1=5\\).*1.*main.*" \
1229         "backtrace through call with trampolines"
1230
1231     # Make sure we can get back to main.
1232     # Stepping back to main might stop again after the return statement
1233     # or immediately transfer control back to main if optimizations
1234     # are performed.
1235     send "step\n"
1236     expect {
1237         -re "main .* at.*$prompt $" {
1238             pass "stepping back to main from function called with trampolines" ;
1239             return 1
1240         }
1241         -re "\}.*End of call_with_trampolines.*$prompt $" {
1242             send "step\n"
1243             exp_continue
1244         }
1245         -re ".*$prompt $" {
1246             fail "stepping back to main from function called with trampolines"
1247         }
1248         default { fail "stepping back to main from function called with trampolines" ; return 0 }
1249     }
1250 }
1251
1252 # Start with a fresh gdb.
1253
1254 gdb_exit
1255 gdb_start
1256 gdb_reinitialize_dir $srcdir/$subdir
1257 gdb_load $objdir/$subdir/$binfile
1258
1259 source gdb.base/funcargs.ci
1260
1261 integral_args
1262 funcargs_reload
1263 unsigned_integral_args
1264 funcargs_reload
1265 float_and_integral_args
1266 funcargs_reload
1267 pointer_args
1268 funcargs_reload
1269 structs_by_reference
1270 funcargs_reload
1271 structs_by_value
1272 funcargs_reload
1273 discard_and_shuffle
1274 funcargs_reload
1275 shuffle_round_robin
1276 funcargs_reload
1277 recursive_structs_by_value
1278 funcargs_reload
1279 localvars_after_alloca
1280 funcargs_reload
1281 call_after_alloca
1282 funcargs_reload
1283 localvars_in_indirect_call
1284 funcargs_reload
1285 test_stepping_over_trampolines