]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/funcargs.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / funcargs.exp
1 # Copyright 1992-2022 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 3 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, see <http://www.gnu.org/licenses/>.
15
16 # This file was written by Fred Fish. (fnf@cygnus.com)
17
18
19 standard_testfile
20
21 set compile_flags {debug nowarnings quiet}
22 if [support_complex_tests] {
23 lappend compile_flags "additional_flags=-DTEST_COMPLEX"
24 }
25
26 # Create and source the file that provides information about the compiler
27 # used to compile the test case.
28 if [get_compiler_info] {
29 return -1
30 }
31
32 set skip_float_test [gdb_skip_float_test]
33
34 if {[prepare_for_testing "failed to prepare" $testfile $srcfile $compile_flags]} {
35 return -1
36 }
37
38 #
39 # Locate actual args; integral types.
40 #
41
42 proc integral_args {} {
43 global gdb_prompt
44 global det_file
45 global gcc_compiled
46
47 delete_breakpoints
48
49 gdb_breakpoint call0a
50 gdb_breakpoint call0b
51 gdb_breakpoint call0c
52 gdb_breakpoint call0d
53 gdb_breakpoint call0e
54
55 # Run; should stop at call0a and print actual arguments.
56 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
57 gdb_run_cmd
58 gdb_test "" " call0a \\(c=97 'a', s=1, i=2, l=3\\) .*" "run to call0a"
59
60 # Print each arg as a double check to see if we can print
61 # them here as well as with backtrace.
62 gdb_test "print c" ".* = 97 'a'" "print c after run to call0a"
63 gdb_test "print s" ".* = 1" "print s after run to call0a"
64 gdb_test "print i" ".* = 2" "print i after run to call0a"
65 gdb_test "print l " ".* = 3" "print l after run to call0a"
66
67 # Continue; should stop at call0b and print actual arguments.
68 gdb_test "cont" ".* call0b \\(s=1, i=2, l=3, c=97 'a'\\) .*" "continue to call0b"
69
70 # Continue; should stop at call0c and print actual arguments.
71 gdb_test "cont" ".* call0c \\(i=2, l=3, c=97 'a', s=1\\) .*" "continue to call0c"
72
73 # Continue; should stop at call0d and print actual arguments.
74 gdb_test "cont" ".* call0d \\(l=3, c=97 'a', s=1, i=2\\) .*" "continue to call0d"
75
76 # Continue; should stop at call0e and print actual arguments.
77 gdb_test "cont" ".* call0e \\(c1=97 'a', l=3, c2=97 'a', i=2, c3=97 'a', s=1, c4=97 'a', c5=97 'a'\\) .*" "continue to call0e"
78 }
79
80 #
81 # Locate actual args; unsigned integral types.
82 #
83
84 proc unsigned_integral_args {} {
85 global gdb_prompt
86 global det_file
87 global gcc_compiled
88
89 delete_breakpoints
90
91 gdb_breakpoint call1a
92 gdb_breakpoint call1b
93 gdb_breakpoint call1c
94 gdb_breakpoint call1d
95 gdb_breakpoint call1e
96
97 # Run; should stop at call1a and print actual arguments.
98 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
99 gdb_run_cmd
100 gdb_test "" " call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*" "run to call1a"
101
102 # Print each arg as a double check to see if we can print
103 # them here as well as with backtrace.
104 gdb_test "print uc" ".* = 98 'b'"
105 gdb_test "print us" ".* = 6"
106 gdb_test "print ui" ".* = 7"
107 gdb_test "print ul" ".* = 8"
108
109 # Continue; should stop at call1b and print actual arguments.
110 gdb_test "cont" ".* call1b \\(us=6, ui=7, ul=8, uc=98 'b'\\) .*" "continue to call1b"
111
112 # Continue; should stop at call1c and print actual arguments.
113 gdb_test "cont" ".* call1c \\(ui=7, ul=8, uc=98 'b', us=6\\) .*" "continue to call1c"
114
115 # Continue; should stop at call1d and print actual arguments.
116 gdb_test "cont" ".* call1d \\(ul=8, uc=98 'b', us=6, ui=7\\) .*" "continue to call1d"
117
118 # Continue; should stop at call1e and print actual arguments.
119 gdb_test "cont" ".* call1e \\(uc1=98 'b', ul=8, uc2=98 'b', ui=7, uc3=98 'b', us=6, uc4=98 'b', uc5=98 'b'\\) .*" "continue to call1e"
120 }
121
122 #
123 # Locate actual args; integrals mixed with floating point.
124 #
125
126 proc float_and_integral_args {} {
127 global gdb_prompt
128 global det_file
129 global gcc_compiled
130
131 delete_breakpoints
132
133 gdb_breakpoint call2a
134 gdb_breakpoint call2b
135 gdb_breakpoint call2c
136 gdb_breakpoint call2d
137 gdb_breakpoint call2e
138 gdb_breakpoint call2f
139 gdb_breakpoint call2g
140 gdb_breakpoint call2h
141
142 # Run; should stop at call2a and print actual arguments.
143
144 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
145 gdb_run_cmd
146 set test "run to call2a"
147 gdb_test_multiple "" $test {
148 -re ".* call2a \\(c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$gdb_prompt $" {
149 pass $test
150 }
151 -re ".* call2a \\(c=97 'a', f1=.*, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$gdb_prompt $" {
152 xfail $test
153 }
154 }
155
156 # Print each arg as a double check to see if we can print
157 gdb_test "print c" ".* = 97 'a'" "print c after run to call2a"
158 gdb_test "print f1" ".* = 4" "print f1 after run to call2a"
159 gdb_test "print s" ".* = 1" "print s after run to call2a"
160 gdb_test "print d1" ".* = 5" "print d1 after run to call2a"
161 gdb_test "print i" ".* = 2" "print i after run to call2a"
162 gdb_test "print f2" ".* = 4" "print f2 after run to call2a"
163 gdb_test "print l" ".* = 3" "print l after run to call2a"
164 gdb_test "print d2" ".* = 5" "print d2 after run to call2a"
165
166 setup_xfail "rs6000-*-*"
167 # Continue; should stop at call2b and print actual arguments.
168 gdb_test "cont" ".* call2b \\(f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5, c=97 'a'\\) .*" "continue to call2b"
169
170 # Continue; should stop at call2c and print actual arguments.
171 gdb_test "cont" ".* call2c \\(s=1, d1=5, i=2, f2=4, l=3, d2=5, c=97 'a', f1=4\\) .*" "continue to call2c"
172
173 # Continue; should stop at call2d and print actual arguments.
174 gdb_test "cont" ".* call2d \\(d1=5, i=2, f2=4, l=3, d2=5, c=97 'a', f1=4, s=1\\) .*" "continue to call2d"
175
176 # Continue; should stop at call2e and print actual arguments.
177 gdb_test "cont" ".* call2e \\(i=2, f2=4, l=3, d2=5, c=97 'a', f1=4, s=1, d1=5\\) .*" "continue to call2e"
178
179 # Continue; should stop at call2f and print actual arguments.
180 gdb_test "cont" ".* call2f \\(f2=4, l=3, d2=5, c=97 'a', f1=4, s=1, d1=5, i=2\\) .*" "continue to call2f"
181
182 # Continue; should stop at call2g and print actual arguments.
183 gdb_test "cont" ".* call2g \\(l=3, d2=5, c=97 'a', f1=4, s=1, d1=5, i=2, f2=4\\) .*" "continue to call2g"
184
185 # Continue; should stop at call2h and print actual arguments.
186 gdb_test "cont" ".* call2h \\(d2=5, c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3\\) .*" "continue to call2h"
187
188 # monitor only allows 8 breakpoints; w89k board allows 10, so
189 # break them up into two groups.
190 delete_breakpoints
191 gdb_breakpoint call2i
192
193 # Continue; should stop at call2i and print actual arguments.
194 gdb_test "cont" ".* call2i \\(c1=97 'a', f1=4, c2=97 'a', c3=97 'a', d1=5, c4=97 'a', c5=97 'a', c6=97 'a', f2=4, s=1, c7=97 'a', d2=5\\) .*" "continue to call2i"
195 }
196
197
198 #
199 # Locate actual args; _Complex types.
200 #
201
202 proc complex_args {} {
203 global gdb_prompt
204
205 delete_breakpoints
206
207 gdb_breakpoint callca
208 gdb_breakpoint callcb
209 gdb_breakpoint callcc
210 gdb_breakpoint callcd
211 gdb_breakpoint callce
212 gdb_breakpoint callcf
213
214 # Run; should stop at call1a and print actual arguments.
215 gdb_run_cmd
216 gdb_test "" " callca \\(f1=1 \\+ 2i, f2=1 \\+ 2i, f3=1 \\+ 2i\\) .*" "run to call2a"
217
218 gdb_test "cont" ".* callcb \\(d1=3 \\+ 4i, d2=3 \\+ 4i, d3=3 \\+ 4i\\) .*" "continue to callcb"
219 gdb_test "cont" ".* callcc \\(ld1=5 \\+ 6i, ld2=5 \\+ 6i, ld3=5 \\+ 6i\\) .*" "continue to callcc"
220 gdb_test "cont" ".* callcd \\(fc1=1 \\+ 2i, dc1=3 \\+ 4i, ldc1=5 \\+ 6i\\) .*" "continue to callcd"
221 gdb_test "cont" ".* callce \\(dc1=3 \\+ 4i, ldc1=5 \\+ 6i, fc1=1 \\+ 2i\\) .*" "continue to callce"
222 gdb_test "cont" ".* callcf \\(ldc1=5 \\+ 6i, fc1=1 \\+ 2i, dc1=3 \\+ 4i\\) .*" "continue to callcf"
223 }
224
225
226 #
227 # Locate actual args; _Complex types and integral.
228 #
229 proc complex_integral_args {} {
230 global gdb_prompt
231
232 delete_breakpoints
233
234 gdb_breakpoint callc1a
235 gdb_breakpoint callc1b
236
237 # Run; should stop at call1a and print actual arguments.
238 gdb_run_cmd
239 gdb_test "" " callc1a \\(c=97 'a', s=1, i=2, ui=7, l=3, fc1=1 \\+ 2i, dc1=3 \\+ 4i, ldc1=5 \\+ 6i\\) .*" "run to callc1a"
240
241 gdb_test "cont" ".* callc1b \\(ldc1=5 \\+ 6i\\, c=97 'a', s=1, i=2, fc1=1 \\+ 2i, ui=7, l=3, dc1=3 \\+ 4i\\) .*" "continue to callc1b"
242 }
243
244 #
245 # Locate actual args; _Complex types and integral/float.
246 #
247 proc complex_float_integral_args {} {
248 global gdb_prompt
249
250 delete_breakpoints
251
252 gdb_breakpoint callc2a
253 gdb_breakpoint callc2b
254
255 # Run; should stop at call1a and print actual arguments.
256 gdb_run_cmd
257 gdb_test "" " callc2a \\(c=97 'a', s=1, i=2, ui=7, l=3, f=4, d=5, fc1=1 \\+ 2i, dc1=3 \\+ 4i, ldc1=5 \\+ 6i\\) .*" "run to callc2a"
258
259 gdb_test "cont" ".* callc2b \\(fc1=1 \\+ 2i, c=97 'a', s=1, i=2, ui=7, ldc1=5 \\+ 6i\\, l=3, f=4, d=5, dc1=3 \\+ 4i\\) .*" "continue to callc2b"
260 }
261
262 #
263 # Locate actual args; dereference pointers to ints and floats.
264 #
265
266 proc pointer_args {} {
267 global gdb_prompt
268 global hex
269 global det_file
270
271 delete_breakpoints
272
273 gdb_breakpoint call3a
274 gdb_breakpoint call3b
275 gdb_breakpoint call3c
276
277 # Run; should stop at call3a and print actual arguments.
278 # Try dereferencing the arguments.
279
280 gdb_run_cmd
281 gdb_test "" " call3a \\(cp=$hex <c> \"a.*\", sp=$hex <s>, ip=$hex <i>, lp=$hex <l>\\) .*" "run to call3a"
282
283 gdb_test "print *cp" ".* = 97 'a'"
284 gdb_test "print *sp" ".* = 1"
285 gdb_test "print *ip" ".* = 2"
286 gdb_test "print *lp" ".* = 3"
287
288 # Continue; should stop at call3b and print actual arguments.
289 # Try dereferencing the arguments.
290 gdb_test "cont" ".* call3b \\(ucp=$hex <uc> \"b.*\", usp=$hex <us>, uip=$hex <ui>, ulp=$hex <ul>\\) .*" "continue to call3b"
291
292 gdb_test "print *ucp" ".* = 98 'b'"
293 gdb_test "print *usp" ".* = 6"
294 gdb_test "print *uip" ".* = 7"
295 gdb_test "print *ulp" ".* = 8"
296
297 # Continue; should stop at call3c and print actual arguments.
298 # Try dereferencing the arguments.
299 gdb_test "cont" ".* call3c \\(fp=$hex <f>, dp=$hex <d>\\) .*" "continue to call3c"
300
301 gdb_test "print *fp" ".* = 4"
302 gdb_test "print *dp" ".* = 5"
303 }
304
305 #
306 # Locate actual args; structures and unions passed by reference.
307 #
308
309 proc structs_by_reference {} {
310 global gdb_prompt
311 global hex
312 global det_file
313 global target_sizeof_int
314 global target_sizeof_long
315 global target_bigendian_p
316
317 delete_breakpoints
318
319 gdb_breakpoint call4a
320 gdb_breakpoint call4b
321
322 # Run; should stop at call4a and print actual arguments.
323 # Try dereferencing the arguments.
324
325 gdb_run_cmd
326 gdb_test "" " call4a \\(stp=$hex <st>\\) .*" "run to call4a"
327
328 gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}"
329
330 # Continue; should stop at call4b and print actual arguments.
331
332 gdb_test "cont" ".* call4b \\(unp=$hex <un>\\) .*" "continue to call4b"
333
334 # Try dereferencing the arguments.
335 if { $target_sizeof_long == $target_sizeof_int } {
336 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}" \
337 "print *unp (sizeof long == sizeof int)"
338 } elseif { ! $target_bigendian_p } {
339 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}" \
340 "print *unp (little-endian, sizeof long != sizeof int)"
341 } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } {
342 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 4294967296\}" \
343 "print *unp (big-endian, sizeof long == 8, sizeof int = 4)"
344 } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } {
345 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 65536\}" \
346 "print *unp (big-endian, sizeof long == 4, sizeof int = 2)"
347 } else {
348 fail "print *unp (unknown case)"
349 }
350
351 pass "locate actual args, structs/unions passed by reference"
352 }
353
354 #
355 # Locate actual args; structures and unions passed by value.
356 #
357
358 proc structs_by_value {} {
359 global gdb_prompt
360 global hex
361 global det_file
362 global target_sizeof_int
363 global target_sizeof_long
364 global target_bigendian_p
365
366 delete_breakpoints
367
368 gdb_breakpoint call5a
369 gdb_breakpoint call5b
370
371 # Run; should stop at call5a and print actual arguments.
372 # Try dereferencing the arguments.
373
374 gdb_run_cmd
375 gdb_test "" " call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*" "run to call5a"
376
377 gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}"
378
379 # Continue; should stop at call5b and print actual arguments.
380 if { $target_sizeof_long == $target_sizeof_int } {
381 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \
382 "continue to call5b (sizeof long == sizeof int)"
383 } elseif { ! $target_bigendian_p } {
384 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \
385 "continue to call5b (little-endian, sizeof long != sizeof int)"
386 } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } {
387 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 8589934592\}\\) .*" \
388 "continue to call5b (big-endian, sizeof long == 8, sizeof int = 4)"
389 } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } {
390 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 131072\}\\) .*" \
391 "continue to call5b (big-endian, sizeof long == 4, sizeof int = 2)"
392 } else {
393 fail "continue to call5b (unknown case)"
394 }
395
396 # Try dereferencing the arguments.
397 if { $target_sizeof_long == $target_sizeof_int } {
398 gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}" \
399 "print un (sizeof long == sizeof int)"
400 } elseif { ! $target_bigendian_p } {
401 gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}" \
402 "print un (little-endian, sizeof long != sizeof int)"
403 } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } {
404 gdb_test "print un" ".* = \{u1 = 2, u2 = 8589934592\}" \
405 "print un (big-endian, sizeof long == 8, sizeof int = 4)"
406 } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } {
407 gdb_test "print un" ".* = \{u1 = 2, u2 = 131072\}" \
408 "print un (big-endian, sizeof long == 4, sizeof int = 2)"
409 } else {
410 fail "print un (unknown case)"
411 }
412 }
413
414 #
415 # Locate actual args; discard, shuffle, and call
416 #
417
418 proc discard_and_shuffle {} {
419 global gdb_prompt
420 global hex
421 global decimal
422 global det_file
423 global gcc_compiled
424
425 delete_breakpoints
426
427 gdb_breakpoint call6a
428 gdb_breakpoint call6b
429 gdb_breakpoint call6c
430 gdb_breakpoint call6d
431 gdb_breakpoint call6e
432 gdb_breakpoint call6f
433 gdb_breakpoint call6g
434 gdb_breakpoint call6h
435
436 # Run; should stop at call6a and print actual arguments.
437 # Print backtrace.
438
439 gdb_run_cmd
440 gdb_test "" "Breakpoint $decimal, call6a .*" "run to call6a"
441
442 setup_xfail "rs6000-*-*"
443
444 gdb_test_multiple "backtrace 100" "backtrace from call6a" {
445 -re " call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .* main \\(.*\\) .*$gdb_prompt $" {
446 pass "backtrace from call6a"
447 }
448 -re " call6a \\(c=97 'a', s=1, i=2, l=3, f=.*, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .* main \\(.*\\) .*$gdb_prompt $" {
449 xfail "backtrace from call6a"
450 }
451 }
452
453 # Continue; should stop at call6b and print actual arguments.
454 # Print backtrace.
455
456 gdb_continue call6b
457
458 gdb_test_sequence "backtrace 100" "backtrace from call6b" {
459 "\[\r\n\]#0 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
460 "\[\r\n\]#1 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
461 "\[\r\n\]#2 .* main \\(.*\\) at "
462 }
463
464 # Continue; should stop at call6c and print actual arguments.
465 # Print backtrace.
466
467 gdb_continue call6c
468
469 gdb_test_sequence "backtrace 100" "backtrace from call6c" {
470 "\[\r\n\]#0 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
471 "\[\r\n\]#1 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
472 "\[\r\n\]#2 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
473 "\[\r\n\]#3 .* main \\(.*\\) at "
474 }
475
476 # Continue; should stop at call6d and print actual arguments.
477 # Print backtrace.
478
479 gdb_continue call6d
480
481 gdb_test_sequence "backtrace 100" "backtrace from call6d" {
482 "\[\r\n\]#0 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
483 "\[\r\n\]#1 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
484 "\[\r\n\]#2 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
485 "\[\r\n\]#3 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
486 "\[\r\n\]#4 .* main \\(.*\\) at "
487 }
488
489 # Continue; should stop at call6e and print actual arguments.
490 # Print backtrace.
491
492 gdb_continue call6e
493
494 gdb_test_sequence "backtrace 100" "backtrace from call6e" {
495 "\[\r\n\]#0 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
496 "\[\r\n\]#1 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
497 "\[\r\n\]#2 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
498 "\[\r\n\]#3 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
499 "\[\r\n\]#4 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
500 "\[\r\n\]#5 .* main \\(.*\\) at "
501 }
502
503 # Continue; should stop at call6f and print actual arguments.
504 # Print backtrace.
505
506 gdb_continue call6f
507
508 gdb_test_sequence "backtrace 100" "backtrace from call6f" {
509 "\[\r\n\]#0 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
510 "\[\r\n\]#1 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
511 "\[\r\n\]#2 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
512 "\[\r\n\]#3 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
513 "\[\r\n\]#4 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
514 "\[\r\n\]#5 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
515 "\[\r\n\]#6 .* main \\(.*\\) at "
516 }
517
518 # Continue; should stop at call6g and print actual arguments.
519 # Print backtrace.
520
521 gdb_continue call6g
522
523 gdb_test_sequence "backtrace 100" "backtrace from call6g" {
524 "\[\r\n\]#0 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) "
525 "\[\r\n\]#1 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
526 "\[\r\n\]#2 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
527 "\[\r\n\]#3 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
528 "\[\r\n\]#4 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
529 "\[\r\n\]#5 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
530 "\[\r\n\]#6 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
531 "\[\r\n\]#7 .* main \\(.*\\) at "
532 }
533
534 # Continue; should stop at call6h and print actual arguments.
535 # Print backtrace.
536
537 gdb_continue call6h
538
539 gdb_test_sequence "backtrace 100" "backtrace from call6h" {
540 "\[\r\n\]#0 .* call6h \\(us=6, ui=7, ul=8\\) "
541 "\[\r\n\]#1 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) "
542 "\[\r\n\]#2 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
543 "\[\r\n\]#3 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
544 "\[\r\n\]#4 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
545 "\[\r\n\]#5 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
546 "\[\r\n\]#6 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
547 "\[\r\n\]#7 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
548 "\[\r\n\]#8 .* main \\(.*\\) at "
549 }
550
551 # monitor only allows 8 breakpoints; w89k board allows 10, so
552 # break them up into two groups.
553 delete_breakpoints
554 gdb_breakpoint call6i
555 gdb_breakpoint call6j
556 gdb_breakpoint call6k
557
558 # Continue; should stop at call6i and print actual arguments.
559 # Print backtrace.
560
561 gdb_continue call6i
562
563 gdb_test_sequence "backtrace 100" "backtrace from call6i" {
564 "\[\r\n\]#0 .* call6i \\(ui=7, ul=8\\) "
565 "\[\r\n\]#1 .* call6h \\(us=6, ui=7, ul=8\\) "
566 "\[\r\n\]#2 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) "
567 "\[\r\n\]#3 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
568 "\[\r\n\]#4 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
569 "\[\r\n\]#5 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
570 "\[\r\n\]#6 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
571 "\[\r\n\]#7 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
572 "\[\r\n\]#8 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
573 "\[\r\n\]#9 .* main \\(.*\\) at "
574 }
575
576 # Continue; should stop at call6j and print actual arguments.
577 # Print backtrace.
578
579 gdb_continue call6j
580
581 gdb_test_sequence "backtrace 100" "backtrace from call6j" {
582 "\[\r\n\]#0 .* call6j \\(ul=8\\) "
583 "\[\r\n\]#1 .* call6i \\(ui=7, ul=8\\) "
584 "\[\r\n\]#2 .* call6h \\(us=6, ui=7, ul=8\\) "
585 "\[\r\n\]#3 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) "
586 "\[\r\n\]#4 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
587 "\[\r\n\]#5 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
588 "\[\r\n\]#6 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
589 "\[\r\n\]#7 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
590 "\[\r\n\]#8 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
591 "\[\r\n\]#9 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
592 "\[\r\n\]#10 .* main \\(.*\\) at "
593 }
594
595 # Continue; should stop at call6k and print actual arguments.
596 # Print backtrace.
597 gdb_continue call6k
598
599 gdb_test_sequence "backtrace 100" "backtrace from call6k" {
600 "\[\r\n\]#0 .* call6k \\(\\) "
601 "\[\r\n\]#1 .* call6j \\(ul=8\\) "
602 "\[\r\n\]#2 .* call6i \\(ui=7, ul=8\\) "
603 "\[\r\n\]#3 .* call6h \\(us=6, ui=7, ul=8\\) "
604 "\[\r\n\]#4 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) "
605 "\[\r\n\]#5 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
606 "\[\r\n\]#6 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
607 "\[\r\n\]#7 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
608 "\[\r\n\]#8 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
609 "\[\r\n\]#9 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
610 "\[\r\n\]#10 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) "
611 "\[\r\n\]#11 .* main \\(.*\\) at "
612 }
613 }
614
615
616 #
617 # Locate actual args; shuffle round robin and call
618 #
619
620 proc shuffle_round_robin {} {
621 global gdb_prompt
622 global hex
623 global decimal
624 global det_file
625 global gcc_compiled
626
627 delete_breakpoints
628
629 gdb_breakpoint call7a
630 gdb_breakpoint call7b
631 gdb_breakpoint call7c
632 gdb_breakpoint call7d
633 gdb_breakpoint call7e
634 gdb_breakpoint call7f
635 gdb_breakpoint call7g
636 gdb_breakpoint call7h
637
638 # Run; should stop at call7a and print actual arguments.
639 # Print backtrace.
640
641 gdb_run_cmd
642 gdb_test "" "Breakpoint $decimal, call7a .*" "run to call7a"
643
644 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
645 gdb_test_multiple "backtrace 100" "backtrace from call7a" {
646 -re " call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .* main \\(.*\\) .*$gdb_prompt $" {
647 pass "backtrace from call7a"
648 }
649 -re " call7a \\(c=97 'a', i=2, s=1, l=3, f=.*, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .* main \\(.*\\) .*$gdb_prompt $" {
650 xfail "backtrace from call7a"
651 }
652 }
653
654 # Continue; should stop at call7b and print actual arguments.
655 # Print backtrace.
656
657 gdb_continue call7b
658
659 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
660
661 gdb_test_sequence "backtrace 100" "backtrace from call7b" {
662 "\[\r\n\]#0 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) "
663 "\[\r\n\]#1 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
664 "\[\r\n\]#2 .* main \\(.*\\) at "
665 }
666
667 # Continue; should stop at call7c and print actual arguments.
668 # Print backtrace.
669
670 gdb_continue call7c
671
672 gdb_test_sequence "backtrace 100" "backtrace from call7c" {
673 "\[\r\n\]#0 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) "
674 "\[\r\n\]#1 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) "
675 "\[\r\n\]#2 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
676 "\[\r\n\]#3 .* main \\(.*\\) at "
677 }
678
679 # Continue; should stop at call7d and print actual arguments.
680 # Print backtrace.
681
682 gdb_continue call7d
683
684 gdb_test_sequence "backtrace 100" "backtrace from call7d" {
685 "\[\r\n\]#0 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) "
686 "\[\r\n\]#1 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) "
687 "\[\r\n\]#2 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) "
688 "\[\r\n\]#3 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
689 "\[\r\n\]#4 .* main \\(.*\\) at "
690 }
691
692 gdb_continue call7e
693
694 gdb_test_sequence "backtrace 100" "backtrace from call7e" {
695 "\[\r\n\]#0 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) "
696 "\[\r\n\]#1 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) "
697 "\[\r\n\]#2 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) "
698 "\[\r\n\]#3 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) "
699 "\[\r\n\]#4 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
700 "\[\r\n\]#5 .* main \\(.*\\) at "
701 }
702
703 # Continue; should stop at call7f and print actual arguments.
704 # Print backtrace.
705
706 gdb_continue call7f
707
708 gdb_test_sequence "backtrace 100" "backtrace from call7f" {
709 "\[\r\n\]#0 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) "
710 "\[\r\n\]#1 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) "
711 "\[\r\n\]#2 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) "
712 "\[\r\n\]#3 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) "
713 "\[\r\n\]#4 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) "
714 "\[\r\n\]#5 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
715 "\[\r\n\]#6 .* main \\(.*\\) at "
716 }
717
718 # Continue; should stop at call7g and print actual arguments.
719 # Print backtrace.
720
721 gdb_continue call7g
722
723 gdb_test_sequence "backtrace 100" "backtrace from call7g" {
724 "\[\r\n\]#0 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) "
725 "\[\r\n\]#1 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) "
726 "\[\r\n\]#2 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) "
727 "\[\r\n\]#3 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) "
728 "\[\r\n\]#4 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) "
729 "\[\r\n\]#5 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) "
730 "\[\r\n\]#6 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
731 "\[\r\n\]#7 .* main \\(.*\\) at "
732 }
733
734 gdb_continue call7h
735
736 gdb_test_sequence "backtrace 100" "backtrace from call7h" {
737 "\[\r\n\]#0 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) "
738 "\[\r\n\]#1 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) "
739 "\[\r\n\]#2 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) "
740 "\[\r\n\]#3 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) "
741 "\[\r\n\]#4 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) "
742 "\[\r\n\]#5 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) "
743 "\[\r\n\]#6 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) "
744 "\[\r\n\]#7 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
745 "\[\r\n\]#8 .* main \\(.*\\) at "
746 }
747
748 # monitor only allows 8 breakpoints; w89k board allows 10, so
749 # break them up into two groups.
750 delete_breakpoints
751 gdb_breakpoint call7i
752 gdb_breakpoint call7j
753 gdb_breakpoint call7k
754
755 # Continue; should stop at call7i and print actual arguments.
756 # Print backtrace.
757
758 gdb_continue call7i
759
760 gdb_test_sequence "backtrace 100" "backtrace from call7i" {
761 "\[\r\n\]#0 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) "
762 "\[\r\n\]#1 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) "
763 "\[\r\n\]#2 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) "
764 "\[\r\n\]#3 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) "
765 "\[\r\n\]#4 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) "
766 "\[\r\n\]#5 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) "
767 "\[\r\n\]#6 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) "
768 "\[\r\n\]#7 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) "
769 "\[\r\n\]#8 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
770 "\[\r\n\]#9 .* main \\(.*\\) at "
771 }
772
773 # Continue; should stop at call7j and print actual arguments.
774 # Print backtrace.
775
776 gdb_continue call7j
777
778 gdb_test_sequence "backtrace 100" "backtrace from call7j" {
779 "\[\r\n\]#0 .* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) "
780 "\[\r\n\]#1 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) "
781 "\[\r\n\]#2 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) "
782 "\[\r\n\]#3 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) "
783 "\[\r\n\]#4 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) "
784 "\[\r\n\]#5 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) "
785 "\[\r\n\]#6 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) "
786 "\[\r\n\]#7 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) "
787 "\[\r\n\]#8 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) "
788 "\[\r\n\]#9 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
789 "\[\r\n\]#10 .* main \\(.*\\) at "
790 }
791
792 # Continue; should stop at call7k and print actual arguments.
793 # Print backtrace.
794
795 gdb_continue call7k
796
797 gdb_test_sequence "backtrace 100" "backtrace from call7k" {
798 "\[\r\n\]#0 .* call7k \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
799 "\[\r\n\]#1 .* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) "
800 "\[\r\n\]#2 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) "
801 "\[\r\n\]#3 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) "
802 "\[\r\n\]#4 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) "
803 "\[\r\n\]#5 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) "
804 "\[\r\n\]#6 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) "
805 "\[\r\n\]#7 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) "
806 "\[\r\n\]#8 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) "
807 "\[\r\n\]#9 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) "
808 "\[\r\n\]#10 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) "
809 "\[\r\n\]#11 .* main \\(.*\\) at "
810 }
811 }
812
813 #
814 # Locate actual args; recursive passing of structs by value
815 #
816
817 proc recursive_structs_by_value {} {
818 global gdb_prompt
819 global hex
820 global decimal
821 global det_file
822
823 delete_breakpoints
824
825 gdb_breakpoint hitbottom
826
827 # Run; should stop at hitbottom and print actual arguments.
828 # Print backtrace.
829 gdb_run_cmd
830 gdb_test "" "Breakpoint $decimal, hitbottom .*" "run to hitbottom"
831
832 gdb_test_sequence "backtrace 100" "recursive passing of structs by value" {
833 "\[\r\n\]#0 .* hitbottom \\(\\) "
834 "\[\r\n\]#1 .* recurse \\(a=\{s = 0, i = 0, l = 0\}, depth=0\\) "
835 "\[\r\n\]#2 .* recurse \\(a=\{s = 1, i = 1, l = 1\}, depth=1\\) "
836 "\[\r\n\]#3 .* recurse \\(a=\{s = 2, i = 2, l = 2\}, depth=2\\) "
837 "\[\r\n\]#4 .* recurse \\(a=\{s = 3, i = 3, l = 3\}, depth=3\\) "
838 "\[\r\n\]#5 .* recurse \\(a=\{s = 4, i = 4, l = 4\}, depth=4\\) "
839 "\[\r\n\]#6 .* test_struct_args \\(\\) "
840 "\[\r\n\]#7 .* main \\(.*\\) at "
841 }
842 }
843
844 #
845 # Test for accessing local stack variables in functions which call alloca
846 #
847 proc localvars_after_alloca { } {
848 global gdb_prompt
849 global hex
850 global decimal
851 global gcc_compiled
852
853 if { ![runto localvars_after_alloca] } {
854 return
855 }
856
857 # Print each arg as a double check to see if we can print
858 # them here as well as with backtrace.
859
860 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
861 gdb_test "print c" " = 97 'a'" "print c after runto localvars_after_alloca"
862 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
863 gdb_test "print s" " = 1" "print s after runto localvars_after_alloca"
864 gdb_test "print i" " = 2" "print i after runto localvars_after_alloca"
865 gdb_test "print l" " = 3" "print l after runto localvars_after_alloca"
866
867 # Lame regexp.
868 gdb_test "next" ".*" "next in localvars_after_alloca()"
869
870 # Print each arg as a double check to see if we can print
871 # them here as well as with backtrace.
872
873 gdb_test "print c" " = 97 'a'" "print c in localvars_after_alloca"
874 gdb_test "print s" " = 1" "print s in localvars_after_alloca"
875 gdb_test "print i" " = 2" "print i in localvars_after_alloca"
876 gdb_test "print l" " = 3" "print l in localvars_after_alloca"
877
878 gdb_test "backtrace 8" "#0.*localvars_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" "backtrace after alloca"
879 }
880
881 proc call_after_alloca { } {
882 global gdb_prompt
883 global hex
884 global decimal
885 global gcc_compiled
886
887 if { ![runto call_after_alloca_subr] } {
888 return
889 }
890
891 # Print each arg as a double check to see if we can print
892 # them here as well as with backtrace.
893
894 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
895 gdb_test "print c" " = 97 'a'" "print c in call_after_alloca"
896 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
897 gdb_test "print s" " = 1" "print s in call_after_alloca"
898 gdb_test "print i" " = 2" "print i in call_after_alloca"
899 gdb_test "print l" " = 3" "print l in call_after_alloca"
900
901 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
902 gdb_test "backtrace 8" "#0.*call_after_alloca_subr \\(c=97 'a', s=1, i=2, l=3, uc=98 'b', us=11, ui=12, ul=13\\).*#1.*call_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#2.*main.*" "backtrace from call_after_alloca_subr"
903 }
904
905 #
906 # Test for accessing local stack variables, backtraces, finish,
907 # and finally stepping into indirect calls. The point is that on the PA
908 # these use a funky `dyncall' mechanism which GDB needs to know about.
909 #
910 proc localvars_in_indirect_call { } {
911 global gdb_prompt
912 global hex
913 global decimal
914 global gcc_compiled
915
916 # Can not use "runto call0a" as call0a is called several times
917 # during single run. Instead stop in a marker function and
918 # take control from there.
919 if { ![runto marker_indirect_call] } {
920 return
921 }
922
923 # break on the next call to call0a, then delete all the breakpoints
924 # and start testing.
925 gdb_breakpoint call0a
926 gdb_continue call0a
927 delete_breakpoints
928
929 # Print each arg as a double check to see if we can print
930 # them here as well as with backtrace.
931
932 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
933 gdb_test "print c" " = 97 'a'" "print c in localvars_in_indirect_call"
934 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
935 gdb_test "print s" " = 1" "print s in localvars_in_indirect_call"
936 gdb_test "print i" " = 2" "print i in localvars_in_indirect_call"
937 gdb_test "print l" " = 3" "print l in localvars_in_indirect_call"
938
939 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
940 gdb_test "backtrace 8" \
941 "#0.*call0a \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" \
942 "backtrace in indirectly called function"
943
944 #
945 # "finish" brings us back to main. We then will try to step through
946 # the second indirect call.
947 # On some targets (e.g. m68k) gdb will stop from the finish in midline
948 # of the first indirect call. This is due to stack adjustment instructions
949 # after the indirect call. In these cases we will step till we hit the
950 # second indirect call.
951 #
952
953 gdb_test_multiple "finish" "finish from indirectly called function" {
954 -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$gdb_prompt $" {
955 # If the branch instruction is not the last instruction in the
956 # function call line, we'll stop at that line, and need an extra
957 # "step" to continue the test.
958 send_gdb "step\n"
959 exp_continue
960 }
961 -re ".*\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$gdb_prompt $" {
962 pass "finish from indirectly called function"
963 }
964 -re ".*$gdb_prompt $" {
965 fail "finish from indirectly called function"
966 }
967 default {
968 fail "finish from indirectly called function"
969 }
970 }
971
972 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
973 gdb_test "step" "call0a \\(c=97 'a', s=1, i=2, l=3\\).*" \
974 "stepping into indirectly called function"
975 }
976
977 #
978 # Test for stepping into indirect calls which may have trampolines (possibly
979 # cascaded) on both the call path and the gdb_suppress_tests; path.
980 # to handle trampolines.
981 #
982 proc test_stepping_over_trampolines { } {
983 global gdb_prompt
984 global hex
985 global decimal
986
987 # Stop in a marker function and take control from there.
988 if { ![runto marker_call_with_trampolines] } {
989 return
990 }
991
992 # Cater for gdb stopping in midline, see comment for finish above.
993 gdb_test_multiple "finish" "finish from marker_call_with_trampolines" {
994 -re "marker_call_with_trampolines ..;.*$gdb_prompt $" {
995 send_gdb "step\n"
996 exp_continue
997 }
998 -re "pointer_to_call_with_trampolines.*$gdb_prompt $" {
999 pass "finish from marker_call_with_trampolines"
1000 }
1001 -re ".*$gdb_prompt $" {
1002 fail "finish from marker_call_with_trampolines"
1003 }
1004 default {
1005 fail "finish from marker_call_with_trampolines"
1006 }
1007 }
1008
1009 # Try to step into the target function.
1010 gdb_test "step" "call_with_trampolines \\(d1=5\\).*" \
1011 "stepping into function called with trampolines"
1012
1013 # Make we can backtrace and the argument looks correct. */
1014 gdb_test "backtrace 8" "#0.*call_with_trampolines \\(d1=5\\).*1.*main.*" \
1015 "backtrace through call with trampolines"
1016
1017 # Make sure we can get back to main.
1018 # Stepping back to main might stop again after the gdb_suppress_tests; statement
1019 # or immediately transfer control back to main if optimizations
1020 # are performed.
1021 gdb_test_multiple "step" "stepping back to main from function called with trampolines" {
1022 -re "main .* at.*$gdb_prompt $" {
1023 pass "stepping back to main from function called with trampolines"
1024 }
1025 -re "\}.*End of call_with_trampolines.*$gdb_prompt $" {
1026 send_gdb "step\n"
1027 exp_continue
1028 }
1029 -re ".*$gdb_prompt $" {
1030 fail "stepping back to main from function called with trampolines"
1031 }
1032 default {
1033 fail "stepping back to main from function called with trampolines"
1034 }
1035 }
1036 }
1037
1038 set prev_timeout $timeout
1039 if [istarget "mips*tx39-*"] {
1040 set timeout 300
1041 } else {
1042 set timeout 60
1043 }
1044
1045 # Determine expected output for unsigned long variables,
1046 # the output varies with sizeof (unsigned long).
1047
1048 gdb_test_multiple "print sizeof (long)" "getting sizeof long" {
1049 -re ".\[0-9\]* = 4.*$gdb_prompt $" {
1050 set target_sizeof_long 4
1051 # pass silently
1052 }
1053 -re ".\[0-9\]* = 8.*$gdb_prompt $" {
1054 set target_sizeof_long 8
1055 # pass silently
1056 }
1057 }
1058
1059 gdb_test_multiple "print sizeof (int)" "getting sizeof int" {
1060 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
1061 set target_sizeof_int 2
1062 # pass silently
1063 }
1064 -re ".\[0-9\]* = 4.*$gdb_prompt $" {
1065 set target_sizeof_int 4
1066 # pass silently
1067 }
1068 -re ".\[0-9\]* = 8.*$gdb_prompt $" {
1069 set target_sizeof_int 8
1070 # pass silently
1071 }
1072 }
1073
1074 switch [get_endianness] {
1075 little { set target_bigendian_p 0 }
1076 big { set target_bigendian_p 1 }
1077 }
1078
1079 # Perform tests
1080
1081 gdb_test_no_output "set print frame-arguments all"
1082
1083 integral_args
1084 unsigned_integral_args
1085 if {!$skip_float_test} {
1086 float_and_integral_args
1087 }
1088
1089 # Test _Complex type here if supported.
1090 if [support_complex_tests] {
1091 complex_args
1092
1093 complex_integral_args
1094
1095 if {!$skip_float_test} {
1096 complex_float_integral_args
1097 }
1098 }
1099
1100 pointer_args
1101 structs_by_reference
1102 structs_by_value
1103 discard_and_shuffle
1104 shuffle_round_robin
1105 recursive_structs_by_value
1106 localvars_after_alloca
1107 call_after_alloca
1108 localvars_in_indirect_call
1109 test_stepping_over_trampolines
1110
1111 set timeout $prev_timeout