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