]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/funcargs.exp
e6245dcfce50453810570c82af8891739ba9864c
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / funcargs.exp
1 # Copyright (C) 1992, 1994, 1995, 1997 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Fred Fish. (fnf@cygnus.com)
21
22 if $tracelevel {
23 strace $tracelevel
24 }
25
26 set prms_id 0
27 set bug_id 0
28
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."
34 }
35
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}] {
39 return -1;
40 }
41
42 #
43 # Locate actual args; integral types.
44 #
45
46 proc integral_args {} {
47 global gdb_prompt
48 global det_file
49 global gcc_compiled
50
51 delete_breakpoints
52
53 gdb_breakpoint call0a
54 gdb_breakpoint call0b
55 gdb_breakpoint call0c
56 gdb_breakpoint call0d
57 gdb_breakpoint call0e
58
59 # Run; should stop at call0a and print actual arguments.
60 # The a29k fails all of these tests, perhaps because the prologue
61 # code is broken.
62 setup_xfail "a29k-*-udi"
63 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
64 gdb_run_cmd
65 gdb_expect {
66 -re ".* call0a \\(c=97 'a', s=1, i=2, l=3\\) .*$gdb_prompt $" {
67 pass "run to call0a"
68 }
69 -re "$gdb_prompt $" { fail "run to call0a" ; gdb_suppress_tests }
70 timeout { fail "(timeout) run to call0a" ; gdb_suppress_tests }
71 }
72
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"
79
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"] {
82 gdb_suppress_tests;
83 }
84
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"] {
87 gdb_suppress_tests;
88 }
89
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";] {
92 gdb_suppress_tests;
93 }
94
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" ] {
97 gdb_suppress_tests;
98 }
99 gdb_stop_suppressing_tests;
100 }
101
102 #
103 # Locate actual args; unsigned integral types.
104 #
105
106 proc unsigned_integral_args {} {
107 global gdb_prompt
108 global det_file
109 global gcc_compiled
110
111 delete_breakpoints
112
113 gdb_breakpoint call1a;
114 gdb_breakpoint call1b;
115 gdb_breakpoint call1c;
116 gdb_breakpoint call1d;
117 gdb_breakpoint call1e;
118
119 # Run; should stop at call1a and print actual arguments.
120 # The a29k fails all of these tests, perhaps because the prologue
121 # code is broken.
122 setup_xfail "a29k-*-udi"
123 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
124 gdb_run_cmd
125 gdb_expect {
126 -re ".* call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*$gdb_prompt $" {
127 pass "run to call1a"
128 }
129 -re "$gdb_prompt $" { fail "run to call1a" ; gdb_suppress_tests; }
130 timeout { fail "(timeout) run to call1a" ; gdb_suppress_tests; }
131 }
132
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"
139
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"] {
142 gdb_suppress_tests;
143 }
144
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"] {
147 gdb_suppress_tests;
148 }
149
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"] {
152 gdb_suppress_tests;
153 }
154
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"] {
157 gdb_suppress_tests;
158 }
159 gdb_stop_suppressing_tests;
160 }
161
162 #
163 # Locate actual args; integrals mixed with floating point.
164 #
165
166 proc float_and_integral_args {} {
167 global gdb_prompt
168 global det_file
169 global gcc_compiled
170
171 delete_breakpoints
172
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
181
182 # Run; should stop at call2a and print actual arguments.
183
184 setup_xfail "i960-*-*" 1813
185 # The a29k fails all of these tests, perhaps because the prologue
186 # code is broken.
187 setup_xfail "a29k-*-udi"
188 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" }
189 gdb_run_cmd
190 gdb_expect {
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; }
194 }
195
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"
205
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"] {
210 gdb_suppress_tests;
211 }
212
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"] {
215 gdb_suppress_tests;
216 }
217
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"] {
220 gdb_suppress_tests;
221 }
222
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"] {
225 gdb_suppress_tests;
226 }
227
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"] {
230 gdb_suppress_tests;
231 }
232
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"] {
235 gdb_suppress_tests;
236 }
237
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"] {
240 gdb_suppress_tests;
241 }
242
243 # monitor only allows 8 breakpoints; w89k board allows 10, so
244 # break them up into two groups.
245 delete_breakpoints
246 gdb_breakpoint call2i
247
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"] {
250 gdb_suppress_tests;
251 }
252 gdb_stop_suppressing_tests;
253 }
254
255 #
256 # Locate actual args; dereference pointers to ints and floats.
257 #
258
259 proc pointer_args {} {
260 global gdb_prompt
261 global hex
262 global det_file
263
264 delete_breakpoints
265
266 gdb_breakpoint call3a
267 gdb_breakpoint call3b
268 gdb_breakpoint call3c
269
270 # Run; should stop at call3a and print actual arguments.
271 # Try dereferencing the arguments.
272
273 # The a29k fails all of these tests, perhaps because the prologue
274 # code is broken.
275 setup_xfail "a29k-*-udi"
276 gdb_run_cmd
277 gdb_expect {
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; }
281 }
282
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"
287
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"] {
291 gdb_suppress_tests;
292 }
293
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"
298
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"] {
302 gdb_suppress_tests;
303 }
304
305 gdb_test "print *fp" ".* = 4"
306 gdb_test "print *dp" ".* = 5"
307
308 # pass "locate actual args, pointer types"
309 gdb_stop_suppressing_tests;
310 }
311
312 #
313 # Locate actual args; structures and unions passed by reference.
314 #
315
316 proc structs_by_reference {} {
317 global gdb_prompt
318 global hex
319 global det_file
320 global target_sizeof_int
321 global target_sizeof_long
322 global target_bigendian_p
323
324 delete_breakpoints
325
326 gdb_breakpoint call4a
327 gdb_breakpoint call4b
328
329 # Run; should stop at call4a and print actual arguments.
330 # Try dereferencing the arguments.
331
332 # The a29k fails all of these tests, perhaps because the prologue
333 # code is broken.
334 setup_xfail "a29k-*-udi"
335 gdb_run_cmd
336 gdb_expect {
337 -re ".* call4a \\(stp=$hex\\) .*$gdb_prompt $" {
338 pass "run to call4a"
339 }
340 -re "$gdb_prompt $" { fail "run to call4a" ; gdb_suppress_tests; }
341 timeout { fail "(timeout) run to call4a" ; gdb_suppress_tests; }
342 }
343
344 gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}"
345
346 # Continue; should stop at call4b and print actual arguments.
347
348 gdb_test "cont" ".* call4b \\(unp=$hex\\) .*" "continue to call4b"
349
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)"
363 } else {
364 fail "print *unp (unknown case)"
365 }
366
367 pass "locate actual args, structs/unions passed by reference"
368 gdb_stop_suppressing_tests;
369 }
370
371 #
372 # Locate actual args; structures and unions passed by value.
373 #
374
375 proc structs_by_value {} {
376 global gdb_prompt
377 global hex
378 global det_file
379 global target_sizeof_int
380 global target_sizeof_long
381 global target_bigendian_p
382
383 delete_breakpoints
384
385 gdb_breakpoint call5a
386 gdb_breakpoint call5b
387
388 # Run; should stop at call5a and print actual arguments.
389 # Try dereferencing the arguments.
390
391 # The a29k fails all of these tests, perhaps because the prologue
392 # code is broken.
393 setup_xfail "a29k-*-udi"
394 gdb_run_cmd
395 gdb_expect {
396 -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$gdb_prompt $" {
397 pass "run to call5a"
398 }
399 -re "$gdb_prompt $" { fail "run to call5a" ; gdb_suppress_tests; }
400 timeout { fail "(timeout) run to call5a" ; gdb_suppress_tests; }
401 }
402
403 gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}"
404
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)"
418 } else {
419 fail "continue to call5b (unknown case)"
420 }
421
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)"
435 } else {
436 fail "print un (unknown case)"
437 }
438
439 gdb_stop_suppressing_tests;
440 }
441
442 #
443 # Locate actual args; discard, shuffle, and call
444 #
445
446 proc discard_and_shuffle {} {
447 global gdb_prompt
448 global hex
449 global decimal
450 global det_file
451 global gcc_compiled
452
453 delete_breakpoints
454
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
463
464 # Run; should stop at call6a and print actual arguments.
465 # Print backtrace.
466
467 # The a29k fails all of these tests, perhaps because the prologue
468 # code is broken.
469 setup_xfail "a29k-*-udi"
470 gdb_run_cmd
471 gdb_expect {
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; }
475 }
476
477 setup_xfail "rs6000-*-*"
478
479 if {!$gcc_compiled} {
480 setup_xfail "mips-sgi-irix5*"
481 }
482
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"] {
484 gdb_suppress_tests;
485 }
486
487 # Continue; should stop at call6b and print actual arguments.
488 # Print backtrace.
489
490 gdb_continue call6b
491
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"] {
493 gdb_suppress_tests;
494 }
495
496 # Continue; should stop at call6c and print actual arguments.
497 # Print backtrace.
498
499 gdb_continue call6c
500
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"] {
502 gdb_suppress_tests;
503 }
504 # Continue; should stop at call6d and print actual arguments.
505 # Print backtrace.
506
507 gdb_continue call6d
508
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"] {
510 gdb_suppress_tests;
511 }
512
513 # Continue; should stop at call6e and print actual arguments.
514 # Print backtrace.
515
516 gdb_continue call6e
517
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"] {
519 gdb_suppress_tests;
520 }
521
522 # Continue; should stop at call6f and print actual arguments.
523 # Print backtrace.
524
525 gdb_continue call6f
526
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"] {
528 gdb_suppress_tests;
529 }
530
531 # Continue; should stop at call6g and print actual arguments.
532 # Print backtrace.
533
534 gdb_continue call6g
535
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"] {
537 gdb_suppress_tests;
538 }
539
540 # Continue; should stop at call6h and print actual arguments.
541 # Print backtrace.
542
543 gdb_continue call6h
544
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"] {
546 gdb_suppress_tests;
547 }
548
549 # monitor only allows 8 breakpoints; w89k board allows 10, so
550 # break them up into two groups.
551 delete_breakpoints
552 gdb_breakpoint call6i
553 gdb_breakpoint call6j
554 gdb_breakpoint call6k
555
556 # Continue; should stop at call6i and print actual arguments.
557 # Print backtrace.
558
559 gdb_continue call6i
560
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"] {
562 gdb_suppress_tests;
563 }
564
565 # Continue; should stop at call6j and print actual arguments.
566 # Print backtrace.
567
568 gdb_continue call6j
569
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"] {
571 gdb_suppress_tests;
572 }
573
574 # Continue; should stop at call6k and print actual arguments.
575 # Print backtrace.
576 # This fails on i960-*-vxworks because gdb gets confused by
577 # breakpoints on adjacent instructions.
578 setup_xfail "i960-*-vxworks" 1786
579 gdb_continue call6k
580
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"] {
582 gdb_suppress_tests;
583 }
584 gdb_stop_suppressing_tests;
585 }
586
587
588 #
589 # Locate actual args; shuffle round robin and call
590 #
591
592 proc shuffle_round_robin {} {
593 global gdb_prompt
594 global hex
595 global decimal
596 global det_file
597 global gcc_compiled
598
599 delete_breakpoints
600
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
609
610 # Run; should stop at call7a and print actual arguments.
611 # Print backtrace.
612
613 # The a29k fails all of these tests, perhaps because the prologue
614 # code is broken.
615 setup_xfail "a29k-*-udi"
616 gdb_run_cmd
617 gdb_expect {
618 -re ".*Breakpoint $decimal, call7a .*$gdb_prompt $" {
619 pass "run to call7a"
620 }
621 -re "$gdb_prompt $" { fail "run to call7a" ; gdb_suppress_tests; }
622 timeout { fail "(timeout) run to call7a" ; gdb_suppress_tests; }
623 }
624
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"
628
629 # Continue; should stop at call7b and print actual arguments.
630 # Print backtrace.
631
632 gdb_continue call7b
633
634 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
635
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"
637
638 # Continue; should stop at call7c and print actual arguments.
639 # Print backtrace.
640
641 gdb_continue call7c
642
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"
644
645 # Continue; should stop at call7d and print actual arguments.
646 # Print backtrace.
647
648 gdb_continue call7d
649
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"
651
652 gdb_continue call7e
653
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"
655
656 # Continue; should stop at call7f and print actual arguments.
657 # Print backtrace.
658
659 gdb_continue call7f
660
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"
662
663 # Continue; should stop at call7g and print actual arguments.
664 # Print backtrace.
665
666 gdb_continue call7g
667
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"
669
670 gdb_continue call7h
671
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"
673
674 # monitor only allows 8 breakpoints; w89k board allows 10, so
675 # break them up into two groups.
676 delete_breakpoints
677 gdb_breakpoint call7i
678 gdb_breakpoint call7j
679 gdb_breakpoint call7k
680
681 # Continue; should stop at call7i and print actual arguments.
682 # Print backtrace.
683
684 gdb_continue call7i
685
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"
687
688 # Continue; should stop at call7j and print actual arguments.
689 # Print backtrace.
690
691 gdb_continue call7j
692
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"
694
695 # Continue; should stop at call7k and print actual arguments.
696 # Print backtrace.
697
698 gdb_continue call7k
699
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;
703 }
704
705 #
706 # Locate actual args; recursive passing of structs by value
707 #
708
709 proc recursive_structs_by_value {} {
710 global gdb_prompt
711 global hex
712 global decimal
713 global det_file
714
715 delete_breakpoints
716
717 gdb_breakpoint hitbottom
718
719 # Run; should stop at hitbottom and print actual arguments.
720 # Print backtrace.
721 gdb_run_cmd
722 gdb_expect {
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; }
726 }
727
728 if ![istarget sparclet-*-*] {
729 # The a29k fails all of these tests, perhaps because the prologue
730 # code is broken.
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"
733 } else {
734 fail "recursive passing of structs by value (sparclet)"
735 }
736 gdb_stop_suppressing_tests;
737 }
738
739 proc funcargs_reload { } {
740 global objdir
741 global subdir
742 global binfile
743 global srcdir
744
745 if [istarget "mips-idt-*"] {
746 # Restart because IDT/SIM runs out of file descriptors.
747 gdb_exit
748 gdb_start
749 gdb_reinitialize_dir $srcdir/$subdir
750 gdb_load ${binfile}
751 }
752 }
753
754 #
755 # Test for accessing local stack variables in functions which call alloca
756 #
757 proc localvars_after_alloca { } {
758 global gdb_prompt
759 global hex
760 global decimal
761 global gcc_compiled
762
763 if { ! [ runto localvars_after_alloca ] } then { gdb_suppress_tests; }
764
765 # Print each arg as a double check to see if we can print
766 # them here as well as with backtrace.
767
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"
774
775 # Lame regexp.
776 gdb_test "next" ".*" "next in localvars_after_alloca()"
777
778 # Print each arg as a double check to see if we can print
779 # them here as well as with backtrace.
780
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"
785
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;
788 }
789
790 proc call_after_alloca { } {
791 global gdb_prompt
792 global hex
793 global decimal
794 global gcc_compiled
795
796 if { ! [ runto call_after_alloca_subr ] } then { gdb_suppress_tests; }
797
798 # Print each arg as a double check to see if we can print
799 # them here as well as with backtrace.
800
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"
807
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;
811 }
812
813 #
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.
817 #
818 proc localvars_in_indirect_call { } {
819 global gdb_prompt
820 global hex
821 global decimal
822 global gcc_compiled
823
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; }
828
829 # break on the next call to call0a, then delete all the breakpoints
830 # and start testing.
831 gdb_breakpoint call0a
832 gdb_continue call0a
833 delete_breakpoints
834
835 # Print each arg as a double check to see if we can print
836 # them here as well as with backtrace.
837
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"
844
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"
849
850 #
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.
857 #
858
859 send_gdb "finish\n"
860 gdb_expect {
861 -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$gdb_prompt $" {
862 send_gdb "step\n"
863 exp_continue
864 }
865 -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$gdb_prompt $" {
866 pass "finish from indirectly called function"
867 }
868 -re ".*$gdb_prompt $" {
869 fail "finish from indirectly called function"
870 gdb_suppress_tests;
871 }
872 default { fail "finish from indirectly called function" ; gdb_suppress_tests; }
873 }
874
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;
879 }
880
881 #
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.
885 #
886 proc test_stepping_over_trampolines { } {
887 global gdb_prompt
888 global hex
889 global decimal
890
891 # Stop in a marker function and take control from there.
892 if { ! [ runto marker_call_with_trampolines ] } then { gdb_suppress_tests; }
893
894 # Cater for gdb stopping in midline, see comment for finish above.
895 send_gdb "finish\n"
896 gdb_expect {
897 -re "marker_call_with_trampolines ..;.*$gdb_prompt $" {
898 send_gdb "step\n"
899 exp_continue
900 }
901 -re "pointer_to_call_with_trampolines.*$gdb_prompt $" {
902 pass "finish from marker_call_with_trampolines"
903 }
904 -re ".*$gdb_prompt $" {
905 fail "finish from marker_call_with_trampolines"
906 }
907 default { fail "finish from marker_call_with_trampolines" ; gdb_suppress_tests; }
908 }
909
910 # Try to step into the target function.
911 gdb_test "step" "call_with_trampolines \\(d1=5\\).*" \
912 "stepping into function called with trampolines"
913
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"
917
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
921 # are performed.
922 send_gdb "step\n"
923 gdb_expect {
924 -re "main .* at.*$gdb_prompt $" {
925 pass "stepping back to main from function called with trampolines" ;
926 }
927 -re "\}.*End of call_with_trampolines.*$gdb_prompt $" {
928 send_gdb "step\n"
929 exp_continue
930 }
931 -re ".*$gdb_prompt $" {
932 fail "stepping back to main from function called with trampolines"
933 }
934 default { fail "stepping back to main from function called with trampolines" ; gdb_suppress_tests; }
935 }
936 gdb_stop_suppressing_tests;
937 }
938
939 # Start with a fresh gdb.
940
941 gdb_exit
942 gdb_start
943 gdb_reinitialize_dir $srcdir/$subdir
944 gdb_load ${binfile}
945
946 if [istarget "mips*tx39-*"] {
947 set timeout 300
948 } elseif [istarget "hppa*-hp-hpux*"] then {
949 set timeout 240
950 } else {
951 set timeout 60
952 }
953
954 # Determine expected output for unsigned long variables,
955 # the output varies with sizeof (unsigned long).
956
957 set target_sizeof_long 4
958 send_gdb "print sizeof (long)\n"
959 gdb_expect {
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"
964 }
965 default { fail "(timeout) getting sizeof long" }
966 }
967
968 set target_sizeof_int 4
969 send_gdb "print sizeof (int)\n"
970 gdb_expect {
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"
976 }
977 default { fail "(timeout) getting sizeof int" }
978 }
979
980 set target_bigendian_p 1
981 send_gdb "show endian\n"
982 gdb_expect {
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"
987 }
988 default { fail "(timeout) getting target endian" }
989 }
990
991 # Perform tests
992
993 integral_args
994 funcargs_reload
995 unsigned_integral_args
996 funcargs_reload
997 float_and_integral_args
998 funcargs_reload
999 pointer_args
1000 funcargs_reload
1001 structs_by_reference
1002 funcargs_reload
1003 structs_by_value
1004 funcargs_reload
1005 discard_and_shuffle
1006 funcargs_reload
1007 shuffle_round_robin
1008 funcargs_reload
1009 recursive_structs_by_value
1010 funcargs_reload
1011 localvars_after_alloca
1012 funcargs_reload
1013 call_after_alloca
1014 funcargs_reload
1015 localvars_in_indirect_call
1016 funcargs_reload
1017 test_stepping_over_trampolines