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