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