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