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