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