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