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