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 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
36 # Create and source the file that provides information about the compiler
37 # used to compile the test case.
38 if [get_compiler_info ${binfile}] {
43 # Locate actual args; integral types.
46 proc integral_args {} {
59 # Run; should stop at call0a and print actual arguments.
60 # The a29k fails all of these tests, perhaps because the prologue
62 setup_xfail "a29k-*-udi"
63 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
66 -re ".* call0a \\(c=97 'a', s=1, i=2, l=3\\) .*$gdb_prompt $" {
69 -re "$gdb_prompt $" { fail "run to call0a" ; gdb_suppress_tests }
70 timeout { fail "(timeout) run to call0a" ; gdb_suppress_tests }
73 # Print each arg as a double check to see if we can print
74 # them here as well as with backtrace.
75 gdb_test "print c" ".* = 97 'a'" "print c after run to call0a"
76 gdb_test "print s" ".* = 1" "print s after run to call0a"
77 gdb_test "print i" ".* = 2" "print i after run to call0a"
78 gdb_test "print l " ".* = 3" "print l after run to call0a"
80 # Continue; should stop at call0b and print actual arguments.
81 if [gdb_test "cont" ".* call0b \\(s=1, i=2, l=3, c=97 'a'\\) .*" "continue to call0b"] {
85 # Continue; should stop at call0c and print actual arguments.
86 if [gdb_test "cont" ".* call0c \\(i=2, l=3, c=97 'a', s=1\\) .*" "continue to call0c"] {
90 # Continue; should stop at call0d and print actual arguments.
91 if [gdb_test "cont" ".* call0d \\(l=3, c=97 'a', s=1, i=2\\) .*" "continue to call0d";] {
95 # Continue; should stop at call0e and print actual arguments.
96 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" ] {
99 gdb_stop_suppressing_tests;
103 # Locate actual args; unsigned integral types.
106 proc unsigned_integral_args {} {
113 gdb_breakpoint call1a;
114 gdb_breakpoint call1b;
115 gdb_breakpoint call1c;
116 gdb_breakpoint call1d;
117 gdb_breakpoint call1e;
119 # Run; should stop at call1a and print actual arguments.
120 # The a29k fails all of these tests, perhaps because the prologue
122 setup_xfail "a29k-*-udi"
123 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
126 -re ".* call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*$gdb_prompt $" {
129 -re "$gdb_prompt $" { fail "run to call1a" ; gdb_suppress_tests; }
130 timeout { fail "(timeout) run to call1a" ; gdb_suppress_tests; }
133 # Print each arg as a double check to see if we can print
134 # them here as well as with backtrace.
135 gdb_test "print uc" ".* = 98 'b'"
136 gdb_test "print us" ".* = 6"
137 gdb_test "print ui" ".* = 7"
138 gdb_test "print ul" ".* = 8"
140 # Continue; should stop at call1b and print actual arguments.
141 if [gdb_test "cont" ".* call1b \\(us=6, ui=7, ul=8, uc=98 'b'\\) .*" "continue to call1b"] {
145 # Continue; should stop at call1c and print actual arguments.
146 if [gdb_test "cont" ".* call1c \\(ui=7, ul=8, uc=98 'b', us=6\\) .*" "continue to call1c"] {
150 # Continue; should stop at call1d and print actual arguments.
151 if [gdb_test "cont" ".* call1d \\(ul=8, uc=98 'b', us=6, ui=7\\) .*" "continue to call1d"] {
155 # Continue; should stop at call1e and print actual arguments.
156 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"] {
159 gdb_stop_suppressing_tests;
163 # Locate actual args; integrals mixed with floating point.
166 proc float_and_integral_args {} {
173 gdb_breakpoint call2a
174 gdb_breakpoint call2b
175 gdb_breakpoint call2c
176 gdb_breakpoint call2d
177 gdb_breakpoint call2e
178 gdb_breakpoint call2f
179 gdb_breakpoint call2g
180 gdb_breakpoint call2h
182 # Run; should stop at call2a and print actual arguments.
184 setup_xfail "i960-*-*" 1813
185 # The a29k fails all of these tests, perhaps because the prologue
187 setup_xfail "a29k-*-udi"
188 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" }
191 -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" }
192 -re "$gdb_prompt $" { fail "run to call2a" ; gdb_suppress_tests; }
193 timeout { fail "(timeout) run to call2a" ; gdb_suppress_tests; }
196 # Print each arg as a double check to see if we can print
197 gdb_test "print c" ".* = 97 'a'" "print c after run to call2a"
198 gdb_test "print f1" ".* = 4" "print f1 after run to call2a"
199 gdb_test "print s" ".* = 1" "print s after run to call2a"
200 gdb_test "print d1" ".* = 5" "print d1 after run to call2a"
201 gdb_test "print i" ".* = 2" "print i after run to call2a"
202 gdb_test "print f2" ".* = 4" "print f2 after run to call2a"
203 gdb_test "print l" ".* = 3" "print l after run to call2a"
204 gdb_test "print d2" ".* = 5" "print d2 after run to call2a"
206 setup_xfail "rs6000-*-*"
207 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
208 # Continue; should stop at call2b and print actual arguments.
209 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"] {
213 # Continue; should stop at call2c and print actual arguments.
214 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"] {
218 # Continue; should stop at call2d and print actual arguments.
219 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"] {
223 # Continue; should stop at call2e and print actual arguments.
224 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"] {
228 # Continue; should stop at call2f and print actual arguments.
229 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"] {
233 # Continue; should stop at call2g and print actual arguments.
234 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"] {
238 # Continue; should stop at call2h and print actual arguments.
239 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"] {
243 # monitor only allows 8 breakpoints; w89k board allows 10, so
244 # break them up into two groups.
246 gdb_breakpoint call2i
248 # Continue; should stop at call2i and print actual arguments.
249 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"] {
252 gdb_stop_suppressing_tests;
256 # Locate actual args; dereference pointers to ints and floats.
259 proc pointer_args {} {
266 gdb_breakpoint call3a
267 gdb_breakpoint call3b
268 gdb_breakpoint call3c
270 # Run; should stop at call3a and print actual arguments.
271 # Try dereferencing the arguments.
273 # The a29k fails all of these tests, perhaps because the prologue
275 setup_xfail "a29k-*-udi"
278 -re ".* call3a \\(cp=$hex \"a\", sp=$hex, ip=$hex, lp=$hex\\) .*$gdb_prompt $" { pass "run to call3a" }
279 -re "$gdb_prompt $" { fail "run to call3a" ; gdb_suppress_tests; }
280 timeout { fail "(timeout) run to call3a" ; gdb_suppress_tests; }
283 gdb_test "print *cp" ".* = 97 'a'"
284 gdb_test "print *sp" ".* = 1"
285 gdb_test "print *ip" ".* = 2"
286 gdb_test "print *lp" ".* = 3"
288 # Continue; should stop at call3b and print actual arguments.
289 # Try dereferencing the arguments.
290 if [gdb_test "cont" ".* call3b \\(ucp=$hex \"b\", usp=$hex, uip=$hex, ulp=$hex\\) .*" "continue to call3b"] {
294 gdb_test "print *ucp" ".* = 98 'b'"
295 gdb_test "print *usp" ".* = 6"
296 gdb_test "print *uip" ".* = 7"
297 gdb_test "print *ulp" ".* = 8"
299 # Continue; should stop at call3c and print actual arguments.
300 # Try dereferencing the arguments.
301 if [gdb_test "cont" ".* call3c \\(fp=$hex, dp=$hex\\) .*" "continue to call3c"] {
305 gdb_test "print *fp" ".* = 4"
306 gdb_test "print *dp" ".* = 5"
308 # pass "locate actual args, pointer types"
309 gdb_stop_suppressing_tests;
313 # Locate actual args; structures and unions passed by reference.
316 proc structs_by_reference {} {
320 global target_sizeof_int
321 global target_sizeof_long
322 global target_bigendian_p
326 gdb_breakpoint call4a
327 gdb_breakpoint call4b
329 # Run; should stop at call4a and print actual arguments.
330 # Try dereferencing the arguments.
332 # The a29k fails all of these tests, perhaps because the prologue
334 setup_xfail "a29k-*-udi"
337 -re ".* call4a \\(stp=$hex\\) .*$gdb_prompt $" {
340 -re "$gdb_prompt $" { fail "run to call4a" ; gdb_suppress_tests; }
341 timeout { fail "(timeout) run to call4a" ; gdb_suppress_tests; }
344 gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}"
346 # Continue; should stop at call4b and print actual arguments.
348 gdb_test "cont" ".* call4b \\(unp=$hex\\) .*" "continue to call4b"
350 # Try dereferencing the arguments.
351 if { $target_sizeof_long == $target_sizeof_int } {
352 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}" \
353 "print *unp (sizeof long == sizeof int)"
354 } elseif { ! $target_bigendian_p } {
355 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}" \
356 "print *unp (little-endian, sizeof long != sizeof int)"
357 } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } {
358 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 4294967296\}" \
359 "print *unp (big-endian, sizeof long == 8, sizeof int = 4)"
360 } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } {
361 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 65536\}" \
362 "print *unp (big-endian, sizeof long == 4, sizeof int = 2)"
364 fail "print *unp (unknown case)"
367 pass "locate actual args, structs/unions passed by reference"
368 gdb_stop_suppressing_tests;
372 # Locate actual args; structures and unions passed by value.
375 proc structs_by_value {} {
379 global target_sizeof_int
380 global target_sizeof_long
381 global target_bigendian_p
385 gdb_breakpoint call5a
386 gdb_breakpoint call5b
388 # Run; should stop at call5a and print actual arguments.
389 # Try dereferencing the arguments.
391 # The a29k fails all of these tests, perhaps because the prologue
393 setup_xfail "a29k-*-udi"
396 -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$gdb_prompt $" {
399 -re "$gdb_prompt $" { fail "run to call5a" ; gdb_suppress_tests; }
400 timeout { fail "(timeout) run to call5a" ; gdb_suppress_tests; }
403 gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}"
405 # Continue; should stop at call5b and print actual arguments.
406 if { $target_sizeof_long == $target_sizeof_int } {
407 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \
408 "continue to call5b (sizeof long == sizeof int)"
409 } elseif { ! $target_bigendian_p } {
410 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \
411 "continue to call5b (little-endian, sizeof long != sizeof int)"
412 } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } {
413 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 8589934592\}\\) .*" \
414 "continue to call5b (big-endian, sizeof long == 8, sizeof int = 4)"
415 } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } {
416 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 131072\}\\) .*" \
417 "continue to call5b (big-endian, sizeof long == 4, sizeof int = 2)"
419 fail "continue to call5b (unknown case)"
422 # Try dereferencing the arguments.
423 if { $target_sizeof_long == $target_sizeof_int } {
424 gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}" \
425 "print un (sizeof long == sizeof int)"
426 } elseif { ! $target_bigendian_p } {
427 gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}" \
428 "print un (little-endian, sizeof long != sizeof int)"
429 } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } {
430 gdb_test "print un" ".* = \{u1 = 2, u2 = 8589934592\}" \
431 "print un (big-endian, sizeof long == 8, sizeof int = 4)"
432 } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } {
433 gdb_test "print un" ".* = \{u1 = 2, u2 = 131072\}" \
434 "print un (big-endian, sizeof long == 4, sizeof int = 2)"
436 fail "print un (unknown case)"
439 gdb_stop_suppressing_tests;
443 # Locate actual args; discard, shuffle, and call
446 proc discard_and_shuffle {} {
455 gdb_breakpoint call6a
456 gdb_breakpoint call6b
457 gdb_breakpoint call6c
458 gdb_breakpoint call6d
459 gdb_breakpoint call6e
460 gdb_breakpoint call6f
461 gdb_breakpoint call6g
462 gdb_breakpoint call6h
464 # Run; should stop at call6a and print actual arguments.
467 # The a29k fails all of these tests, perhaps because the prologue
469 setup_xfail "a29k-*-udi"
472 -re ".*Breakpoint $decimal, call6a .*$gdb_prompt $" { pass "run to call6a" }
473 -re "$gdb_prompt $" { fail "run to call6a" ; gdb_suppress_tests; }
474 timeout { fail "(timeout) run to call6a" ; gdb_suppress_tests; }
477 setup_xfail "rs6000-*-*"
479 if {!$gcc_compiled} {
480 setup_xfail "mips-sgi-irix5*"
483 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\\).* main \\(.*\\).*" "backtrace from call6a"] {
487 # Continue; should stop at call6b and print actual arguments.
492 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\\).* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* main \\(.*\\).*" "backtrace from call6b"] {
496 # Continue; should stop at call6c and print actual arguments.
501 if [gdb_test "backtrace 100" " call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* main \\(.*\\).*" "backtrace from call6c"] {
504 # Continue; should stop at call6d and print actual arguments.
509 if [gdb_test "backtrace 100" " call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* main \\(.*\\).*" "backtrace from call6d"] {
513 # Continue; should stop at call6e and print actual arguments.
518 if [gdb_test "backtrace 100" " call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* main \\(.*\\).*" "backtrace from call6e"] {
522 # Continue; should stop at call6f and print actual arguments.
527 if [gdb_test "backtrace 100" " call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* main \\(.*\\).*" "backtrace from call6f"] {
531 # Continue; should stop at call6g and print actual arguments.
536 if [gdb_test "backtrace 100" " call6g \\(uc=98 'b', us=6, ui=7, ul=8\\).* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* main \\(.*\\).*" "backtrace from call6g"] {
540 # Continue; should stop at call6h and print actual arguments.
545 if [gdb_test "backtrace 100" " call6h \\(us=6, ui=7, ul=8\\).* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\).* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* main \\(.*\\).*" "backtrace from call6h"] {
549 # monitor only allows 8 breakpoints; w89k board allows 10, so
550 # break them up into two groups.
552 gdb_breakpoint call6i
553 gdb_breakpoint call6j
554 gdb_breakpoint call6k
556 # Continue; should stop at call6i and print actual arguments.
561 if [gdb_test "backtrace 100" " call6i \\(ui=7, ul=8\\).* call6h \\(us=6, ui=7, ul=8\\).* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\).* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* main \\(.*\\).*" "backtrace from call6i"] {
565 # Continue; should stop at call6j and print actual arguments.
570 if [gdb_test "backtrace 100" " call6j \\(ul=8\\).* call6i \\(ui=7, ul=8\\).* call6h \\(us=6, ui=7, ul=8\\).* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\).* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* main \\(.*\\).*" "backtrace from call6j"] {
574 # Continue; should stop at call6k and print actual arguments.
576 # This fails on i960-*-vxworks because gdb gets confused by
577 # breakpoints on adjacent instructions.
578 setup_xfail "i960-*-vxworks" 1786
581 if [gdb_test "backtrace 100" " call6k \\(\\).* call6j \\(ul=8\\).* call6i \\(ui=7, ul=8\\).* call6h \\(us=6, ui=7, ul=8\\).* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\).* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\).* main \\(.*\\).*" "backtrace from call6k"] {
584 gdb_stop_suppressing_tests;
589 # Locate actual args; shuffle round robin and call
592 proc shuffle_round_robin {} {
601 gdb_breakpoint call7a
602 gdb_breakpoint call7b
603 gdb_breakpoint call7c
604 gdb_breakpoint call7d
605 gdb_breakpoint call7e
606 gdb_breakpoint call7f
607 gdb_breakpoint call7g
608 gdb_breakpoint call7h
610 # Run; should stop at call7a and print actual arguments.
613 # The a29k fails all of these tests, perhaps because the prologue
615 setup_xfail "a29k-*-udi"
618 -re ".*Breakpoint $decimal, call7a .*$gdb_prompt $" {
621 -re "$gdb_prompt $" { fail "run to call7a" ; gdb_suppress_tests; }
622 timeout { fail "(timeout) run to call7a" ; gdb_suppress_tests; }
625 setup_xfail "i960-*-*" 1813
626 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" }
627 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\\).* main \\(.*\\).*" "backtrace from call7a"
629 # Continue; should stop at call7b and print actual arguments.
634 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
636 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'\\).* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\).* main \\(.*\\).*" "backtrace from call7b"
638 # Continue; should stop at call7c and print actual arguments.
643 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\\).* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\).* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\).* main \\(.*\\).*" "backtrace from call7c"
645 # Continue; should stop at call7d and print actual arguments.
650 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\\).* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\).* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\).* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\).* main \\(.*\\).*" "backtrace from call7d"
654 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\\).* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\).* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\).* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\).* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\).* main \\(.*\\).*" "backtrace from call7e"
656 # Continue; should stop at call7f and print actual arguments.
661 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\\).* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\).* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\).* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\).* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\).* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\).* main \\(.*\\).*" "backtrace from call7f"
663 # Continue; should stop at call7g and print actual arguments.
668 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'\\).* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\).* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\).* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\).* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\).* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\).* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\).* main \\(.*\\).*" "backtrace from call7g"
672 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\\).* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\).* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\).* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\).* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\).* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\).* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\).* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\).* main \\(.*\\).*" "backtrace from call7h"
674 # monitor only allows 8 breakpoints; w89k board allows 10, so
675 # break them up into two groups.
677 gdb_breakpoint call7i
678 gdb_breakpoint call7j
679 gdb_breakpoint call7k
681 # Continue; should stop at call7i and print actual arguments.
686 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\\).* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\).* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\).* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\).* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\).* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\).* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\).* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\).* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\).* main \\(.*\\).*" "backtrace from call7i"
688 # Continue; should stop at call7j and print actual arguments.
693 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\\).* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\).* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\).* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\).* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\).* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\).* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\).* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\).* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\).* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\).* main \\(.*\\).*" "backtrace from call7j"
695 # Continue; should stop at call7k and print actual arguments.
700 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
701 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\\).* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\).* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\).* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\).* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\).* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\).* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\).* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\).* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\).* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\).* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\).* main \\(.*\\).*" "backtrace from call7k"
702 gdb_stop_suppressing_tests;
706 # Locate actual args; recursive passing of structs by value
709 proc recursive_structs_by_value {} {
717 gdb_breakpoint hitbottom
719 # Run; should stop at hitbottom and print actual arguments.
723 -re ".*Breakpoint $decimal, hitbottom .*$gdb_prompt $" { pass "run to hitbottom" }
724 -re "$gdb_prompt $" { fail "run to hitbottom" ; gdb_suppress_tests; }
725 timeout { fail "(timeout) run to hitbottom" ; gdb_suppress_tests; }
728 if ![istarget sparclet-*-*] {
729 # The a29k fails all of these tests, perhaps because the prologue
731 setup_xfail "a29k-*-udi"
732 gdb_test "backtrace 100" " hitbottom \\(\\).* recurse \\(a=\{s = 0, i = 0, l = 0\}, depth=0\\).* recurse \\(a=\{s = 1, i = 1, l = 1\}, depth=1\\).* recurse \\(a=\{s = 2, i = 2, l = 2\}, depth=2\\).* recurse \\(a=\{s = 3, i = 3, l = 3\}, depth=3\\).* recurse \\(a=\{s = 4, i = 4, l = 4\}, depth=4\\).* test_struct_args \\(\\).* main \\(.*\\).*" "recursive passing of structs by value"
734 fail "recursive passing of structs by value (sparclet)"
736 gdb_stop_suppressing_tests;
739 proc funcargs_reload { } {
745 if [istarget "mips-idt-*"] {
746 # Restart because IDT/SIM runs out of file descriptors.
749 gdb_reinitialize_dir $srcdir/$subdir
755 # Test for accessing local stack variables in functions which call alloca
757 proc localvars_after_alloca { } {
763 if { ! [ runto localvars_after_alloca ] } then { gdb_suppress_tests; }
765 # Print each arg as a double check to see if we can print
766 # them here as well as with backtrace.
768 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
769 gdb_test "print c" " = 97 'a'" "print c after runto localvars_after_alloca"
770 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
771 gdb_test "print s" " = 1" "print s after runto localvars_after_alloca"
772 gdb_test "print i" " = 2" "print i after runto localvars_after_alloca"
773 gdb_test "print l" " = 3" "print l after runto localvars_after_alloca"
776 gdb_test "next" ".*" "next in localvars_after_alloca()"
778 # Print each arg as a double check to see if we can print
779 # them here as well as with backtrace.
781 gdb_test "print c" " = 97 'a'" "print c in localvars_after_alloca"
782 gdb_test "print s" " = 1" "print s in localvars_after_alloca"
783 gdb_test "print i" " = 2" "print i in localvars_after_alloca"
784 gdb_test "print l" " = 3" "print l in localvars_after_alloca"
786 gdb_test "backtrace 8" "#0.*localvars_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" "backtrace after alloca"
787 gdb_stop_suppressing_tests;
790 proc call_after_alloca { } {
796 if { ! [ runto call_after_alloca_subr ] } then { gdb_suppress_tests; }
798 # Print each arg as a double check to see if we can print
799 # them here as well as with backtrace.
801 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
802 gdb_test "print c" " = 97 'a'" "print c in call_after_alloca"
803 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
804 gdb_test "print s" " = 1" "print s in call_after_alloca"
805 gdb_test "print i" " = 2" "print i in call_after_alloca"
806 gdb_test "print l" " = 3" "print l in call_after_alloca"
808 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
809 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"
810 gdb_stop_suppressing_tests;
814 # Test for accessing local stack variables, backtraces, finish,
815 # and finally stepping into indirect calls. The point is that on the PA
816 # these use a funky `dyncall' mechanism which GDB needs to know about.
818 proc localvars_in_indirect_call { } {
824 # Can not use "runto call0a" as call0a is called several times
825 # during single run. Instead stop in a marker function and
826 # take control from there.
827 if { ! [ runto marker_indirect_call ] } then { gdb_suppress_tests; }
829 # break on the next call to call0a, then delete all the breakpoints
831 gdb_breakpoint call0a
835 # Print each arg as a double check to see if we can print
836 # them here as well as with backtrace.
838 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
839 gdb_test "print c" " = 97 'a'" "print c in localvars_in_indirect_call"
840 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
841 gdb_test "print s" " = 1" "print s in localvars_in_indirect_call"
842 gdb_test "print i" " = 2" "print i in localvars_in_indirect_call"
843 gdb_test "print l" " = 3" "print l in localvars_in_indirect_call"
845 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
846 gdb_test "backtrace 8" \
847 "#0.*call0a \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" \
848 "backtrace in indirectly called function"
851 # "finish" brings us back to main. We then will try to step through
852 # the second indirect call.
853 # On some targets (e.g. m68k) gdb will stop from the finish in midline
854 # of the first indirect call. This is due to stack adjustment instructions
855 # after the indirect call. In these cases we will step till we hit the
856 # second indirect call.
861 -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$gdb_prompt $" {
865 -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$gdb_prompt $" {
866 pass "finish from indirectly called function"
868 -re ".*$gdb_prompt $" {
869 fail "finish from indirectly called function"
872 default { fail "finish from indirectly called function" ; gdb_suppress_tests; }
875 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
876 gdb_test "step" "call0a \\(c=97 'a', s=1, i=2, l=3\\).*" \
877 "stepping into indirectly called function"
878 gdb_stop_suppressing_tests;
882 # Test for stepping into indirect calls which may have trampolines (possibly
883 # cascaded) on both the call path and the gdb_suppress_tests; path.
884 # to handle trampolines.
886 proc test_stepping_over_trampolines { } {
891 # Stop in a marker function and take control from there.
892 if { ! [ runto marker_call_with_trampolines ] } then { gdb_suppress_tests; }
894 # Cater for gdb stopping in midline, see comment for finish above.
897 -re "marker_call_with_trampolines ..;.*$gdb_prompt $" {
901 -re "pointer_to_call_with_trampolines.*$gdb_prompt $" {
902 pass "finish from marker_call_with_trampolines"
904 -re ".*$gdb_prompt $" {
905 fail "finish from marker_call_with_trampolines"
907 default { fail "finish from marker_call_with_trampolines" ; gdb_suppress_tests; }
910 # Try to step into the target function.
911 gdb_test "step" "call_with_trampolines \\(d1=5\\).*" \
912 "stepping into function called with trampolines"
914 # Make we can backtrace and the argument looks correct. */
915 gdb_test "backtrace 8" "#0.*call_with_trampolines \\(d1=5\\).*1.*main.*" \
916 "backtrace through call with trampolines"
918 # Make sure we can get back to main.
919 # Stepping back to main might stop again after the gdb_suppress_tests; statement
920 # or immediately transfer control back to main if optimizations
924 -re "main .* at.*$gdb_prompt $" {
925 pass "stepping back to main from function called with trampolines" ;
927 -re "\}.*End of call_with_trampolines.*$gdb_prompt $" {
931 -re ".*$gdb_prompt $" {
932 fail "stepping back to main from function called with trampolines"
934 default { fail "stepping back to main from function called with trampolines" ; gdb_suppress_tests; }
936 gdb_stop_suppressing_tests;
939 # Start with a fresh gdb.
943 gdb_reinitialize_dir $srcdir/$subdir
946 if [istarget "mips*tx39-*"] {
948 } elseif [istarget "hppa*-hp-hpux*"] then {
954 # Determine expected output for unsigned long variables,
955 # the output varies with sizeof (unsigned long).
957 set target_sizeof_long 4
958 send_gdb "print sizeof (long)\n"
960 -re ".\[0-9\]* = 4.*$gdb_prompt $" { }
961 -re ".\[0-9\]* = 8.*$gdb_prompt $" { set target_sizeof_long 8 }
962 -re ".*$gdb_prompt $" {
963 fail "getting sizeof long"
965 default { fail "(timeout) getting sizeof long" }
968 set target_sizeof_int 4
969 send_gdb "print sizeof (int)\n"
971 -re ".\[0-9\]* = 2.*$gdb_prompt $" { set target_sizeof_int 2 }
972 -re ".\[0-9\]* = 4.*$gdb_prompt $" { }
973 -re ".\[0-9\]* = 8.*$gdb_prompt $" { set target_sizeof_int 8 }
974 -re ".*$gdb_prompt $" {
975 fail "getting sizeof unsigned long"
977 default { fail "(timeout) getting sizeof int" }
980 set target_bigendian_p 1
981 send_gdb "show endian\n"
983 -re ".*little endian.*$gdb_prompt $" { set target_bigendian_p 0 }
984 -re ".*big endian.*$gdb_prompt $" { }
985 -re ".*$gdb_prompt $" {
986 fail "getting target endian"
988 default { fail "(timeout) getting target endian" }
995 unsigned_integral_args
997 float_and_integral_args
1001 structs_by_reference
1009 recursive_structs_by_value
1011 localvars_after_alloca
1015 localvars_in_indirect_call
1017 test_stepping_over_trampolines