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