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