* gdb.base/Makefile.in: Add action to .c.o transformation
[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     send "break call2i\n" ; expect -re ".*$prompt $"
175
176     # Run; should stop at call2a and print actual arguments.
177
178     setup_xfail "i960-*-*" 1813
179     # The a29k fails all of these tests, perhaps because the prologue
180     # code is broken.
181     setup_xfail "a29k-*-udi"
182     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
183     gdb_run_cmd
184     expect {
185         -re ".* call2a \\(c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$prompt $" { pass "run to call2a" }
186         -re "$prompt $" { fail "run to call2a" ; return }
187         timeout { fail "(timeout) run to call2a" ; return }
188     }
189
190     # Print each arg as a double check to see if we can print
191     gdb_test "print c" ".* = 97 'a'" "print c after run to call2a"
192     if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
193     gdb_test "print fl" ".* = 4" "print f1 after run to call2a"
194     gdb_test "print s" ".* = 1" "print s after run to call2a"
195     gdb_test "print d1" ".* = 5" "print d1 after run to call2a"
196     gdb_test "print i" ".* = 2" "print i after run to call2a"
197     gdb_test "print f2" ".* = 4" "print f2 after run to call2a"
198     gdb_test "print l" ".* = 3" "print l after run to call2a"
199     gdb_test "print d2" ".* = 5" "print d2 after run to call2a"
200
201     setup_xfail "rs6000-*-*"
202     # Continue; should stop at call2b and print actual arguments.
203     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"] {
204         return
205     }
206
207     # Continue; should stop at call2c and print actual arguments.
208     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"] {
209         return
210     }
211
212     # Continue; should stop at call2d and print actual arguments.
213     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"] {
214         return
215     }
216
217     # Continue; should stop at call2e and print actual arguments.
218     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"] {
219         return
220     }
221
222     # Continue; should stop at call2f and print actual arguments.
223     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"] {
224         return
225     }
226
227     # Continue; should stop at call2g and print actual arguments.
228     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"] {
229         return
230     }
231
232     # Continue; should stop at call2h and print actual arguments.
233     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"] {
234         return
235     }
236
237     # Continue; should stop at call2i and print actual arguments.
238     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"] {
239         return
240     }
241 }
242
243 #
244 # Locate actual args; dereference pointers to ints and floats.
245 #
246
247 proc pointer_args {} {
248     global prompt
249     global hex
250     global det_file
251
252     delete_breakpoints
253
254     send "break call3a\n" ; expect -re ".*$prompt $"
255     send "break call3b\n" ; expect -re ".*$prompt $"
256     send "break call3c\n" ; expect -re ".*$prompt $"
257
258     # Run; should stop at call3a and print actual arguments.
259     # Try dereferencing the arguments.
260
261     # The a29k fails all of these tests, perhaps because the prologue
262     # code is broken.
263     setup_xfail "a29k-*-udi"
264     gdb_run_cmd
265     expect {
266         -re ".* call3a \\(cp=$hex \"a\", sp=$hex, ip=$hex, lp=$hex\\) .*$prompt $" { pass "run to call3a" }
267         -re "$prompt $" { fail "run to call3a" ; return }
268         timeout { fail "(timeout) run to call3a" ; return }
269     }
270
271     gdb_test "print *cp" ".* = 97 'a'"
272     gdb_test "print *sp" ".* = 1"
273     gdb_test "print *ip" ".* = 2"
274     gdb_test "print *lp" ".* = 3"
275
276     # Continue; should stop at call3b and print actual arguments.
277     # Try dereferencing the arguments.
278     if [gdb_test "cont" ".* call3b \\(ucp=$hex \"b\", usp=$hex, uip=$hex, ulp=$hex\\) .*" "continue to call3b"] {
279         return
280     }
281
282     gdb_test "print *ucp" ".* = 98 'b'"
283     gdb_test "print *usp" ".* = 6"
284     gdb_test "print *uip" ".* = 7"
285     gdb_test "print *ulp" ".* = 8"
286
287     # Continue; should stop at call3c and print actual arguments.
288     # Try dereferencing the arguments.
289     if [gdb_test "cont" ".* call3c \\(fp=$hex, dp=$hex\\) .*" "continue to call3c"] {
290         return
291     }
292
293     gdb_test "print *fp" ".* = 4"
294     gdb_test "print *dp" ".* = 5"
295
296     pass "locate actual args, pointer types"
297 }
298
299 #
300 # Locate actual args; structures and unions passed by reference.
301 #
302
303 proc structs_by_reference {} {
304     global prompt
305     global hex
306     global det_file
307
308     delete_breakpoints
309
310     send "break call4a\n" ; expect -re ".*$prompt $"
311     send "break call4b\n" ; expect -re ".*$prompt $"
312
313     # Run; should stop at call4a and print actual arguments.
314     # Try dereferencing the arguments.
315
316     # The a29k fails all of these tests, perhaps because the prologue
317     # code is broken.
318     setup_xfail "a29k-*-udi"
319     gdb_run_cmd
320     expect {
321         -re ".* call4a \\(stp=$hex\\) .*$prompt $" {
322             pass "run to call4a"
323         }
324         -re "$prompt $" { fail "run to call4a" ; return }
325         timeout { fail "(timeout) run to call4a" ; return }
326     }
327
328     gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}"
329
330     # Continue; should stop at call4b and print actual arguments.
331     # Try dereferencing the arguments.
332
333     gdb_test "cont" ".* call4b \\(unp=$hex\\) .*" "continue to call4b"
334
335     gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}"
336
337     pass "locate actual args, structs/unions passed by reference"
338 }
339
340 #
341 # Locate actual args; structures and unions passed by value.
342 #
343
344 proc structs_by_value {} {
345     global prompt
346     global hex
347     global det_file
348
349     delete_breakpoints
350
351     send "break call5a\n" ; expect -re ".*$prompt $"
352     send "break call5b\n" ; expect -re ".*$prompt $"
353
354     # Run; should stop at call5a and print actual arguments.
355     # Try dereferencing the arguments.
356
357     # The a29k fails all of these tests, perhaps because the prologue
358     # code is broken.
359     setup_xfail "a29k-*-udi"
360     gdb_run_cmd
361     expect {
362         -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$prompt $" {
363             pass "run to call5a"
364         }
365         -re "$prompt $" { fail "run to call5a" ; return }
366         timeout { fail "(timeout) run to call5a" ; return }
367     }
368
369     gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}"
370
371     # Continue; should stop at call5b and print actual arguments.
372     # Try dereferencing the arguments.
373     gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \
374         "continue to call5b"
375
376     gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}"
377 }
378
379 #
380 # Locate actual args; discard, shuffle, and call
381 #
382
383 proc discard_and_shuffle {} {
384     global prompt
385     global hex
386     global decimal
387     global det_file
388
389     delete_breakpoints
390
391     send "break call6a\n" ; expect -re ".*$prompt $"
392     send "break call6b\n" ; expect -re ".*$prompt $"
393     send "break call6c\n" ; expect -re ".*$prompt $"
394     send "break call6d\n" ; expect -re ".*$prompt $"
395     send "break call6e\n" ; expect -re ".*$prompt $"
396     send "break call6f\n" ; expect -re ".*$prompt $"
397     send "break call6g\n" ; expect -re ".*$prompt $"
398     send "break call6h\n" ; expect -re ".*$prompt $"
399     send "break call6i\n" ; expect -re ".*$prompt $"
400     send "break call6j\n" ; expect -re ".*$prompt $"
401     send "break call6k\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     # Continue; should stop at call6i and print actual arguments.
596     # Print backtrace.
597
598     send "continue\n"
599     expect {
600         -re ".*Breakpoint $decimal, call6i .*$prompt $" { pass "continue to call6i" }
601         -re "$prompt $" { fail "continue to call6i" ; return }
602         timeout { fail "(timeout) continue to call6i" ; return }
603     }
604
605     send "backtrace 100\n"
606     expect {
607         -re "backtrace 100\[\r\n\]+
608 .* call6i \\(ui=7, ul=8\\) .*\r
609 .* call6h \\(us=6, ui=7, ul=8\\) .*\r
610 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\r
611 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
612 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
613 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
614 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
615 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
616 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
617 .* main \\(.*\\) .*\r
618 $prompt $" { pass "backtrace from call6i" }
619         -re "$prompt $" { fail "backtrace from call6i" ; return }
620         timeout { fail "(timeout) backtrace from call6i" ; return }
621     }
622
623     # Continue; should stop at call6j and print actual arguments.
624     # Print backtrace.
625
626     send "continue\n"
627     expect {
628         -re ".*Breakpoint $decimal, call6j .*$prompt $" { pass "continue to call6j" }
629         -re "$prompt $" { fail "continue to call6j" ; return }
630         timeout { fail "(timeout) continue to call6j" ; return }
631     }
632
633     send "backtrace 100\n"
634     expect {
635         -re "backtrace 100\[\r\n\]+
636 .* call6j \\(ul=8\\) .*\r
637 .* call6i \\(ui=7, ul=8\\) .*\r
638 .* call6h \\(us=6, ui=7, ul=8\\) .*\r
639 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\r
640 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
641 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
642 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
643 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
644 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
645 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
646 .* main \\(.*\\) .*\r
647 $prompt $" { pass "backtrace from call6j" }
648         -re "$prompt $" { fail "backtrace from call6j" ; return }
649         timeout { fail "(timeout) backtrace from call6j" ; return }
650     }
651
652     # Continue; should stop at call6k and print actual arguments.
653     # Print backtrace.
654     # This fails on i960-*-vxworks because gdb gets confused by
655     # breakpoints on adjacent instructions.
656     setup_xfail "i960-*-vxworks" 1786
657     send "continue\n"
658     expect {
659         -re ".*Breakpoint $decimal, call6k .*$prompt $" {
660             pass "continue to call6k"
661         }
662         -re "$prompt $" { fail "continue to call6k"; return }
663         timeout { fail "(timeout) continue to call6k"; return }
664     }
665
666     send "backtrace 100\n"
667     expect {
668         -re "backtrace 100\[\r\n\]+
669 .* call6k \\(\\) .*\r
670 .* call6j \\(ul=8\\) .*\r
671 .* call6i \\(ui=7, ul=8\\) .*\r
672 .* call6h \\(us=6, ui=7, ul=8\\) .*\r
673 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\r
674 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
675 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
676 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
677 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
678 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
679 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r
680 .* main \\(.*\\) .*\r
681 $prompt $" { pass "backtrace from call6k" }
682         -re "$prompt $" { fail "backtrace from call6k" ; return }
683         timeout { fail "(timeout) backtrace from call6k" ; return }
684     }
685 }
686
687 #
688 # Locate actual args; shuffle round robin and call
689 #
690
691 proc shuffle_round_robin {} {
692     global prompt
693     global hex
694     global decimal
695     global det_file
696     global gcc_compiled
697
698     delete_breakpoints
699
700     send "break call7a\n" ; expect -re ".*$prompt $"
701     send "break call7b\n" ; expect -re ".*$prompt $"
702     send "break call7c\n" ; expect -re ".*$prompt $"
703     send "break call7d\n" ; expect -re ".*$prompt $"
704     send "break call7e\n" ; expect -re ".*$prompt $"
705     send "break call7f\n" ; expect -re ".*$prompt $"
706     send "break call7g\n" ; expect -re ".*$prompt $"
707     send "break call7h\n" ; expect -re ".*$prompt $"
708     send "break call7i\n" ; expect -re ".*$prompt $"
709     send "break call7j\n" ; expect -re ".*$prompt $"
710     send "break call7k\n" ; expect -re ".*$prompt $"
711
712     # Run; should stop at call7a and print actual arguments.
713     # Print backtrace.
714
715     # The a29k fails all of these tests, perhaps because the prologue
716     # code is broken.
717     setup_xfail "a29k-*-udi"
718     gdb_run_cmd
719     expect {
720         -re ".*Breakpoint $decimal, call7a .*$prompt $" {
721             pass "run to call7a"
722         }
723         -re "$prompt $" { fail "run to call7a" ; return }
724         timeout { fail "(timeout) run to call7a" ; return }
725     }
726
727     setup_xfail "i960-*-*" 1813
728     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
729     send "backtrace 100\n"
730     expect {
731         -re "backtrace 100\[\r\n\]+
732 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
733 .* main \\(.*\\) .*\r
734 $prompt $" { pass "backtrace from call7a" }
735         -re "$prompt $" { fail "backtrace from call7a" ; return }
736         timeout { fail "(timeout) backtrace from call7a" ; return }
737     }
738
739     # Continue; should stop at call7b and print actual arguments.
740     # Print backtrace.
741
742     send "continue\n"
743     expect {
744         -re ".*Breakpoint $decimal, call7b .*$prompt $" { pass "continue to call7b" }
745         -re "$prompt $" { fail "continue to call7b" ; return }
746         timeout { fail "(timeout) continue to call7b" ; return }
747     }
748
749     if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
750     send "backtrace 100\n"
751     expect {
752         -re "backtrace 100\[\r\n\]+
753 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
754 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
755 .* main \\(.*\\) .*\r
756 $prompt $" { pass "backtrace from call7b" }
757         -re "$prompt $" { fail "backtrace from call7b" ; return }
758         timeout { fail "(timeout) backtrace from call7b" ; return }
759     }
760
761     # Continue; should stop at call7c and print actual arguments.
762     # Print backtrace.
763
764     send "continue\n"
765     expect {
766         -re ".*Breakpoint $decimal, call7c .*$prompt $" { pass "continue to call7c" }
767         -re "$prompt $" { fail "continue to call7c" ; return }
768         timeout { fail "(timeout) continue to call7c" ; return }
769     }
770
771     send "backtrace 100\n"
772     expect {
773         -re "backtrace 100\[\r\n\]+
774 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
775 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
776 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
777 .* main \\(.*\\) .*\r
778 $prompt $" { pass "backtrace from call7c" }
779         -re "$prompt $" { fail "backtrace from call7c" ; return }
780         timeout { fail "(timeout) backtrace from call7c" ; return }
781     }
782
783     # Continue; should stop at call7d and print actual arguments.
784     # Print backtrace.
785
786     send "continue\n"
787     expect {
788         -re ".*Breakpoint $decimal, call7d .*$prompt $" { pass "continue to call7d" }
789         -re "$prompt $" { fail "continue to call7d" ; return }
790         timeout { fail "(timeout) continue to call7d" ; return }
791     }
792
793     send "backtrace 100\n"
794     expect {
795         -re "backtrace 100\[\r\n\]+
796 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
797 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
798 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
799 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
800 .* main \\(.*\\) .*\r
801 $prompt $" { pass "backtrace from call7d" }
802         -re "$prompt $" { fail "backtrace from call7d" ; return }
803         timeout { fail "(timeout) backtrace from call7d" ; return }
804     }
805
806     # Continue; should stop at call7e and print actual arguments.
807     # Print backtrace.
808
809     send "continue\n"
810     expect {
811         -re "Breakpoint $decimal, call7e .*$prompt $" { pass "continue to call7e" }
812         -re "$prompt $" { fail "continue to call7e" ; return }
813         timeout { fail "(timeout) continue to call7e" ; return }
814     }
815
816     send "backtrace 100\n"
817     expect {
818         -re "backtrace 100\[\r\n\]+
819 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
820 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
821 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
822 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
823 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
824 .* main \\(.*\\) .*\r
825 $prompt $" { pass "backtrace from call7e" }
826         -re "$prompt $" { fail "backtrace from call7e" ; return }
827         timeout { fail "(timeout) backtrace from call7e" ; return }
828     }
829
830     # Continue; should stop at call7f and print actual arguments.
831     # Print backtrace.
832
833     send "continue\n"
834     expect {
835         -re ".*Breakpoint $decimal, call7f .*$prompt $" { pass "continue to call7f" }
836         -re "$prompt $" { fail "continue to call7f" ; return }
837         timeout { fail "(timeout) continue to call7f" ; return }
838     }
839
840     send "backtrace 100\n"
841     expect {
842         -re "backtrace 100\[\r\n\]+
843 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
844 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
845 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
846 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
847 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
848 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
849 .* main \\(.*\\) .*\r
850 $prompt $" { pass "backtrace from call7f" }
851         -re "$prompt $" { fail "backtrace from call7f" ; return }
852         timeout { fail "(timeout) backtrace from call7f" ; return }
853     }
854
855     # Continue; should stop at call7g and print actual arguments.
856     # Print backtrace.
857
858     send "continue\n"
859     expect {
860         -re ".*Breakpoint $decimal, call7g .*$prompt $" { pass "continue to call7g" }
861         -re "$prompt $" { fail "continue to call7g" ; return }
862         timeout { fail "(timeout) continue to call7g" ; return }
863     }
864
865     send "backtrace 100\n"
866     expect {
867         -re "backtrace 100\[\r\n\]+
868 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\r
869 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
870 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
871 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
872 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
873 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
874 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
875 .* main \\(.*\\) .*\r
876 $prompt $" { pass "backtrace from call7g" }
877         -re "$prompt $" { fail "backtrace from call7g" ; return }
878         timeout { fail "(timeout) backtrace from call7g" ; return }
879     }
880
881     # Continue; should stop at call7h and print actual arguments.
882     # Print backtrace.
883
884     send "continue\n"
885     expect {
886         -re ".*Breakpoint $decimal, call7h .*$prompt $" { pass "continue to call7h" }
887         -re "$prompt $" { fail "continue to call7h" ; return }
888         timeout { fail "(timeout) continue to call7h" ; return }
889     }
890
891     send "backtrace 100\n"
892     expect {
893         -re "backtrace 100\[\r\n\]+
894 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\r
895 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\r
896 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
897 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
898 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
899 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
900 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
901 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
902 .* main \\(.*\\) .*\r
903 $prompt $" { pass "backtrace from call7h" }
904         -re "$prompt $" { fail "backtrace from call7h" ; return }
905         timeout { fail "(timeout) backtrace from call7h" ; return }
906     }
907
908     # Continue; should stop at call7i and print actual arguments.
909     # Print backtrace.
910
911     send "continue\n"
912     expect {
913         -re ".*Breakpoint $decimal, call7i .*$prompt $" { pass "continue to call7i" }
914         -re "$prompt $" { fail "continue to call7i" ; return }
915         timeout { fail "(timeout) continue to call7i" ; return }
916     }
917
918     send "backtrace 100\n"
919     expect {
920         -re "backtrace 100\[\r\n\]+
921 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\r
922 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\r
923 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\r
924 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
925 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
926 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
927 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
928 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
929 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
930 .* main \\(.*\\) .*\r
931 $prompt $" { pass "backtrace from call7i" }
932         -re "$prompt $" { fail "backtrace from call7i" ; return }
933         timeout { fail "(timeout) backtrace from call7i" ; return }
934     }
935
936     # Continue; should stop at call7j and print actual arguments.
937     # Print backtrace.
938
939     send "continue\n"
940     expect {
941         -re ".*Breakpoint $decimal, call7j .*$prompt $" { pass "continue to call7j" }
942         -re "$prompt $" { fail "continue to call7j" ; return }
943         timeout { fail "(timeout) continue to call7j" ; return }
944     }
945
946     send "backtrace 100\n"
947     expect {
948         -re "backtrace 100\[\r\n\]+
949 .* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) .*\r
950 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\r
951 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\r
952 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\r
953 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
954 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
955 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
956 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
957 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
958 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
959 .* main \\(.*\\) .*\r
960 $prompt $" { pass "backtrace from call7j" }
961         -re "$prompt $" { fail "backtrace from call7j" ; return }
962         timeout { fail "(timeout) backtrace from call7j" ; return }
963     }
964
965     # Continue; should stop at call7k and print actual arguments.
966     # Print backtrace.
967
968     send "continue\n"
969     expect {
970         -re ".*Breakpoint $decimal, call7k .*$prompt $" { pass "continue to call7k" }
971         -re "$prompt $" { fail "continue to call7k" ; return }
972         timeout { fail "(timeout) continue to call7k" ; return }
973     }
974
975     send "backtrace 100\n"
976     expect {
977         -re "backtrace 100\[\r\n\]+
978 .* call7k \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
979 .* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) .*\r
980 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\r
981 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\r
982 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\r
983 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\r
984 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\r
985 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\r
986 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\r
987 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\r
988 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\r
989 .* main \\(.*\\) .*\r
990 $prompt $" { pass "backtrace from call7k" }
991         -re "$prompt $" { fail "backtrace from call7k" ; return }
992         timeout { fail "(timeout) backtrace from call7k" ; return }
993     }
994 }
995
996 #
997 # Locate actual args; recursive passing of structs by value
998 #
999
1000 proc recursive_structs_by_value {} {
1001     global prompt
1002     global hex
1003     global decimal
1004     global det_file
1005
1006     delete_breakpoints
1007
1008     send "break hitbottom\n" ; expect -re ".*$prompt $"
1009
1010     # Run; should stop at hitbottom and print actual arguments.
1011     # Print backtrace.
1012     gdb_run_cmd
1013     expect {
1014         -re ".*Breakpoint $decimal, hitbottom .*$prompt $" { pass "run to hitbottom" }
1015         -re "$prompt $" { fail "run to hitbottom" ; return }
1016         timeout { fail "(timeout) run to hitbottom" ; return }
1017     }
1018
1019     # The a29k fails all of these tests, perhaps because the prologue
1020     # code is broken.
1021     setup_xfail "a29k-*-udi"
1022     send "backtrace 100\n"
1023     expect {
1024         -re "backtrace 100\[\r\n\]+
1025 .* hitbottom \\(\\) .*\r
1026 .* recurse \\(a=\{s = 0, i = 0, l = 0\}, depth=0\\) .*\r
1027 .* recurse \\(a=\{s = 1, i = 1, l = 1\}, depth=1\\) .*\r
1028 .* recurse \\(a=\{s = 2, i = 2, l = 2\}, depth=2\\) .*\r
1029 .* recurse \\(a=\{s = 3, i = 3, l = 3\}, depth=3\\) .*\r
1030 .* recurse \\(a=\{s = 4, i = 4, l = 4\}, depth=4\\) .*\r
1031 .* test_struct_args \\(\\) .*\r
1032 .* main \\(.*\\) .*\r
1033 $prompt $" { pass "recursive passing of structs by value" }
1034         -re "$prompt $" { fail "recursive passing of structs by value" ; return }
1035         timeout { fail "(timeout) recursive passing of structs by value" ; return }
1036     }
1037 }
1038
1039 proc funcargs_reload { } {
1040     global objdir
1041     global subdir
1042     global binfile
1043     global srcdir
1044
1045     if [istarget "mips-idt-*"] then {
1046         # Restart because IDT/SIM runs out of file descriptors.
1047         gdb_exit
1048         gdb_start
1049         gdb_reinitialize_dir $srcdir/$subdir
1050         gdb_load $objdir/$subdir/$binfile
1051     }
1052 }
1053
1054 #
1055 # Test for accessing local stack variables in functions which call alloca
1056 #
1057 proc localvars_after_alloca { } {
1058     global prompt
1059     global hex
1060     global decimal
1061
1062     if { ! [ runto localvars_after_alloca ] } then { return 0 }
1063
1064     # Print each arg as a double check to see if we can print
1065     # them here as well as with backtrace.
1066
1067     setup_xfail "rs6000-*-*"
1068     gdb_test "print c after runto localvars_after_alloca" " = 97 'a'"
1069     setup_xfail "rs6000-*-*"
1070     gdb_test "print s after runto localvars_after_alloca" " = 1"
1071     setup_xfail "rs6000-*-*"
1072     gdb_test "print i after runto localvars_after_alloca" " = 2"
1073     setup_xfail "rs6000-*-*"
1074     gdb_test "print l after runto localvars_after_alloca" " = 3"
1075
1076     send "next\n"
1077     expect {
1078         -re ".*$prompt $" { pass "next in localvars_after_alloca()" }
1079         timeout { fail "next in localvars_after_alloca()" ; return }
1080     }
1081
1082     # Print each arg as a double check to see if we can print
1083     # them here as well as with backtrace.
1084
1085     gdb_test "print c" " = 97 'a'" "print c in localvars_after_alloca"
1086     gdb_test "print s" " = 1" "print s in localvars_after_alloca"
1087     gdb_test "print i" " = 2" "print i in localvars_after_alloca"
1088     gdb_test "print l" " = 3" "print l in localvars_after_alloca"
1089
1090     gdb_test "backtrace 8" "#0.*localvars_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" "backtrace after alloca"
1091 }
1092
1093 proc call_after_alloca { } {
1094     global prompt
1095     global hex
1096     global decimal
1097     global gcc_compiled
1098
1099     if { ! [ runto call_after_alloca_subr ] } then { return 0 }
1100
1101     # Print each arg as a double check to see if we can print
1102     # them here as well as with backtrace.
1103
1104     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1105     gdb_test "print c" " = 97 'a'" "print c in call_after_alloca"
1106     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1107     gdb_test "print s" " = 1" "print s in call_after_alloca"
1108     gdb_test "print i" " = 2" "print i in call_after_alloca"
1109     gdb_test "print l" " = 3" "print l in call_after_alloca"
1110
1111     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1112     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"
1113 }
1114
1115 #
1116 # Test for accessing local stack variables, backtraces, finish,
1117 # and finally stepping into indirect calls.  The point is that on the PA
1118 # these use a funky `dyncall' mechanism which GDB needs to know about.
1119 #
1120 proc localvars_in_indirect_call { } {
1121     global prompt
1122     global hex
1123     global decimal
1124     global gcc_compiled
1125
1126     # Can not use "runto call0a" as call0a is called several times
1127     # during single run.  Instead stop in a marker function and
1128     # take control from there.
1129     if { ! [ runto marker_indirect_call ] } then { return 0 }
1130
1131     # break on the next call to call0a, then delete all the breakpoints
1132     # and start testing.
1133     gdb_test "break call0a" "Breakpoint .*" \
1134         "break call0a in localvars_in_indirect_call"
1135     gdb_test "continue" "call0a .*" "continue in localvars_in_indirect_call"
1136     delete_breakpoints
1137     
1138     # Print each arg as a double check to see if we can print
1139     # them here as well as with backtrace.
1140
1141     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1142     gdb_test "print c" " = 97 'a'" "print c in localvars_in_indirect_call"
1143     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1144     gdb_test "print s" " = 1" "print s in localvars_in_indirect_call"
1145     gdb_test "print i" " = 2" "print i in localvars_in_indirect_call"
1146     gdb_test "print l" " = 3" "print l in localvars_in_indirect_call"
1147
1148     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1149     gdb_test "backtrace 8" \
1150         "#0.*call0a \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" \
1151         "backtrace in indirectly called function"
1152
1153     # 
1154     # "finish" brings us back to main.  We then will try to step through
1155     # the second indirect call.  
1156     # On some targets (e.g. m68k) gdb will stop from the finish in midline
1157     # of the first indirect call. This is due to stack adjustment instructions
1158     # after the indirect call. In these cases we will step till we hit the
1159     # second indirect call.
1160     #
1161
1162     send "finish\n"
1163     expect {
1164         -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$prompt $" {
1165             send "step\n"
1166             exp_continue
1167         }
1168         -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$prompt $" {
1169             pass "finish from indirectly called function"
1170         }
1171         -re ".*$prompt $" {
1172             fail "finish from indirectly called function"
1173             return
1174         }
1175         default { fail "finish from indirectly called function" ; return }
1176     }
1177
1178     if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
1179     gdb_test "step" "call0a \\(c=97 'a', s=1, i=2, l=3\\).*" \
1180         "stepping into indirectly called function"
1181 }
1182
1183 # Start with a fresh gdb.
1184 #
1185 # Test for stepping into indirect calls which may have trampolines (possibly
1186 # cascaded) on both the call path and the return path.
1187 # to handle trampolines.
1188 #
1189 proc test_stepping_over_trampolines { } {
1190     global prompt
1191     global hex
1192     global decimal
1193
1194     # Stop in a marker function and take control from there.
1195     if { ! [ runto marker_call_with_trampolines ] } then { return 0 }
1196
1197     # Cater for gdb stopping in midline, see comment for finish above.
1198     send "finish\n"
1199     expect {
1200         -re "marker_call_with_trampolines ..;.*$prompt $" {
1201             send "step\n"
1202             exp_continue
1203         }
1204         -re "pointer_to_call_with_trampolines.*$prompt $" {
1205             pass "finish from marker_call_with_trampolines"
1206         }
1207         -re ".*$prompt $" {
1208             fail "finish from marker_call_with_trampolines"
1209         }
1210         default { fail "finish from marker_call_with_trampolines" ; return 0 }
1211     }
1212
1213     # Try to step into the target function.
1214     gdb_test "step" "call_with_trampolines \\(d1=5\\).*" \
1215         "stepping into function called with trampolines"
1216
1217     # Make we can backtrace and the argument looks correct.  */
1218     gdb_test "backtrace 8" "#0.*call_with_trampolines \\(d1=5\\).*1.*main.*" \
1219         "backtrace through call with trampolines"
1220
1221     # Make sure we can get back to main.
1222     # Stepping back to main might stop again after the return statement
1223     # or immediately transfer control back to main if optimizations
1224     # are performed.
1225     send "step\n"
1226     expect {
1227         -re "main .* at.*$prompt $" {
1228             pass "stepping back to main from function called with trampolines" ;
1229             return 1
1230         }
1231         -re "\}.*End of call_with_trampolines.*$prompt $" {
1232             send "step\n"
1233             exp_continue
1234         }
1235         -re ".*$prompt $" {
1236             fail "stepping back to main from function called with trampolines"
1237         }
1238         default { fail "stepping back to main from function called with trampolines" ; return 0 }
1239     }
1240 }
1241
1242 # Start with a fresh gdb.
1243
1244 gdb_exit
1245 gdb_start
1246 gdb_reinitialize_dir $srcdir/$subdir
1247 gdb_load $objdir/$subdir/$binfile
1248
1249 source gdb.base/funcargs.ci
1250
1251 integral_args
1252 funcargs_reload
1253 unsigned_integral_args
1254 funcargs_reload
1255 float_and_integral_args
1256 funcargs_reload
1257 pointer_args
1258 funcargs_reload
1259 structs_by_reference
1260 funcargs_reload
1261 structs_by_value
1262 funcargs_reload
1263 discard_and_shuffle
1264 funcargs_reload
1265 shuffle_round_robin
1266 funcargs_reload
1267 recursive_structs_by_value
1268 funcargs_reload
1269 localvars_after_alloca
1270 funcargs_reload
1271 call_after_alloca
1272 funcargs_reload
1273 localvars_in_indirect_call
1274 funcargs_reload
1275 test_stepping_over_trampolines