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