1 # Copyright (C) 1992, 1994, 1995, 1997 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Fred Fish. (fnf@cygnus.com)
29 set testfile "funcargs"
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33 perror "Couldn't compile ${srcfile}"
37 # Create and source the file that provides information about the compiler
38 # used to compile the test case.
39 if [get_compiler_info ${binfile}] {
44 # Locate actual args; integral types.
47 proc integral_args {} {
60 # Run; should stop at call0a and print actual arguments.
61 # The a29k fails all of these tests, perhaps because the prologue
63 setup_xfail "a29k-*-udi"
64 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
67 -re ".* call0a \\(c=97 'a', s=1, i=2, l=3\\) .*$gdb_prompt $" {
70 -re "$gdb_prompt $" { fail "run to call0a" ; gdb_suppress_tests }
71 timeout { fail "(timeout) run to call0a" ; gdb_suppress_tests }
74 # Print each arg as a double check to see if we can print
75 # them here as well as with backtrace.
76 gdb_test "print c" ".* = 97 'a'" "print c after run to call0a"
77 gdb_test "print s" ".* = 1" "print s after run to call0a"
78 gdb_test "print i" ".* = 2" "print i after run to call0a"
79 gdb_test "print l " ".* = 3" "print l after run to call0a"
81 # Continue; should stop at call0b and print actual arguments.
82 if [gdb_test "cont" ".* call0b \\(s=1, i=2, l=3, c=97 'a'\\) .*" "continue to call0b"] {
86 # Continue; should stop at call0c and print actual arguments.
87 if [gdb_test "cont" ".* call0c \\(i=2, l=3, c=97 'a', s=1\\) .*" "continue to call0c"] {
91 # Continue; should stop at call0d and print actual arguments.
92 if [gdb_test "cont" ".* call0d \\(l=3, c=97 'a', s=1, i=2\\) .*" "continue to call0d";] {
96 # Continue; should stop at call0e and print actual arguments.
97 if [gdb_test "cont" ".* call0e \\(c1=97 'a', l=3, c2=97 'a', i=2, c3=97 'a', s=1, c4=97 'a', c5=97 'a'\\) .*" "continue to call0e" ] {
100 gdb_stop_suppressing_tests;
104 # Locate actual args; unsigned integral types.
107 proc unsigned_integral_args {} {
114 gdb_breakpoint call1a;
115 gdb_breakpoint call1b;
116 gdb_breakpoint call1c;
117 gdb_breakpoint call1d;
118 gdb_breakpoint call1e;
120 # Run; should stop at call1a and print actual arguments.
121 # The a29k fails all of these tests, perhaps because the prologue
123 setup_xfail "a29k-*-udi"
124 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
127 -re ".* call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*$gdb_prompt $" {
130 -re "$gdb_prompt $" { fail "run to call1a" ; gdb_suppress_tests; }
131 timeout { fail "(timeout) run to call1a" ; gdb_suppress_tests; }
134 # Print each arg as a double check to see if we can print
135 # them here as well as with backtrace.
136 gdb_test "print uc" ".* = 98 'b'"
137 gdb_test "print us" ".* = 6"
138 gdb_test "print ui" ".* = 7"
139 gdb_test "print ul" ".* = 8"
141 # Continue; should stop at call1b and print actual arguments.
142 if [gdb_test "cont" ".* call1b \\(us=6, ui=7, ul=8, uc=98 'b'\\) .*" "continue to call1b"] {
146 # Continue; should stop at call1c and print actual arguments.
147 if [gdb_test "cont" ".* call1c \\(ui=7, ul=8, uc=98 'b', us=6\\) .*" "continue to call1c"] {
151 # Continue; should stop at call1d and print actual arguments.
152 if [gdb_test "cont" ".* call1d \\(ul=8, uc=98 'b', us=6, ui=7\\) .*" "continue to call1d"] {
156 # Continue; should stop at call1e and print actual arguments.
157 if [gdb_test "cont" ".* call1e \\(uc1=98 'b', ul=8, uc2=98 'b', ui=7, uc3=98 'b', us=6, uc4=98 'b', uc5=98 'b'\\) .*" "continue to call1e"] {
160 gdb_stop_suppressing_tests;
164 # Locate actual args; integrals mixed with floating point.
167 proc float_and_integral_args {} {
174 gdb_breakpoint call2a
175 gdb_breakpoint call2b
176 gdb_breakpoint call2c
177 gdb_breakpoint call2d
178 gdb_breakpoint call2e
179 gdb_breakpoint call2f
180 gdb_breakpoint call2g
181 gdb_breakpoint call2h
183 # Run; should stop at call2a and print actual arguments.
185 setup_xfail "i960-*-*" 1813
186 # The a29k fails all of these tests, perhaps because the prologue
188 setup_xfail "a29k-*-udi"
189 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" }
192 -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" }
193 -re "$gdb_prompt $" { fail "run to call2a" ; gdb_suppress_tests; }
194 timeout { fail "(timeout) run to call2a" ; gdb_suppress_tests; }
197 # Print each arg as a double check to see if we can print
198 gdb_test "print c" ".* = 97 'a'" "print c after run to call2a"
199 gdb_test "print f1" ".* = 4" "print f1 after run to call2a"
200 gdb_test "print s" ".* = 1" "print s after run to call2a"
201 gdb_test "print d1" ".* = 5" "print d1 after run to call2a"
202 gdb_test "print i" ".* = 2" "print i after run to call2a"
203 gdb_test "print f2" ".* = 4" "print f2 after run to call2a"
204 gdb_test "print l" ".* = 3" "print l after run to call2a"
205 gdb_test "print d2" ".* = 5" "print d2 after run to call2a"
207 setup_xfail "rs6000-*-*"
208 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
209 # Continue; should stop at call2b and print actual arguments.
210 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"] {
214 # Continue; should stop at call2c and print actual arguments.
215 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"] {
219 # Continue; should stop at call2d and print actual arguments.
220 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"] {
224 # Continue; should stop at call2e and print actual arguments.
225 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"] {
229 # Continue; should stop at call2f and print actual arguments.
230 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"] {
234 # Continue; should stop at call2g and print actual arguments.
235 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"] {
239 # Continue; should stop at call2h and print actual arguments.
240 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"] {
244 # monitor only allows 8 breakpoints; w89k board allows 10, so
245 # break them up into two groups.
247 gdb_breakpoint call2i
249 # Continue; should stop at call2i and print actual arguments.
250 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"] {
253 gdb_stop_suppressing_tests;
257 # Locate actual args; dereference pointers to ints and floats.
260 proc pointer_args {} {
267 gdb_breakpoint call3a
268 gdb_breakpoint call3b
269 gdb_breakpoint call3c
271 # Run; should stop at call3a and print actual arguments.
272 # Try dereferencing the arguments.
274 # The a29k fails all of these tests, perhaps because the prologue
276 setup_xfail "a29k-*-udi"
279 -re ".* call3a \\(cp=$hex \"a\", sp=$hex, ip=$hex, lp=$hex\\) .*$gdb_prompt $" { pass "run to call3a" }
280 -re "$gdb_prompt $" { fail "run to call3a" ; gdb_suppress_tests; }
281 timeout { fail "(timeout) run to call3a" ; gdb_suppress_tests; }
284 gdb_test "print *cp" ".* = 97 'a'"
285 gdb_test "print *sp" ".* = 1"
286 gdb_test "print *ip" ".* = 2"
287 gdb_test "print *lp" ".* = 3"
289 # Continue; should stop at call3b and print actual arguments.
290 # Try dereferencing the arguments.
291 if [gdb_test "cont" ".* call3b \\(ucp=$hex \"b\", usp=$hex, uip=$hex, ulp=$hex\\) .*" "continue to call3b"] {
295 gdb_test "print *ucp" ".* = 98 'b'"
296 gdb_test "print *usp" ".* = 6"
297 gdb_test "print *uip" ".* = 7"
298 gdb_test "print *ulp" ".* = 8"
300 # Continue; should stop at call3c and print actual arguments.
301 # Try dereferencing the arguments.
302 if [gdb_test "cont" ".* call3c \\(fp=$hex, dp=$hex\\) .*" "continue to call3c"] {
306 gdb_test "print *fp" ".* = 4"
307 gdb_test "print *dp" ".* = 5"
309 # pass "locate actual args, pointer types"
310 gdb_stop_suppressing_tests;
314 # Locate actual args; structures and unions passed by reference.
317 proc structs_by_reference {} {
324 gdb_breakpoint call4a
325 gdb_breakpoint call4b
327 # Run; should stop at call4a and print actual arguments.
328 # Try dereferencing the arguments.
330 # The a29k fails all of these tests, perhaps because the prologue
332 setup_xfail "a29k-*-udi"
335 -re ".* call4a \\(stp=$hex\\) .*$gdb_prompt $" {
338 -re "$gdb_prompt $" { fail "run to call4a" ; gdb_suppress_tests; }
339 timeout { fail "(timeout) run to call4a" ; gdb_suppress_tests; }
342 gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}"
344 # Continue; should stop at call4b and print actual arguments.
345 # Try dereferencing the arguments.
347 gdb_test "cont" ".* call4b \\(unp=$hex\\) .*" "continue to call4b"
349 # sizeof int != sizeof long
350 if [target_info exists gdb,short_int] {
353 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}"
355 pass "locate actual args, structs/unions passed by reference"
356 gdb_stop_suppressing_tests;
360 # Locate actual args; structures and unions passed by value.
363 proc structs_by_value {} {
370 gdb_breakpoint call5a
371 gdb_breakpoint call5b
373 # Run; should stop at call5a and print actual arguments.
374 # Try dereferencing the arguments.
376 # The a29k fails all of these tests, perhaps because the prologue
378 setup_xfail "a29k-*-udi"
381 -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$gdb_prompt $" {
384 -re "$gdb_prompt $" { fail "run to call5a" ; gdb_suppress_tests; }
385 timeout { fail "(timeout) run to call5a" ; gdb_suppress_tests; }
388 gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}"
390 # Continue; should stop at call5b and print actual arguments.
391 # Try dereferencing the arguments.
392 # sizeof int != sizeof long
393 if [target_info exists gdb,short_int] {
396 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \
399 # sizeof int != sizeof long
400 if [target_info exists gdb,short_int] {
403 gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}"
404 gdb_stop_suppressing_tests;
408 # Locate actual args; discard, shuffle, and call
411 proc discard_and_shuffle {} {
420 gdb_breakpoint call6a
421 gdb_breakpoint call6b
422 gdb_breakpoint call6c
423 gdb_breakpoint call6d
424 gdb_breakpoint call6e
425 gdb_breakpoint call6f
426 gdb_breakpoint call6g
427 gdb_breakpoint call6h
429 # Run; should stop at call6a and print actual arguments.
432 # The a29k fails all of these tests, perhaps because the prologue
434 setup_xfail "a29k-*-udi"
437 -re ".*Breakpoint $decimal, call6a .*$gdb_prompt $" { pass "run to call6a" }
438 -re "$gdb_prompt $" { fail "run to call6a" ; gdb_suppress_tests; }
439 timeout { fail "(timeout) run to call6a" ; gdb_suppress_tests; }
442 setup_xfail "rs6000-*-*"
444 if {!$gcc_compiled} {
445 setup_xfail "mips-sgi-irix5*"
448 if [gdb_test "backtrace 100" ".* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\]" "backtrace from call6a"] {
452 # Continue; should stop at call6b and print actual arguments.
457 if [gdb_test "backtrace 100" ".* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\]*.* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\]" "backtrace from call6b"] {
461 # Continue; should stop at call6c and print actual arguments.
466 if [gdb_test "backtrace 100" ".* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6c"] {
469 # Continue; should stop at call6d and print actual arguments.
474 if [gdb_test "backtrace 100" ".* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6d"] {
478 # Continue; should stop at call6e and print actual arguments.
483 if [gdb_test "backtrace 100" ".* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6e"] {
487 # Continue; should stop at call6f and print actual arguments.
492 if [gdb_test "backtrace 100" ".* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6f"] {
496 # Continue; should stop at call6g and print actual arguments.
501 if [gdb_test "backtrace 100" ".* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6g"] {
505 # Continue; should stop at call6h and print actual arguments.
510 if [gdb_test "backtrace 100" ".* call6h \\(us=6, ui=7, ul=8\\) .*\[\r\n\].* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6h"] {
514 # monitor only allows 8 breakpoints; w89k board allows 10, so
515 # break them up into two groups.
517 gdb_breakpoint call6i
518 gdb_breakpoint call6j
519 gdb_breakpoint call6k
521 # Continue; should stop at call6i and print actual arguments.
526 if [gdb_test "backtrace 100" ".* call6i \\(ui=7, ul=8\\) .*\[\r\n\].* call6h \\(us=6, ui=7, ul=8\\) .*\[\r\n\].* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6i"] {
530 # Continue; should stop at call6j and print actual arguments.
535 if [gdb_test "backtrace 100" ".* call6j \\(ul=8\\) .*\[\r\n\].* call6i \\(ui=7, ul=8\\) .*\[\r\n\].* call6h \\(us=6, ui=7, ul=8\\) .*\[\r\n\].* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6j"] {
539 # Continue; should stop at call6k and print actual arguments.
541 # This fails on i960-*-vxworks because gdb gets confused by
542 # breakpoints on adjacent instructions.
543 setup_xfail "i960-*-vxworks" 1786
546 if [gdb_test "backtrace 100" ".* call6k \\(\\) .*\[\r\n\].* call6j \\(ul=8\\) .*\[\r\n\].* call6i \\(ui=7, ul=8\\) .*\[\r\n\].* call6h \\(us=6, ui=7, ul=8\\) .*\[\r\n\].* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6k"] {
549 gdb_stop_suppressing_tests;
554 # Locate actual args; shuffle round robin and call
557 proc shuffle_round_robin {} {
566 gdb_breakpoint call7a
567 gdb_breakpoint call7b
568 gdb_breakpoint call7c
569 gdb_breakpoint call7d
570 gdb_breakpoint call7e
571 gdb_breakpoint call7f
572 gdb_breakpoint call7g
573 gdb_breakpoint call7h
575 # Run; should stop at call7a and print actual arguments.
578 # The a29k fails all of these tests, perhaps because the prologue
580 setup_xfail "a29k-*-udi"
583 -re ".*Breakpoint $decimal, call7a .*$gdb_prompt $" {
586 -re "$gdb_prompt $" { fail "run to call7a" ; gdb_suppress_tests; }
587 timeout { fail "(timeout) run to call7a" ; gdb_suppress_tests; }
590 setup_xfail "i960-*-*" 1813
591 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" }
592 gdb_test "backtrace 100" ".* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7a"
594 # Continue; should stop at call7b and print actual arguments.
599 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
601 gdb_test "backtrace 100" ".* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7b"
603 # Continue; should stop at call7c and print actual arguments.
608 gdb_test "backtrace 100" ".* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7c"
610 # Continue; should stop at call7d and print actual arguments.
615 gdb_test "backtrace 100" ".* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7d"
619 gdb_test "backtrace 100" ".* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7e"
621 # Continue; should stop at call7f and print actual arguments.
626 gdb_test "backtrace 100" ".* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7f"
628 # Continue; should stop at call7g and print actual arguments.
633 gdb_test "backtrace 100" ".* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\[\r\n\].* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7g"
637 gdb_test "backtrace 100" ".* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\[\r\n\].* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\[\r\n\].* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7h"
639 # monitor only allows 8 breakpoints; w89k board allows 10, so
640 # break them up into two groups.
642 gdb_breakpoint call7i
643 gdb_breakpoint call7j
644 gdb_breakpoint call7k
646 # Continue; should stop at call7i and print actual arguments.
651 gdb_test "backtrace 100" ".* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\[\r\n\].* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\[\r\n\].* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\[\r\n\].* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7i"
653 # Continue; should stop at call7j and print actual arguments.
658 gdb_test "backtrace 100" ".* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) .*\[\r\n\].* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\[\r\n\].* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\[\r\n\].* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\[\r\n\].* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7j"
660 # Continue; should stop at call7k and print actual arguments.
665 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
666 gdb_test "backtrace 100" ".* call7k \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) .*\[\r\n\].* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\[\r\n\].* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\[\r\n\].* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\[\r\n\].* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7k"
667 gdb_stop_suppressing_tests;
671 # Locate actual args; recursive passing of structs by value
674 proc recursive_structs_by_value {} {
682 gdb_breakpoint hitbottom
684 # Run; should stop at hitbottom and print actual arguments.
688 -re ".*Breakpoint $decimal, hitbottom .*$gdb_prompt $" { pass "run to hitbottom" }
689 -re "$gdb_prompt $" { fail "run to hitbottom" ; gdb_suppress_tests; }
690 timeout { fail "(timeout) run to hitbottom" ; gdb_suppress_tests; }
693 if ![istarget sparclet-*-*] {
694 # The a29k fails all of these tests, perhaps because the prologue
696 setup_xfail "a29k-*-udi"
697 gdb_test "backtrace 100" ".* hitbottom \\(\\) .*\[\r\n\].* recurse \\(a=\{s = 0, i = 0, l = 0\}, depth=0\\) .*\[\r\n\].* recurse \\(a=\{s = 1, i = 1, l = 1\}, depth=1\\) .*\[\r\n\].* recurse \\(a=\{s = 2, i = 2, l = 2\}, depth=2\\) .*\[\r\n\].* recurse \\(a=\{s = 3, i = 3, l = 3\}, depth=3\\) .*\[\r\n\].* recurse \\(a=\{s = 4, i = 4, l = 4\}, depth=4\\) .*\[\r\n\].* test_struct_args \\(\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\]" "recursive passing of structs by value"
699 fail "recursive passing of structs by value (sparclet)"
701 gdb_stop_suppressing_tests;
704 proc funcargs_reload { } {
710 if [istarget "mips-idt-*"] {
711 # Restart because IDT/SIM runs out of file descriptors.
714 gdb_reinitialize_dir $srcdir/$subdir
720 # Test for accessing local stack variables in functions which call alloca
722 proc localvars_after_alloca { } {
728 if { ! [ runto localvars_after_alloca ] } then { gdb_suppress_tests; }
730 # Print each arg as a double check to see if we can print
731 # them here as well as with backtrace.
733 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
734 gdb_test "print c" " = 97 'a'" "print c after runto localvars_after_alloca"
735 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
736 gdb_test "print s" " = 1" "print s after runto localvars_after_alloca"
737 gdb_test "print i" " = 2" "print i after runto localvars_after_alloca"
738 gdb_test "print l" " = 3" "print l after runto localvars_after_alloca"
741 gdb_test "next" ".*" "next in localvars_after_alloca()"
743 # Print each arg as a double check to see if we can print
744 # them here as well as with backtrace.
746 gdb_test "print c" " = 97 'a'" "print c in localvars_after_alloca"
747 gdb_test "print s" " = 1" "print s in localvars_after_alloca"
748 gdb_test "print i" " = 2" "print i in localvars_after_alloca"
749 gdb_test "print l" " = 3" "print l in localvars_after_alloca"
751 gdb_test "backtrace 8" "#0.*localvars_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" "backtrace after alloca"
752 gdb_stop_suppressing_tests;
755 proc call_after_alloca { } {
761 if { ! [ runto call_after_alloca_subr ] } then { gdb_suppress_tests; }
763 # Print each arg as a double check to see if we can print
764 # them here as well as with backtrace.
766 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
767 gdb_test "print c" " = 97 'a'" "print c in call_after_alloca"
768 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
769 gdb_test "print s" " = 1" "print s in call_after_alloca"
770 gdb_test "print i" " = 2" "print i in call_after_alloca"
771 gdb_test "print l" " = 3" "print l in call_after_alloca"
773 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
774 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"
775 gdb_stop_suppressing_tests;
779 # Test for accessing local stack variables, backtraces, finish,
780 # and finally stepping into indirect calls. The point is that on the PA
781 # these use a funky `dyncall' mechanism which GDB needs to know about.
783 proc localvars_in_indirect_call { } {
789 # Can not use "runto call0a" as call0a is called several times
790 # during single run. Instead stop in a marker function and
791 # take control from there.
792 if { ! [ runto marker_indirect_call ] } then { gdb_suppress_tests; }
794 # break on the next call to call0a, then delete all the breakpoints
796 gdb_breakpoint call0a
800 # Print each arg as a double check to see if we can print
801 # them here as well as with backtrace.
803 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
804 gdb_test "print c" " = 97 'a'" "print c in localvars_in_indirect_call"
805 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
806 gdb_test "print s" " = 1" "print s in localvars_in_indirect_call"
807 gdb_test "print i" " = 2" "print i in localvars_in_indirect_call"
808 gdb_test "print l" " = 3" "print l in localvars_in_indirect_call"
810 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
811 gdb_test "backtrace 8" \
812 "#0.*call0a \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" \
813 "backtrace in indirectly called function"
816 # "finish" brings us back to main. We then will try to step through
817 # the second indirect call.
818 # On some targets (e.g. m68k) gdb will stop from the finish in midline
819 # of the first indirect call. This is due to stack adjustment instructions
820 # after the indirect call. In these cases we will step till we hit the
821 # second indirect call.
826 -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$gdb_prompt $" {
830 -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$gdb_prompt $" {
831 pass "finish from indirectly called function"
833 -re ".*$gdb_prompt $" {
834 fail "finish from indirectly called function"
837 default { fail "finish from indirectly called function" ; gdb_suppress_tests; }
840 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
841 gdb_test "step" "call0a \\(c=97 'a', s=1, i=2, l=3\\).*" \
842 "stepping into indirectly called function"
843 gdb_stop_suppressing_tests;
846 # Start with a fresh gdb.
848 # Test for stepping into indirect calls which may have trampolines (possibly
849 # cascaded) on both the call path and the gdb_suppress_tests; path.
850 # to handle trampolines.
852 proc test_stepping_over_trampolines { } {
857 # Stop in a marker function and take control from there.
858 if { ! [ runto marker_call_with_trampolines ] } then { gdb_suppress_tests; }
860 # Cater for gdb stopping in midline, see comment for finish above.
863 -re "marker_call_with_trampolines ..;.*$gdb_prompt $" {
867 -re "pointer_to_call_with_trampolines.*$gdb_prompt $" {
868 pass "finish from marker_call_with_trampolines"
870 -re ".*$gdb_prompt $" {
871 fail "finish from marker_call_with_trampolines"
873 default { fail "finish from marker_call_with_trampolines" ; gdb_suppress_tests; }
876 # Try to step into the target function.
877 gdb_test "step" "call_with_trampolines \\(d1=5\\).*" \
878 "stepping into function called with trampolines"
880 # Make we can backtrace and the argument looks correct. */
881 gdb_test "backtrace 8" "#0.*call_with_trampolines \\(d1=5\\).*1.*main.*" \
882 "backtrace through call with trampolines"
884 # Make sure we can get back to main.
885 # Stepping back to main might stop again after the gdb_suppress_tests; statement
886 # or immediately transfer control back to main if optimizations
890 -re "main .* at.*$gdb_prompt $" {
891 pass "stepping back to main from function called with trampolines" ;
893 -re "\}.*End of call_with_trampolines.*$gdb_prompt $" {
897 -re ".*$gdb_prompt $" {
898 fail "stepping back to main from function called with trampolines"
900 default { fail "stepping back to main from function called with trampolines" ; gdb_suppress_tests; }
902 gdb_stop_suppressing_tests;
905 # Start with a fresh gdb.
909 gdb_reinitialize_dir $srcdir/$subdir
916 unsigned_integral_args
918 float_and_integral_args
930 recursive_structs_by_value
932 localvars_after_alloca
936 localvars_in_indirect_call
938 test_stepping_over_trampolines