]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.trace/collection.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / collection.exp
1 # Copyright 1998-2013 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 load_lib "trace-support.exp"
17
18
19 standard_testfile
20 set executable $testfile
21
22 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug nowarnings}]} {
23 return -1
24 }
25
26 # Tests:
27 # 1) $args
28 # 2) function args by name
29 # 3) $locs
30 # 4) function locals by name
31 # 5) $regs
32 # 6) registers by name ($sp, $fp?)
33 # 7) globals by name
34 # 8) expressions (lots of different kinds: local and global)
35
36 set ws "\[\r\n\t \]+"
37 set cr "\[\r\n\]+"
38
39 if [is_amd64_regs_target] {
40 set fpreg "rbp"
41 set spreg "rsp"
42 set pcreg "rip"
43 } elseif [is_x86_like_target] {
44 set fpreg "ebp"
45 set spreg "esp"
46 set pcreg "eip"
47 } else {
48 set fpreg "fp"
49 set spreg "sp"
50 set pcreg "pc"
51 }
52
53 #
54 # Utility procs
55 #
56
57 proc test_register { reg test_id } {
58 global cr
59 global gdb_prompt
60
61 gdb_test_multiple "print /x $reg" "" {
62 -re "\\$\[0-9\]+ = \[x0\]+$cr$gdb_prompt $" {
63 fail "collect $test_id: collected $reg (zero)"
64 }
65 -re "\\$\[0-9\]+ = \[x0-9a-fA-F\]+$cr$gdb_prompt $" {
66 pass "collect $test_id: collected $reg"
67 }
68 -re "\[Ee\]rror.*$gdb_prompt $" {
69 fail "collect $test_id: collected $reg (error)"
70 }
71 }
72 }
73
74 proc prepare_for_trace_test {} {
75 global executable
76
77 clean_restart $executable
78
79 runto_main
80
81 gdb_test "break begin" ".*" ""
82 gdb_test "break end" ".*" ""
83 }
84
85 proc run_trace_experiment { msg test_func } {
86 global gdb_prompt
87
88 gdb_test "continue" \
89 ".*Breakpoint \[0-9\]+, begin .*" \
90 "collect $msg: advance to begin"
91
92 set test "collect $msg: start trace experiment"
93 gdb_test_multiple "tstart" "$test" {
94 -re "^tstart\r\n$gdb_prompt $" {
95 pass "$test"
96 }
97 }
98
99 gdb_test "continue" \
100 "Continuing.*Breakpoint \[0-9\]+, end.*" \
101 "collect $msg: run trace experiment"
102 gdb_test "tstop" \
103 "\[\r\n\]+" \
104 "collect $msg: stop trace experiment"
105 gdb_test "tfind start" \
106 "#0 $test_func .*" \
107 "collect $msg: tfind test frame"
108 }
109
110
111 #
112 # Test procs
113 #
114
115 proc gdb_collect_args_test { myargs msg } {
116 global cr
117 global gdb_prompt
118
119 prepare_for_trace_test
120
121 gdb_test "trace args_test_func" \
122 "Tracepoint \[0-9\]+ at .*" \
123 "collect $msg: set tracepoint"
124 gdb_trace_setactions "collect $msg: define actions" \
125 "" \
126 "collect $myargs" "^$"
127
128 # Begin the test.
129 run_trace_experiment $msg args_test_func
130
131 gdb_test "print argc" \
132 "\\$\[0-9\]+ = 1 '.001'$cr" \
133 "collect $msg: collected arg char"
134 gdb_test "print argi" \
135 "\\$\[0-9\]+ = 2$cr" \
136 "collect $msg: collected arg int"
137 gdb_test "print argf" \
138 "\\$\[0-9\]+ = 3.\[23\]\[0-9\]*$cr" \
139 "collect $msg: collected arg float"
140 gdb_test "print argd" \
141 "\\$\[0-9\]+ = 4.\[34\]\[0-9\]*$cr" \
142 "collect $msg: collected arg double"
143
144 # struct arg as one of several args (near end of list)
145 gdb_test "print argstruct.memberc" \
146 "\\$\[0-9\]+ = 101 'e'$cr" \
147 "collect $msg: collected arg struct member char"
148 gdb_test "print argstruct.memberi" \
149 "\\$\[0-9\]+ = 102$cr" \
150 "collect $msg: collected arg struct member int"
151 gdb_test "print argstruct.memberf" \
152 "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*$cr" \
153 "collect $msg: collected arg struct member float"
154 gdb_test "print argstruct.memberd" \
155 "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*$cr" \
156 "collect $msg: collected arg struct member double"
157
158 # array arg as one of several args (near end of list)
159
160 # It isn't clear why is the test assuming the array's elements are
161 # collected. In C, an array as function parameters is a special
162 # case; it's just a pointer into the caller's array, and as such,
163 # that's what normally the debug info describes. Maybe this was
164 # originaly written for a compiler where array parameters were
165 # really described as arrays in debug info.
166
167 setup_xfail "*-*-*"
168 gdb_test "print argarray\[0\]" \
169 "\\$\[0-9\]+ = 111$cr" \
170 "collect $msg: collected argarray #0"
171
172 setup_xfail "*-*-*"
173 gdb_test "print argarray\[1\]" \
174 "\\$\[0-9\]+ = 112$cr" \
175 "collect $msg: collected argarray #1"
176
177 setup_xfail "*-*-*"
178 gdb_test "print argarray\[2\]" \
179 "\\$\[0-9\]+ = 113$cr" \
180 "collect $msg: collected argarray #2"
181
182 setup_xfail "*-*-*"
183 gdb_test "print argarray\[3\]" \
184 "\\$\[0-9\]+ = 114$cr" \
185 "collect $msg: collected argarray #3"
186
187 gdb_test "tfind none" \
188 "#0 end .*" \
189 "collect $msg: cease trace debugging"
190 }
191
192 proc gdb_collect_argstruct_test { myargs msg } {
193 global cr
194 global gdb_prompt
195
196 prepare_for_trace_test
197
198 gdb_test "trace argstruct_test_func" \
199 "Tracepoint \[0-9\]+ at .*" \
200 "collect $msg: set tracepoint"
201 gdb_trace_setactions "collect $msg: define actions" \
202 "" \
203 "collect $myargs" "^$"
204
205 # Begin the test.
206 run_trace_experiment $msg argstruct_test_func
207
208 # struct argument as only argument
209 gdb_test "print argstruct.memberc" \
210 "\\$\[0-9\]+ = 101 'e'$cr" \
211 "collect $msg: collected arg struct member char"
212 gdb_test "print argstruct.memberi" \
213 "\\$\[0-9\]+ = 102$cr" \
214 "collect $msg: collected arg struct member int"
215 gdb_test "print argstruct.memberf" \
216 "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*$cr" \
217 "collect $msg: collected arg struct member float"
218 gdb_test "print argstruct.memberd" \
219 "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*$cr" \
220 "collect $msg: collected arg struct member double"
221
222 gdb_test "tfind none" \
223 "#0 end .*" \
224 "collect $msg: cease trace debugging"
225 }
226
227
228 proc gdb_collect_argarray_test { myargs msg } {
229 global cr
230 global gdb_prompt
231
232 prepare_for_trace_test
233
234 gdb_test "trace argarray_test_func" \
235 "Tracepoint \[0-9\]+ at .*" \
236 "collect $msg: set tracepoint"
237 gdb_trace_setactions "collect $msg: define actions" \
238 "" \
239 "collect $myargs" "^$"
240
241 # Begin the test.
242 run_trace_experiment $msg argarray_test_func
243
244 # array arg as only argument
245
246 # It isn't clear why is the test assuming the array's elements are
247 # collected. In C, an array as function parameters is a special
248 # case; it's just a pointer into the caller's array, and as such,
249 # that's what normally the debug info describes. Maybe this was
250 # originaly written for a compiler where array parameters were
251 # really described as arrays in debug info.
252
253 setup_xfail "*-*-*"
254 gdb_test "print argarray\[0\]" \
255 "\\$\[0-9\]+ = 111$cr" \
256 "collect $msg: collected argarray #0"
257
258 setup_xfail "*-*-*"
259 gdb_test "print argarray\[1\]" \
260 "\\$\[0-9\]+ = 112$cr" \
261 "collect $msg: collected argarray #1"
262
263 setup_xfail "*-*-*"
264 gdb_test "print argarray\[2\]" \
265 "\\$\[0-9\]+ = 113$cr" \
266 "collect $msg: collected argarray #2"
267
268 setup_xfail "*-*-*"
269 gdb_test "print argarray\[3\]" \
270 "\\$\[0-9\]+ = 114$cr" \
271 "collect $msg: collected argarray #3"
272
273 gdb_test "tfind none" \
274 "#0 end .*" \
275 "collect $msg: cease trace debugging"
276 }
277
278
279 proc gdb_collect_locals_test { func mylocs msg } {
280 global cr
281 global gdb_prompt
282
283 prepare_for_trace_test
284
285 # Find the comment-identified line for setting this tracepoint.
286 set testline 0
287 gdb_test_multiple "list $func, +30" "collect $msg: find tracepoint line" {
288 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
289 set testline $expect_out(1,string)
290 pass "collect $msg: find tracepoint line"
291 }
292 -re ".*$gdb_prompt " {
293 fail "collect $msg: find tracepoint line (skipping locals test)"
294 return
295 }
296 timeout {
297 fail "collect $msg: find tracepoint line (skipping locals test)"
298 return
299 }
300 }
301
302 gdb_test "trace $testline" \
303 "Tracepoint \[0-9\]+ at .*" \
304 "collect $msg: set tracepoint"
305 gdb_trace_setactions "collect $msg: define actions" \
306 "" \
307 "collect $mylocs" "^$"
308
309 # Begin the test.
310 run_trace_experiment $msg $func
311
312 gdb_test "print locc" \
313 "\\$\[0-9\]+ = 11 '.\[a-z0-7\]+'$cr" \
314 "collect $msg: collected local char"
315 gdb_test "print loci" \
316 "\\$\[0-9\]+ = 12$cr" \
317 "collect $msg: collected local int"
318 gdb_test "print locf" \
319 "\\$\[0-9\]+ = 13.\[23\]\[0-9\]*$cr" \
320 "collect $msg: collected local float"
321 gdb_test "print locd" \
322 "\\$\[0-9\]+ = 14.\[34\]\[0-9\]*$cr" \
323 "collect $msg: collected local double"
324
325 gdb_test "print locst.memberc" \
326 "\\$\[0-9\]+ = 15 '.017'$cr" \
327 "collect $msg: collected local member char"
328 gdb_test "print locst.memberi" \
329 "\\$\[0-9\]+ = 16$cr" \
330 "collect $msg: collected local member int"
331 gdb_test "print locst.memberf" \
332 "\\$\[0-9\]+ = 17.\[67\]\[0-9\]*$cr" \
333 "collect $msg: collected local member float"
334 gdb_test "print locst.memberd" \
335 "\\$\[0-9\]+ = 18.\[78\]\[0-9\]*$cr" \
336 "collect $msg: collected local member double"
337
338 gdb_test "print locar\[0\]" \
339 "\\$\[0-9\]+ = 121$cr" \
340 "collect $msg: collected locarray #0"
341 gdb_test "print locar\[1\]" \
342 "\\$\[0-9\]+ = 122$cr" \
343 "collect $msg: collected locarray #1"
344 gdb_test "print locar\[2\]" \
345 "\\$\[0-9\]+ = 123$cr" \
346 "collect $msg: collected locarray #2"
347 gdb_test "print locar\[3\]" \
348 "\\$\[0-9\]+ = 124$cr" \
349 "collect $msg: collected locarray #3"
350
351
352 gdb_test "tfind none" \
353 "#0 end .*" \
354 "collect $msg: cease trace debugging"
355 }
356
357 proc gdb_collect_registers_test { myregs } {
358 global cr
359 global gdb_prompt
360 global fpreg
361 global spreg
362 global pcreg
363
364 prepare_for_trace_test
365
366 # We'll simply re-use the args_test_function for this test
367 gdb_test "trace args_test_func" \
368 "Tracepoint \[0-9\]+ at .*" \
369 "collect $myregs: set tracepoint"
370 gdb_trace_setactions "collect $myregs: define actions" \
371 "" \
372 "collect $myregs" "^$"
373
374 # Begin the test.
375 run_trace_experiment $myregs args_test_func
376
377 test_register "\$$fpreg" $myregs
378 test_register "\$$spreg" $myregs
379 test_register "\$$pcreg" $myregs
380
381 gdb_test "tfind none" \
382 "#0 end .*" \
383 "collect $myregs: cease trace debugging"
384 }
385
386 proc gdb_collect_expression_test { func expr val msg } {
387 global cr
388 global gdb_prompt
389
390 prepare_for_trace_test
391
392 # Find the comment-identified line for setting this tracepoint.
393 set testline 0
394 gdb_test_multiple "list $func, +30" "collect $msg: find tracepoint line" {
395 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
396 set testline $expect_out(1,string)
397 pass "collect $msg: find tracepoint line"
398 }
399 -re ".*$gdb_prompt " {
400 fail "collect $msg: find tracepoint line (skipping locals test)"
401 return
402 }
403 timeout {
404 fail "collect $msg: find tracepoint line (skipping locals test)"
405 return
406 }
407 }
408
409 gdb_test "trace $testline" \
410 "Tracepoint \[0-9\]+ at .*" \
411 "collect $msg: set tracepoint"
412 gdb_trace_setactions "collect $msg: define actions" \
413 "" \
414 "collect $expr" "^$"
415
416 # Begin the test.
417 run_trace_experiment $msg $func
418
419 gdb_test "print $expr" \
420 "\\$\[0-9\]+ = $val$cr" \
421 "collect $msg: got expected value '$val'"
422
423 gdb_test "tfind none" \
424 "#0 end .*" \
425 "collect $msg: cease trace debugging"
426 }
427
428 proc gdb_collect_globals_test { } {
429 global cr
430 global gdb_prompt
431
432 prepare_for_trace_test
433
434 # Find the comment-identified line for setting this tracepoint.
435 set testline 0
436 gdb_test_multiple "list globals_test_func, +30" "collect globals: find tracepoint line" {
437 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
438 set testline $expect_out(1,string)
439 pass "collect globals: find tracepoint line"
440 }
441 -re ".*$gdb_prompt " {
442 fail "collect globals: find tracepoint line (skipping global test)"
443 return
444 }
445 timeout {
446 fail "collect globals: find tracepoint line (skipping global test)"
447 return
448 }
449 }
450
451 # Use use this to test collecting overlapping memory ranges
452 # (making use of UNOP_MEMVAL, as objects don't usually overlap
453 # other objects). Note that globalarr2 should not be collected in
454 # any other way so that a regression test below can be effective.
455
456 set globalarr2_addr ""
457 set test "get address of globalarr2"
458 gdb_test_multiple "p /x &globalarr2" $test {
459 -re " = (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
460 set globalarr2_addr $expect_out(1,string)
461 pass $test
462 }
463 }
464
465 gdb_test "trace $testline" \
466 "Tracepoint \[0-9\]+ at .*" \
467 "collect globals: set tracepoint"
468 gdb_trace_setactions "collect globals: define actions" \
469 "" \
470 "collect globalc, globali, globalf, globald" "^$" \
471 "collect globalstruct, globalp, globalarr" "^$" \
472 "collect \{int \[4\]\}$globalarr2_addr" "^$" \
473 "collect \{int \[2\]\}$globalarr2_addr" "^$" \
474 "collect \{int \[4\]\}globalarr3" "^$"
475
476 # Begin the test.
477 run_trace_experiment "globals" globals_test_func
478
479 gdb_test "print globalc" \
480 "\\$\[0-9\]+ = 71 'G'$cr" \
481 "collect globals: collected global char"
482 gdb_test "print globali" \
483 "\\$\[0-9\]+ = 72$cr" \
484 "collect globals: collected global int"
485 gdb_test "print globalf" \
486 "\\$\[0-9\]+ = 73.\[23\]\[0-9\]*$cr" \
487 "collect globals: collected global float"
488 gdb_test "print globald" \
489 "\\$\[0-9\]+ = 74.\[34\]\[0-9\]*$cr" \
490 "collect globals: collected global double"
491
492 gdb_test "print globalstruct.memberc" \
493 "\\$\[0-9\]+ = 81 'Q'$cr" \
494 "collect globals: collected struct char member"
495 gdb_test "print globalstruct.memberi" \
496 "\\$\[0-9\]+ = 82$cr" \
497 "collect globals: collected struct member int"
498 gdb_test "print globalstruct.memberf" \
499 "\\$\[0-9\]+ = 83.\[23\]\[0-9\]*$cr" \
500 "collect globals: collected struct member float"
501 gdb_test "print globalstruct.memberd" \
502 "\\$\[0-9\]+ = 84.\[34\]\[0-9\]*$cr" \
503 "collect globals: collected struct member double"
504
505 gdb_test "print globalp == &globalstruct" \
506 "\\$\[0-9\]+ = 1$cr" \
507 "collect globals: collected global pointer"
508
509 gdb_test "print globalarr\[1\]" \
510 "\\$\[0-9\]+ = 1$cr" \
511 "collect globals: collected global array element #1"
512 gdb_test "print globalarr\[2\]" \
513 "\\$\[0-9\]+ = 2$cr" \
514 "collect globals: collected global array element #2"
515 gdb_test "print globalarr\[3\]" \
516 "\\$\[0-9\]+ = 3$cr" \
517 "collect globals: collected global array element #3"
518
519 # Check that we didn't mess up sort&merging memory ranges to
520 # collect.
521 gdb_test "print globalarr2" \
522 "\\$\[0-9\]+ = \\{0, 1, 2, 3\\}$cr" \
523 "collect globals: collected global array 2"
524
525 # GDB would internal error collecting UNOP_MEMVAL's whose address
526 # expression wasn't an rvalue (that's regtested in the
527 # corresponding 'collect' action above). This just double checks
528 # we actually did collect what we wanted.
529 gdb_test "print globalarr3" \
530 "\\$\[0-9\]+ = \\{3, 2, 1, 0\\}$cr" \
531 "collect globals: collected global array 3"
532
533 gdb_test "tfind none" \
534 "#0 end .*" \
535 "collect globals: cease trace debugging"
536 }
537
538 # Test that when we've collected all fields of a structure
539 # individually, we can print the whole structure in one go.
540 proc gdb_collect_global_in_pieces_test { } {
541 global gdb_prompt
542
543 prepare_for_trace_test
544
545 # Find the comment-identified line for setting this tracepoint.
546 set testline 0
547 set msg "collect global in pieces: find tracepoint line"
548 gdb_test_multiple "list globals_test_func, +30" "$msg" {
549 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
550 set testline $expect_out(1,string)
551 pass "$msg"
552 }
553 }
554
555 if {$testline == 0} {
556 return
557 }
558
559 gdb_test "trace $testline" \
560 "Tracepoint \[0-9\]+ at .*" \
561 "collect global in pieces: set tracepoint"
562 gdb_trace_setactions "collect global in pieces: define actions" \
563 "" \
564 "collect global_pieces.a, global_pieces.b" \
565 "^$"
566
567 # Begin the test.
568 run_trace_experiment "global in pieces" globals_test_func
569
570 gdb_test "print /x global_pieces.a" " = 0x12345678" \
571 "collect global in pieces: print piece a"
572 gdb_test "print /x global_pieces.b" " = 0x87654321" \
573 "collect global in pieces: print piece b"
574
575 gdb_test "print /x global_pieces" " = \{a = 0x12345678, b = 0x87654321\}" \
576 "collect global in pieces: print whole object"
577
578 gdb_test "tfind none" "#0 end .*" \
579 "collect global in pieces: cease trace debugging"
580 }
581
582 proc gdb_collect_return_test { } {
583 global gdb_prompt
584
585 prepare_for_trace_test
586
587 # We'll simply re-use the args_test_function for this test
588 gdb_test "trace args_test_func" \
589 "Tracepoint \[0-9\]+ at .*" \
590 "collect \$_ret: set tracepoint"
591 gdb_trace_setactions "collect \$_ret: define actions" \
592 "" \
593 "collect \$_ret" "^$"
594
595 # Begin the test.
596 run_trace_experiment \$_ret args_test_func
597
598 # Since we can't guarantee that $_ret will give us the caller,
599 # pass either way, but giving different messages.
600 gdb_test_multiple "backtrace" "" {
601 -re ".*#1 .* in main .*\r\n$gdb_prompt $" {
602 pass "collect \$_ret: backtrace lists main"
603 }
604 -re ".*#1 .* in ?? .*\r\n$gdb_prompt $" {
605 pass "collect \$_ret: backtrace not listing main"
606 }
607 }
608
609 gdb_test "tfind none" \
610 "#0 end .*" \
611 "collect \$_ret: cease trace debugging"
612 }
613
614 proc gdb_collect_strings_test { func mystr myrslt mylim msg } {
615 global hex
616 global cr
617 global gdb_prompt
618
619 prepare_for_trace_test
620
621 # Find the comment-identified line for setting this tracepoint.
622 set testline 0
623 gdb_test_multiple "list $func, +30" "collect $msg: find tracepoint line" {
624 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
625 set testline $expect_out(1,string)
626 pass "collect $msg: find tracepoint line"
627 }
628 -re ".*$gdb_prompt " {
629 fail "collect $msg: find tracepoint line (skipping strings test)"
630 return
631 }
632 timeout {
633 fail "collect $msg: find tracepoint line (skipping strings test)"
634 return
635 }
636 }
637
638 gdb_test "trace $testline" \
639 "Tracepoint \[0-9\]+ at .*" \
640 "collect $msg: set tracepoint"
641 gdb_trace_setactions "collect $msg: define actions" \
642 "" \
643 "collect/s$mylim $mystr" "^$"
644
645 # Begin the test.
646 run_trace_experiment $msg $func
647
648 gdb_test "print $mystr" \
649 "\\$\[0-9\]+ = $hex \"$myrslt\".*$cr" \
650 "collect $msg: collected local string"
651
652 gdb_test "tfind none" \
653 "#0 end .*" \
654 "collect $msg: cease trace debugging"
655 }
656
657 proc gdb_trace_collection_test {} {
658 global fpreg
659 global spreg
660 global pcreg
661
662 gdb_collect_args_test "\$args" \
663 "args collectively"
664 gdb_collect_args_test "argc, argi, argf, argd, argstruct, argarray" \
665 "args individually"
666 gdb_collect_argstruct_test "\$args" \
667 "argstruct collectively"
668 gdb_collect_argstruct_test "argstruct" \
669 "argstruct individually"
670 gdb_collect_argarray_test "\$args" \
671 "argarray collectively"
672 gdb_collect_argarray_test "argarray" \
673 "argarray individually"
674 gdb_collect_locals_test local_test_func "\$locals" \
675 "auto locals collectively"
676 gdb_collect_locals_test local_test_func \
677 "locc, loci, locf, locd, locst, locar" \
678 "auto locals individually"
679 gdb_collect_locals_test reglocal_test_func "\$locals" \
680 "register locals collectively"
681 gdb_collect_locals_test reglocal_test_func \
682 "locc, loci, locf, locd, locst, locar" \
683 "register locals individually"
684 gdb_collect_locals_test statlocal_test_func "\$locals" \
685 "static locals collectively"
686 gdb_collect_locals_test statlocal_test_func \
687 "locc, loci, locf, locd, locst, locar" \
688 "static locals individually"
689 gdb_collect_registers_test "\$regs"
690 gdb_collect_registers_test "\$$fpreg, \$$spreg, \$$pcreg"
691 gdb_collect_globals_test
692 gdb_collect_global_in_pieces_test
693
694 #
695 # Expression tests:
696 #
697 # *x (**x, ...)
698 # x.y (x.y.z, ...)
699 # x->y (x->y->z, ...)
700 # x[2] (x[2][3], ...) (const index)
701 # x[y] (x[y][z], ...) (index to be char, short, long, float, double)
702 # NOTE:
703 # We test the following operators by using them in an array index
704 # expression -- because the naked result of an operator is not really
705 # collected. To be sure the operator was evaluated correctly on the
706 # target, we have to actually use the result eg. in an array offset
707 # calculation.
708 # x[y + z] (tests addition: y and z various combos of types, sclasses)
709 # x[y - z] (tests subtraction) (ditto)
710 # x[y * z] (tests multiplication) (ditto)
711 # x[y / z] (tests division) (ditto)
712 # x[y % z] (tests modulo division) (ditto)
713 # x[y == z] (tests equality relation) (ditto) UNSUPPORTED
714 # x[y != z] (tests inequality relation) (ditto) UNSUPPORTED
715 # x[y > z] (tests greater-than relation) (ditto) UNSUPPORTED
716 # x[y < z] (tests less-than relation) (ditto) UNSUPPORTED
717 # x[y >= z] (tests greater-than-or-equal relation) (ditto) UNSUPPORTED
718 # x[y <= z] (tests less-than-or-equal relation) (ditto) UNSUPPORTED
719 # x[y && z] (tests logical and) (ditto) UNSUPPORTED
720 # x[y || z] (tests logical or) (ditto) UNSUPPORTED
721 # x[y & z] (tests binary and) (ditto) UNSUPPORTED
722 # x[y | z] (tests binary or) (ditto) UNSUPPORTED
723 # x[y ^ z] (tests binary xor) (ditto) UNSUPPORTED
724 # x[y ? z1 : z2] (tests ternary operator) (ditto) UNSUPPORTED
725 # x[y << z] (tests shift-left) (ditto) UNSUPPORTED
726 # x[y >> z] (tests shift-right) (ditto) UNSUPPORTED
727 # x[y = z] (tests assignment operator) (ditto) UNSUPPORTED
728 # x[++y] (tests pre-increment operator) (ditto) UNSUPPORTED
729 # x[--y] (tests pre-decrement operator) (ditto) UNSUPPORTED
730 # x[y++] (tests post-increment operator) (ditto) UNSUPPORTED
731 # x[y--] (tests post-decrement operator) (ditto) UNSUPPORTED
732 # x[+y] (tests unary plus) (ditto)
733 # x[-y] (tests unary minus) (ditto)
734 # x[!y] (tests logical not) (ditto) UNSUPPORTED
735 # x[~y] (tests binary not) (ditto) UNSUPPORTED
736 # x[(y, z)] (tests comma expression) (ditto)
737 # cast expr
738 # stack data
739
740 gdb_collect_expression_test globals_test_func \
741 "globalstruct.memberi" "82" "a.b"
742 gdb_collect_expression_test globals_test_func \
743 "globalp->memberc" "81 'Q'" "a->b"
744 gdb_collect_expression_test globals_test_func \
745 "globalarr\[2\]" "2" "a\[2\]"
746 gdb_collect_expression_test globals_test_func \
747 "globalarr\[l3\]" "3" "a\[b\]"
748 gdb_collect_expression_test globals_test_func \
749 "globalarr\[l3 + l2\]" "5" "a\[b + c\]"
750 gdb_collect_expression_test globals_test_func \
751 "globalarr\[l3 - l2\]" "1" "a\[b - c\]"
752 gdb_collect_expression_test globals_test_func \
753 "globalarr\[l3 * l2\]" "6" "a\[b * c\]"
754 gdb_collect_expression_test globals_test_func \
755 "globalarr\[l6 / l3\]" "2" "a\[b / c\]"
756 gdb_collect_expression_test globals_test_func \
757 "globalarr\[l7 % l3\]" "1" "a\[b % c\]"
758 gdb_collect_expression_test globals_test_func \
759 "globalarr\[+l1\]" "1" "a\[+b\]"
760 gdb_collect_expression_test globals_test_func \
761 "globalarr\[-lminus\]" "2" "a\[-b\]"
762 gdb_collect_expression_test globals_test_func \
763 "globalarr\[\(l6, l7\)\]" "7" "a\[\(b, c\)\]"
764
765 gdb_collect_return_test
766
767 gdb_collect_strings_test strings_test_func "locstr" "abcdef" "" \
768 "local string"
769
770 gdb_collect_strings_test strings_test_func "longloc" "how now brown c" 15 \
771 "long local string"
772
773 }
774
775 runto_main
776
777 if { ![gdb_target_supports_trace] } then {
778 unsupported "Current target does not support trace"
779 return 1;
780 }
781
782 # Body of test encased in a proc so we can return prematurely.
783 gdb_trace_collection_test
784
785 # Finished!
786 gdb_test "tfind none" ".*" ""