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