]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/funcargs.exp
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[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 perror "Couldn't compile ${srcfile}"
34 return -1
35 }
36
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}] {
40 return -1;
41 }
42
43 #
44 # Locate actual args; integral types.
45 #
46
47 proc integral_args {} {
48 global gdb_prompt
49 global det_file
50 global gcc_compiled
51
52 delete_breakpoints
53
54 gdb_breakpoint call0a
55 gdb_breakpoint call0b
56 gdb_breakpoint call0c
57 gdb_breakpoint call0d
58 gdb_breakpoint call0e
59
60 # Run; should stop at call0a and print actual arguments.
61 # The a29k fails all of these tests, perhaps because the prologue
62 # code is broken.
63 setup_xfail "a29k-*-udi"
64 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
65 gdb_run_cmd
66 gdb_expect {
67 -re ".* call0a \\(c=97 'a', s=1, i=2, l=3\\) .*$gdb_prompt $" {
68 pass "run to call0a"
69 }
70 -re "$gdb_prompt $" { fail "run to call0a" ; gdb_suppress_tests }
71 timeout { fail "(timeout) run to call0a" ; gdb_suppress_tests }
72 }
73
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"
80
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"] {
83 gdb_suppress_tests;
84 }
85
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"] {
88 gdb_suppress_tests;
89 }
90
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";] {
93 gdb_suppress_tests;
94 }
95
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" ] {
98 gdb_suppress_tests;
99 }
100 gdb_stop_suppressing_tests;
101 }
102
103 #
104 # Locate actual args; unsigned integral types.
105 #
106
107 proc unsigned_integral_args {} {
108 global gdb_prompt
109 global det_file
110 global gcc_compiled
111
112 delete_breakpoints
113
114 gdb_breakpoint call1a;
115 gdb_breakpoint call1b;
116 gdb_breakpoint call1c;
117 gdb_breakpoint call1d;
118 gdb_breakpoint call1e;
119
120 # Run; should stop at call1a and print actual arguments.
121 # The a29k fails all of these tests, perhaps because the prologue
122 # code is broken.
123 setup_xfail "a29k-*-udi"
124 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
125 gdb_run_cmd
126 gdb_expect {
127 -re ".* call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*$gdb_prompt $" {
128 pass "run to call1a"
129 }
130 -re "$gdb_prompt $" { fail "run to call1a" ; gdb_suppress_tests; }
131 timeout { fail "(timeout) run to call1a" ; gdb_suppress_tests; }
132 }
133
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"
140
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"] {
143 gdb_suppress_tests;
144 }
145
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"] {
148 gdb_suppress_tests;
149 }
150
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"] {
153 gdb_suppress_tests;
154 }
155
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"] {
158 gdb_suppress_tests;
159 }
160 gdb_stop_suppressing_tests;
161 }
162
163 #
164 # Locate actual args; integrals mixed with floating point.
165 #
166
167 proc float_and_integral_args {} {
168 global gdb_prompt
169 global det_file
170 global gcc_compiled
171
172 delete_breakpoints
173
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
182
183 # Run; should stop at call2a and print actual arguments.
184
185 setup_xfail "i960-*-*" 1813
186 # The a29k fails all of these tests, perhaps because the prologue
187 # code is broken.
188 setup_xfail "a29k-*-udi"
189 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" }
190 gdb_run_cmd
191 gdb_expect {
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; }
195 }
196
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"
206
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"] {
211 gdb_suppress_tests;
212 }
213
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"] {
216 gdb_suppress_tests;
217 }
218
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"] {
221 gdb_suppress_tests;
222 }
223
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"] {
226 gdb_suppress_tests;
227 }
228
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"] {
231 gdb_suppress_tests;
232 }
233
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"] {
236 gdb_suppress_tests;
237 }
238
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"] {
241 gdb_suppress_tests;
242 }
243
244 # monitor only allows 8 breakpoints; w89k board allows 10, so
245 # break them up into two groups.
246 delete_breakpoints
247 gdb_breakpoint call2i
248
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"] {
251 gdb_suppress_tests;
252 }
253 gdb_stop_suppressing_tests;
254 }
255
256 #
257 # Locate actual args; dereference pointers to ints and floats.
258 #
259
260 proc pointer_args {} {
261 global gdb_prompt
262 global hex
263 global det_file
264
265 delete_breakpoints
266
267 gdb_breakpoint call3a
268 gdb_breakpoint call3b
269 gdb_breakpoint call3c
270
271 # Run; should stop at call3a and print actual arguments.
272 # Try dereferencing the arguments.
273
274 # The a29k fails all of these tests, perhaps because the prologue
275 # code is broken.
276 setup_xfail "a29k-*-udi"
277 gdb_run_cmd
278 gdb_expect {
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; }
282 }
283
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"
288
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"] {
292 gdb_suppress_tests;
293 }
294
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"
299
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"] {
303 gdb_suppress_tests;
304 }
305
306 gdb_test "print *fp" ".* = 4"
307 gdb_test "print *dp" ".* = 5"
308
309 # pass "locate actual args, pointer types"
310 gdb_stop_suppressing_tests;
311 }
312
313 #
314 # Locate actual args; structures and unions passed by reference.
315 #
316
317 proc structs_by_reference {} {
318 global gdb_prompt
319 global hex
320 global det_file
321
322 delete_breakpoints
323
324 gdb_breakpoint call4a
325 gdb_breakpoint call4b
326
327 # Run; should stop at call4a and print actual arguments.
328 # Try dereferencing the arguments.
329
330 # The a29k fails all of these tests, perhaps because the prologue
331 # code is broken.
332 setup_xfail "a29k-*-udi"
333 gdb_run_cmd
334 gdb_expect {
335 -re ".* call4a \\(stp=$hex\\) .*$gdb_prompt $" {
336 pass "run to call4a"
337 }
338 -re "$gdb_prompt $" { fail "run to call4a" ; gdb_suppress_tests; }
339 timeout { fail "(timeout) run to call4a" ; gdb_suppress_tests; }
340 }
341
342 gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}"
343
344 # Continue; should stop at call4b and print actual arguments.
345 # Try dereferencing the arguments.
346
347 gdb_test "cont" ".* call4b \\(unp=$hex\\) .*" "continue to call4b"
348
349 # sizeof int != sizeof long
350 if [target_info exists gdb,short_int] {
351 setup_xfail "*-*-*"
352 }
353 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}"
354
355 pass "locate actual args, structs/unions passed by reference"
356 gdb_stop_suppressing_tests;
357 }
358
359 #
360 # Locate actual args; structures and unions passed by value.
361 #
362
363 proc structs_by_value {} {
364 global gdb_prompt
365 global hex
366 global det_file
367
368 delete_breakpoints
369
370 gdb_breakpoint call5a
371 gdb_breakpoint call5b
372
373 # Run; should stop at call5a and print actual arguments.
374 # Try dereferencing the arguments.
375
376 # The a29k fails all of these tests, perhaps because the prologue
377 # code is broken.
378 setup_xfail "a29k-*-udi"
379 gdb_run_cmd
380 gdb_expect {
381 -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$gdb_prompt $" {
382 pass "run to call5a"
383 }
384 -re "$gdb_prompt $" { fail "run to call5a" ; gdb_suppress_tests; }
385 timeout { fail "(timeout) run to call5a" ; gdb_suppress_tests; }
386 }
387
388 gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}"
389
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] {
394 setup_xfail "*-*-*"
395 }
396 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \
397 "continue to call5b"
398
399 # sizeof int != sizeof long
400 if [target_info exists gdb,short_int] {
401 setup_xfail "*-*-*"
402 }
403 gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}"
404 gdb_stop_suppressing_tests;
405 }
406
407 #
408 # Locate actual args; discard, shuffle, and call
409 #
410
411 proc discard_and_shuffle {} {
412 global gdb_prompt
413 global hex
414 global decimal
415 global det_file
416 global gcc_compiled
417
418 delete_breakpoints
419
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
428
429 # Run; should stop at call6a and print actual arguments.
430 # Print backtrace.
431
432 # The a29k fails all of these tests, perhaps because the prologue
433 # code is broken.
434 setup_xfail "a29k-*-udi"
435 gdb_run_cmd
436 gdb_expect {
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; }
440 }
441
442 setup_xfail "rs6000-*-*"
443
444 if {!$gcc_compiled} {
445 setup_xfail "mips-sgi-irix5*"
446 }
447
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"] {
449 gdb_suppress_tests;
450 }
451
452 # Continue; should stop at call6b and print actual arguments.
453 # Print backtrace.
454
455 gdb_continue call6b
456
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"] {
458 gdb_suppress_tests;
459 }
460
461 # Continue; should stop at call6c and print actual arguments.
462 # Print backtrace.
463
464 gdb_continue call6c
465
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"] {
467 gdb_suppress_tests;
468 }
469 # Continue; should stop at call6d and print actual arguments.
470 # Print backtrace.
471
472 gdb_continue call6d
473
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"] {
475 gdb_suppress_tests;
476 }
477
478 # Continue; should stop at call6e and print actual arguments.
479 # Print backtrace.
480
481 gdb_continue call6e
482
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"] {
484 gdb_suppress_tests;
485 }
486
487 # Continue; should stop at call6f and print actual arguments.
488 # Print backtrace.
489
490 gdb_continue call6f
491
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"] {
493 gdb_suppress_tests;
494 }
495
496 # Continue; should stop at call6g and print actual arguments.
497 # Print backtrace.
498
499 gdb_continue call6g
500
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"] {
502 gdb_suppress_tests;
503 }
504
505 # Continue; should stop at call6h and print actual arguments.
506 # Print backtrace.
507
508 gdb_continue call6h
509
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"] {
511 gdb_suppress_tests;
512 }
513
514 # monitor only allows 8 breakpoints; w89k board allows 10, so
515 # break them up into two groups.
516 delete_breakpoints
517 gdb_breakpoint call6i
518 gdb_breakpoint call6j
519 gdb_breakpoint call6k
520
521 # Continue; should stop at call6i and print actual arguments.
522 # Print backtrace.
523
524 gdb_continue call6i
525
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"] {
527 gdb_suppress_tests;
528 }
529
530 # Continue; should stop at call6j and print actual arguments.
531 # Print backtrace.
532
533 gdb_continue call6j
534
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"] {
536 gdb_suppress_tests;
537 }
538
539 # Continue; should stop at call6k and print actual arguments.
540 # Print backtrace.
541 # This fails on i960-*-vxworks because gdb gets confused by
542 # breakpoints on adjacent instructions.
543 setup_xfail "i960-*-vxworks" 1786
544 gdb_continue call6k
545
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"] {
547 gdb_suppress_tests;
548 }
549 gdb_stop_suppressing_tests;
550 }
551
552
553 #
554 # Locate actual args; shuffle round robin and call
555 #
556
557 proc shuffle_round_robin {} {
558 global gdb_prompt
559 global hex
560 global decimal
561 global det_file
562 global gcc_compiled
563
564 delete_breakpoints
565
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
574
575 # Run; should stop at call7a and print actual arguments.
576 # Print backtrace.
577
578 # The a29k fails all of these tests, perhaps because the prologue
579 # code is broken.
580 setup_xfail "a29k-*-udi"
581 gdb_run_cmd
582 gdb_expect {
583 -re ".*Breakpoint $decimal, call7a .*$gdb_prompt $" {
584 pass "run to call7a"
585 }
586 -re "$gdb_prompt $" { fail "run to call7a" ; gdb_suppress_tests; }
587 timeout { fail "(timeout) run to call7a" ; gdb_suppress_tests; }
588 }
589
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"
593
594 # Continue; should stop at call7b and print actual arguments.
595 # Print backtrace.
596
597 gdb_continue call7b
598
599 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
600
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"
602
603 # Continue; should stop at call7c and print actual arguments.
604 # Print backtrace.
605
606 gdb_continue call7c
607
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"
609
610 # Continue; should stop at call7d and print actual arguments.
611 # Print backtrace.
612
613 gdb_continue call7d
614
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"
616
617 gdb_continue call7e
618
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"
620
621 # Continue; should stop at call7f and print actual arguments.
622 # Print backtrace.
623
624 gdb_continue call7f
625
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"
627
628 # Continue; should stop at call7g and print actual arguments.
629 # Print backtrace.
630
631 gdb_continue call7g
632
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"
634
635 gdb_continue call7h
636
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"
638
639 # monitor only allows 8 breakpoints; w89k board allows 10, so
640 # break them up into two groups.
641 delete_breakpoints
642 gdb_breakpoint call7i
643 gdb_breakpoint call7j
644 gdb_breakpoint call7k
645
646 # Continue; should stop at call7i and print actual arguments.
647 # Print backtrace.
648
649 gdb_continue call7i
650
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"
652
653 # Continue; should stop at call7j and print actual arguments.
654 # Print backtrace.
655
656 gdb_continue call7j
657
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"
659
660 # Continue; should stop at call7k and print actual arguments.
661 # Print backtrace.
662
663 gdb_continue call7k
664
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;
668 }
669
670 #
671 # Locate actual args; recursive passing of structs by value
672 #
673
674 proc recursive_structs_by_value {} {
675 global gdb_prompt
676 global hex
677 global decimal
678 global det_file
679
680 delete_breakpoints
681
682 gdb_breakpoint hitbottom
683
684 # Run; should stop at hitbottom and print actual arguments.
685 # Print backtrace.
686 gdb_run_cmd
687 gdb_expect {
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; }
691 }
692
693 if ![istarget sparclet-*-*] {
694 # The a29k fails all of these tests, perhaps because the prologue
695 # code is broken.
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"
698 } else {
699 fail "recursive passing of structs by value (sparclet)"
700 }
701 gdb_stop_suppressing_tests;
702 }
703
704 proc funcargs_reload { } {
705 global objdir
706 global subdir
707 global binfile
708 global srcdir
709
710 if [istarget "mips-idt-*"] {
711 # Restart because IDT/SIM runs out of file descriptors.
712 gdb_exit
713 gdb_start
714 gdb_reinitialize_dir $srcdir/$subdir
715 gdb_load ${binfile}
716 }
717 }
718
719 #
720 # Test for accessing local stack variables in functions which call alloca
721 #
722 proc localvars_after_alloca { } {
723 global gdb_prompt
724 global hex
725 global decimal
726 global gcc_compiled
727
728 if { ! [ runto localvars_after_alloca ] } then { gdb_suppress_tests; }
729
730 # Print each arg as a double check to see if we can print
731 # them here as well as with backtrace.
732
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"
739
740 # Lame regexp.
741 gdb_test "next" ".*" "next in localvars_after_alloca()"
742
743 # Print each arg as a double check to see if we can print
744 # them here as well as with backtrace.
745
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"
750
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;
753 }
754
755 proc call_after_alloca { } {
756 global gdb_prompt
757 global hex
758 global decimal
759 global gcc_compiled
760
761 if { ! [ runto call_after_alloca_subr ] } then { gdb_suppress_tests; }
762
763 # Print each arg as a double check to see if we can print
764 # them here as well as with backtrace.
765
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"
772
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;
776 }
777
778 #
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.
782 #
783 proc localvars_in_indirect_call { } {
784 global gdb_prompt
785 global hex
786 global decimal
787 global gcc_compiled
788
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; }
793
794 # break on the next call to call0a, then delete all the breakpoints
795 # and start testing.
796 gdb_breakpoint call0a
797 gdb_continue call0a
798 delete_breakpoints
799
800 # Print each arg as a double check to see if we can print
801 # them here as well as with backtrace.
802
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"
809
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"
814
815 #
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.
822 #
823
824 send_gdb "finish\n"
825 gdb_expect {
826 -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$gdb_prompt $" {
827 send_gdb "step\n"
828 exp_continue
829 }
830 -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$gdb_prompt $" {
831 pass "finish from indirectly called function"
832 }
833 -re ".*$gdb_prompt $" {
834 fail "finish from indirectly called function"
835 gdb_suppress_tests;
836 }
837 default { fail "finish from indirectly called function" ; gdb_suppress_tests; }
838 }
839
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;
844 }
845
846 # Start with a fresh gdb.
847 #
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.
851 #
852 proc test_stepping_over_trampolines { } {
853 global gdb_prompt
854 global hex
855 global decimal
856
857 # Stop in a marker function and take control from there.
858 if { ! [ runto marker_call_with_trampolines ] } then { gdb_suppress_tests; }
859
860 # Cater for gdb stopping in midline, see comment for finish above.
861 send_gdb "finish\n"
862 gdb_expect {
863 -re "marker_call_with_trampolines ..;.*$gdb_prompt $" {
864 send_gdb "step\n"
865 exp_continue
866 }
867 -re "pointer_to_call_with_trampolines.*$gdb_prompt $" {
868 pass "finish from marker_call_with_trampolines"
869 }
870 -re ".*$gdb_prompt $" {
871 fail "finish from marker_call_with_trampolines"
872 }
873 default { fail "finish from marker_call_with_trampolines" ; gdb_suppress_tests; }
874 }
875
876 # Try to step into the target function.
877 gdb_test "step" "call_with_trampolines \\(d1=5\\).*" \
878 "stepping into function called with trampolines"
879
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"
883
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
887 # are performed.
888 send_gdb "step\n"
889 gdb_expect {
890 -re "main .* at.*$gdb_prompt $" {
891 pass "stepping back to main from function called with trampolines" ;
892 }
893 -re "\}.*End of call_with_trampolines.*$gdb_prompt $" {
894 send_gdb "step\n"
895 exp_continue
896 }
897 -re ".*$gdb_prompt $" {
898 fail "stepping back to main from function called with trampolines"
899 }
900 default { fail "stepping back to main from function called with trampolines" ; gdb_suppress_tests; }
901 }
902 gdb_stop_suppressing_tests;
903 }
904
905 # Start with a fresh gdb.
906
907 gdb_exit
908 gdb_start
909 gdb_reinitialize_dir $srcdir/$subdir
910 gdb_load ${binfile}
911
912 set timeout 60
913
914 integral_args
915 funcargs_reload
916 unsigned_integral_args
917 funcargs_reload
918 float_and_integral_args
919 funcargs_reload
920 pointer_args
921 funcargs_reload
922 structs_by_reference
923 funcargs_reload
924 structs_by_value
925 funcargs_reload
926 discard_and_shuffle
927 funcargs_reload
928 shuffle_round_robin
929 funcargs_reload
930 recursive_structs_by_value
931 funcargs_reload
932 localvars_after_alloca
933 funcargs_reload
934 call_after_alloca
935 funcargs_reload
936 localvars_in_indirect_call
937 funcargs_reload
938 test_stepping_over_trampolines