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