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