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