2011-11-02 Stan Shebs <stan@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / collection.exp
CommitLineData
7b6bb8da
JB
1# Copyright 1998, 2005, 2007, 2008, 2009, 2010, 2011
2# Free Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c
SS
17load_lib "trace-support.exp"
18
19if $tracelevel then {
20 strace $tracelevel
21}
22
c906108c
SS
23
24set testfile "collection"
25set srcfile ${testfile}.c
6e79d367
PA
26set executable $testfile
27set binfile $objdir/$subdir/$executable
c906108c
SS
28
29if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
fc91c6c2 30 executable {debug nowarnings}] != "" } {
b60f0898
JB
31 untested collection.exp
32 return -1
c906108c
SS
33}
34
35# Tests:
36# 1) $args
37# 2) function args by name
38# 3) $locs
39# 4) function locals by name
40# 5) $regs
41# 6) registers by name ($sp, $fp?)
42# 7) globals by name
43# 8) expressions (lots of different kinds: local and global)
44
45set ws "\[\r\n\t \]+"
46set cr "\[\r\n\]+"
47
7f062217 48if [is_amd64_regs_target] {
6e79d367
PA
49 set fpreg "rbp"
50 set spreg "rsp"
51 set pcreg "rip"
7f062217 52} elseif [is_x86_like_target] {
6e79d367
PA
53 set fpreg "ebp"
54 set spreg "esp"
55 set pcreg "eip"
56} else {
57 set fpreg "fp"
58 set spreg "sp"
59 set pcreg "pc"
60}
61
c906108c
SS
62#
63# Utility procs
64#
65
66proc test_register { reg test_id } {
67 global cr
68 global gdb_prompt
69
6e79d367
PA
70 gdb_test_multiple "print /x $reg" "" {
71 -re "\\$\[0-9\]+ = \[x0\]+$cr$gdb_prompt $" {
c906108c
SS
72 fail "collect $test_id: collected $reg (zero)"
73 }
6e79d367 74 -re "\\$\[0-9\]+ = \[x0-9a-fA-F\]+$cr$gdb_prompt $" {
c906108c
SS
75 pass "collect $test_id: collected $reg"
76 }
6e79d367 77 -re "\[Ee\]rror.*$gdb_prompt $" {
c906108c
SS
78 fail "collect $test_id: collected $reg (error)"
79 }
c906108c
SS
80 }
81}
82
6e79d367
PA
83proc prepare_for_trace_test {} {
84 global executable
85
86 clean_restart $executable
87
88 runto_main
89
de7ff789
MS
90 gdb_test "break begin" ".*" ""
91 gdb_test "break end" ".*" ""
6e79d367
PA
92}
93
c906108c 94proc run_trace_experiment { msg test_func } {
a8121990
PA
95 global gdb_prompt
96
6e79d367
PA
97 gdb_test "continue" \
98 ".*Breakpoint \[0-9\]+, begin .*" \
99 "collect $msg: advance to begin"
100
a8121990
PA
101 set test "collect $msg: start trace experiment"
102 gdb_test_multiple "tstart" "$test" {
103 -re "^tstart\r\n$gdb_prompt $" {
104 pass "$test"
105 }
106 }
107
c906108c
SS
108 gdb_test "continue" \
109 "Continuing.*Breakpoint \[0-9\]+, end.*" \
110 "collect $msg: run trace experiment"
111 gdb_test "tstop" \
112 "\[\r\n\]+" \
113 "collect $msg: stop trace experiment"
114 gdb_test "tfind start" \
115 "#0 $test_func .*" \
116 "collect $msg: tfind test frame"
117}
118
119
120#
121# Test procs
122#
123
124proc gdb_collect_args_test { myargs msg } {
125 global cr
126 global gdb_prompt
127
6e79d367 128 prepare_for_trace_test
c906108c
SS
129
130 gdb_test "trace args_test_func" \
131 "Tracepoint \[0-9\]+ at .*" \
132 "collect $msg: set tracepoint"
133 gdb_trace_setactions "collect $msg: define actions" \
134 "" \
135 "collect $myargs" "^$"
136
137 # Begin the test.
138 run_trace_experiment $msg args_test_func
139
140 gdb_test "print argc" \
141 "\\$\[0-9\]+ = 1 '.001'$cr" \
142 "collect $msg: collected arg char"
143 gdb_test "print argi" \
144 "\\$\[0-9\]+ = 2$cr" \
145 "collect $msg: collected arg int"
146 gdb_test "print argf" \
147 "\\$\[0-9\]+ = 3.\[23\]\[0-9\]*$cr" \
148 "collect $msg: collected arg float"
149 gdb_test "print argd" \
150 "\\$\[0-9\]+ = 4.\[34\]\[0-9\]*$cr" \
151 "collect $msg: collected arg double"
152
153 # struct arg as one of several args (near end of list)
154 gdb_test "print argstruct.memberc" \
155 "\\$\[0-9\]+ = 101 'e'$cr" \
156 "collect $msg: collected arg struct member char"
157 gdb_test "print argstruct.memberi" \
158 "\\$\[0-9\]+ = 102$cr" \
159 "collect $msg: collected arg struct member int"
160 gdb_test "print argstruct.memberf" \
161 "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*$cr" \
162 "collect $msg: collected arg struct member float"
163 gdb_test "print argstruct.memberd" \
164 "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*$cr" \
165 "collect $msg: collected arg struct member double"
166
167 # array arg as one of several args (near end of list)
0db9b91c
PA
168
169 # It isn't clear why is the test assuming the array's elements are
170 # collected. In C, an array as function parameters is a special
171 # case; it's just a pointer into the caller's array, and as such,
172 # that's what normally the debug info describes. Maybe this was
173 # originaly written for a compiler where array parameters were
174 # really described as arrays in debug info.
175
176 setup_xfail "*-*-*"
c906108c
SS
177 gdb_test "print argarray\[0\]" \
178 "\\$\[0-9\]+ = 111$cr" \
179 "collect $msg: collected argarray #0"
0db9b91c
PA
180
181 setup_xfail "*-*-*"
c906108c
SS
182 gdb_test "print argarray\[1\]" \
183 "\\$\[0-9\]+ = 112$cr" \
184 "collect $msg: collected argarray #1"
0db9b91c
PA
185
186 setup_xfail "*-*-*"
c906108c
SS
187 gdb_test "print argarray\[2\]" \
188 "\\$\[0-9\]+ = 113$cr" \
189 "collect $msg: collected argarray #2"
0db9b91c
PA
190
191 setup_xfail "*-*-*"
c906108c
SS
192 gdb_test "print argarray\[3\]" \
193 "\\$\[0-9\]+ = 114$cr" \
194 "collect $msg: collected argarray #3"
195
196 gdb_test "tfind none" \
197 "#0 end .*" \
198 "collect $msg: cease trace debugging"
199}
200
201proc gdb_collect_argstruct_test { myargs msg } {
202 global cr
203 global gdb_prompt
204
6e79d367 205 prepare_for_trace_test
c906108c
SS
206
207 gdb_test "trace argstruct_test_func" \
208 "Tracepoint \[0-9\]+ at .*" \
209 "collect $msg: set tracepoint"
210 gdb_trace_setactions "collect $msg: define actions" \
211 "" \
212 "collect $myargs" "^$"
213
214 # Begin the test.
215 run_trace_experiment $msg argstruct_test_func
216
217 # struct argument as only argument
218 gdb_test "print argstruct.memberc" \
219 "\\$\[0-9\]+ = 101 'e'$cr" \
220 "collect $msg: collected arg struct member char"
221 gdb_test "print argstruct.memberi" \
222 "\\$\[0-9\]+ = 102$cr" \
223 "collect $msg: collected arg struct member int"
224 gdb_test "print argstruct.memberf" \
225 "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*$cr" \
226 "collect $msg: collected arg struct member float"
227 gdb_test "print argstruct.memberd" \
228 "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*$cr" \
229 "collect $msg: collected arg struct member double"
230
231 gdb_test "tfind none" \
232 "#0 end .*" \
233 "collect $msg: cease trace debugging"
234}
235
236
237proc gdb_collect_argarray_test { myargs msg } {
238 global cr
239 global gdb_prompt
240
6e79d367 241 prepare_for_trace_test
c906108c
SS
242
243 gdb_test "trace argarray_test_func" \
244 "Tracepoint \[0-9\]+ at .*" \
245 "collect $msg: set tracepoint"
246 gdb_trace_setactions "collect $msg: define actions" \
247 "" \
248 "collect $myargs" "^$"
249
250 # Begin the test.
251 run_trace_experiment $msg argarray_test_func
252
253 # array arg as only argument
0db9b91c
PA
254
255 # It isn't clear why is the test assuming the array's elements are
256 # collected. In C, an array as function parameters is a special
257 # case; it's just a pointer into the caller's array, and as such,
258 # that's what normally the debug info describes. Maybe this was
259 # originaly written for a compiler where array parameters were
260 # really described as arrays in debug info.
261
262 setup_xfail "*-*-*"
c906108c
SS
263 gdb_test "print argarray\[0\]" \
264 "\\$\[0-9\]+ = 111$cr" \
265 "collect $msg: collected argarray #0"
0db9b91c
PA
266
267 setup_xfail "*-*-*"
c906108c
SS
268 gdb_test "print argarray\[1\]" \
269 "\\$\[0-9\]+ = 112$cr" \
270 "collect $msg: collected argarray #1"
0db9b91c
PA
271
272 setup_xfail "*-*-*"
c906108c
SS
273 gdb_test "print argarray\[2\]" \
274 "\\$\[0-9\]+ = 113$cr" \
275 "collect $msg: collected argarray #2"
0db9b91c
PA
276
277 setup_xfail "*-*-*"
c906108c
SS
278 gdb_test "print argarray\[3\]" \
279 "\\$\[0-9\]+ = 114$cr" \
280 "collect $msg: collected argarray #3"
281
282 gdb_test "tfind none" \
283 "#0 end .*" \
284 "collect $msg: cease trace debugging"
285}
286
287
288proc gdb_collect_locals_test { func mylocs msg } {
289 global cr
290 global gdb_prompt
291
6e79d367 292 prepare_for_trace_test
c906108c
SS
293
294 # Find the comment-identified line for setting this tracepoint.
295 set testline 0
0ab48859 296 gdb_test_multiple "list $func, +30" "collect $msg: find tracepoint line" {
c906108c
SS
297 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
298 set testline $expect_out(1,string)
299 pass "collect $msg: find tracepoint line"
300 }
301 -re ".*$gdb_prompt " {
302 fail "collect $msg: find tracepoint line (skipping locals test)"
303 return
304 }
305 timeout {
306 fail "collect $msg: find tracepoint line (skipping locals test)"
307 return
308 }
309 }
310
311 gdb_test "trace $testline" \
312 "Tracepoint \[0-9\]+ at .*" \
313 "collect $msg: set tracepoint"
314 gdb_trace_setactions "collect $msg: define actions" \
315 "" \
316 "collect $mylocs" "^$"
317
318 # Begin the test.
319 run_trace_experiment $msg $func
320
321 gdb_test "print locc" \
5f579bc5 322 "\\$\[0-9\]+ = 11 '.\[a-z0-7\]+'$cr" \
c906108c
SS
323 "collect $msg: collected local char"
324 gdb_test "print loci" \
325 "\\$\[0-9\]+ = 12$cr" \
326 "collect $msg: collected local int"
327 gdb_test "print locf" \
328 "\\$\[0-9\]+ = 13.\[23\]\[0-9\]*$cr" \
329 "collect $msg: collected local float"
330 gdb_test "print locd" \
331 "\\$\[0-9\]+ = 14.\[34\]\[0-9\]*$cr" \
332 "collect $msg: collected local double"
333
334 gdb_test "print locst.memberc" \
335 "\\$\[0-9\]+ = 15 '.017'$cr" \
336 "collect $msg: collected local member char"
337 gdb_test "print locst.memberi" \
338 "\\$\[0-9\]+ = 16$cr" \
339 "collect $msg: collected local member int"
340 gdb_test "print locst.memberf" \
341 "\\$\[0-9\]+ = 17.\[67\]\[0-9\]*$cr" \
342 "collect $msg: collected local member float"
343 gdb_test "print locst.memberd" \
344 "\\$\[0-9\]+ = 18.\[78\]\[0-9\]*$cr" \
345 "collect $msg: collected local member double"
346
347 gdb_test "print locar\[0\]" \
348 "\\$\[0-9\]+ = 121$cr" \
349 "collect $msg: collected locarray #0"
350 gdb_test "print locar\[1\]" \
351 "\\$\[0-9\]+ = 122$cr" \
352 "collect $msg: collected locarray #1"
353 gdb_test "print locar\[2\]" \
354 "\\$\[0-9\]+ = 123$cr" \
355 "collect $msg: collected locarray #2"
356 gdb_test "print locar\[3\]" \
357 "\\$\[0-9\]+ = 124$cr" \
358 "collect $msg: collected locarray #3"
359
360
361 gdb_test "tfind none" \
362 "#0 end .*" \
363 "collect $msg: cease trace debugging"
364}
365
366proc gdb_collect_registers_test { myregs } {
367 global cr
368 global gdb_prompt
6e79d367
PA
369 global fpreg
370 global spreg
371 global pcreg
c906108c 372
6e79d367 373 prepare_for_trace_test
c906108c
SS
374
375 # We'll simply re-use the args_test_function for this test
376 gdb_test "trace args_test_func" \
377 "Tracepoint \[0-9\]+ at .*" \
378 "collect $myregs: set tracepoint"
379 gdb_trace_setactions "collect $myregs: define actions" \
380 "" \
381 "collect $myregs" "^$"
382
383 # Begin the test.
384 run_trace_experiment $myregs args_test_func
385
6e79d367
PA
386 test_register "\$$fpreg" $myregs
387 test_register "\$$spreg" $myregs
388 test_register "\$$pcreg" $myregs
c906108c
SS
389
390 gdb_test "tfind none" \
391 "#0 end .*" \
392 "collect $myregs: cease trace debugging"
393}
394
395proc gdb_collect_expression_test { func expr val msg } {
396 global cr
397 global gdb_prompt
398
6e79d367 399 prepare_for_trace_test
c906108c
SS
400
401 # Find the comment-identified line for setting this tracepoint.
402 set testline 0
0ab48859 403 gdb_test_multiple "list $func, +30" "collect $msg: find tracepoint line" {
c906108c
SS
404 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
405 set testline $expect_out(1,string)
406 pass "collect $msg: find tracepoint line"
407 }
408 -re ".*$gdb_prompt " {
409 fail "collect $msg: find tracepoint line (skipping locals test)"
410 return
411 }
412 timeout {
413 fail "collect $msg: find tracepoint line (skipping locals test)"
414 return
415 }
416 }
417
418 gdb_test "trace $testline" \
419 "Tracepoint \[0-9\]+ at .*" \
420 "collect $msg: set tracepoint"
421 gdb_trace_setactions "collect $msg: define actions" \
422 "" \
423 "collect $expr" "^$"
424
425 # Begin the test.
426 run_trace_experiment $msg $func
427
428 gdb_test "print $expr" \
429 "\\$\[0-9\]+ = $val$cr" \
430 "collect $msg: got expected value '$val'"
431
432 gdb_test "tfind none" \
433 "#0 end .*" \
434 "collect $msg: cease trace debugging"
435}
436
437proc gdb_collect_globals_test { } {
438 global cr
439 global gdb_prompt
440
6e79d367 441 prepare_for_trace_test
c906108c
SS
442
443 # Find the comment-identified line for setting this tracepoint.
444 set testline 0
0ab48859 445 gdb_test_multiple "list globals_test_func, +30" "collect globals: find tracepoint line" {
c906108c
SS
446 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
447 set testline $expect_out(1,string)
448 pass "collect globals: find tracepoint line"
449 }
450 -re ".*$gdb_prompt " {
451 fail "collect globals: find tracepoint line (skipping global test)"
452 return
453 }
454 timeout {
455 fail "collect globals: find tracepoint line (skipping global test)"
456 return
457 }
458 }
459
08807d5a
PA
460 # Use use this to test collecting overlapping memory ranges
461 # (making use of UNOP_MEMVAL, as objects don't usually overlap
462 # other objects). Note that globalarr2 should not be collected in
463 # any other way so that a regression test below can be effective.
464
465 set globalarr2_addr ""
466 set test "get address of globalarr2"
467 gdb_test_multiple "p /x &globalarr2" $test {
468 -re " = (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
469 set globalarr2_addr $expect_out(1,string)
470 pass $test
471 }
472 }
473
c906108c
SS
474 gdb_test "trace $testline" \
475 "Tracepoint \[0-9\]+ at .*" \
476 "collect globals: set tracepoint"
477 gdb_trace_setactions "collect globals: define actions" \
478 "" \
479 "collect globalc, globali, globalf, globald" "^$" \
08807d5a
PA
480 "collect globalstruct, globalp, globalarr" "^$" \
481 "collect \{int \[4\]\}$globalarr2_addr" "^$" \
a0c78a73
PA
482 "collect \{int \[2\]\}$globalarr2_addr" "^$" \
483 "collect \{int \[4\]\}globalarr3" "^$"
c906108c
SS
484
485 # Begin the test.
486 run_trace_experiment "globals" globals_test_func
487
488 gdb_test "print globalc" \
489 "\\$\[0-9\]+ = 71 'G'$cr" \
490 "collect globals: collected global char"
491 gdb_test "print globali" \
492 "\\$\[0-9\]+ = 72$cr" \
493 "collect globals: collected global int"
494 gdb_test "print globalf" \
495 "\\$\[0-9\]+ = 73.\[23\]\[0-9\]*$cr" \
496 "collect globals: collected global float"
497 gdb_test "print globald" \
498 "\\$\[0-9\]+ = 74.\[34\]\[0-9\]*$cr" \
499 "collect globals: collected global double"
500
501 gdb_test "print globalstruct.memberc" \
502 "\\$\[0-9\]+ = 81 'Q'$cr" \
503 "collect globals: collected struct char member"
504 gdb_test "print globalstruct.memberi" \
505 "\\$\[0-9\]+ = 82$cr" \
506 "collect globals: collected struct member int"
507 gdb_test "print globalstruct.memberf" \
508 "\\$\[0-9\]+ = 83.\[23\]\[0-9\]*$cr" \
509 "collect globals: collected struct member float"
510 gdb_test "print globalstruct.memberd" \
511 "\\$\[0-9\]+ = 84.\[34\]\[0-9\]*$cr" \
512 "collect globals: collected struct member double"
513
514 gdb_test "print globalp == &globalstruct" \
515 "\\$\[0-9\]+ = 1$cr" \
516 "collect globals: collected global pointer"
517
518 gdb_test "print globalarr\[1\]" \
519 "\\$\[0-9\]+ = 1$cr" \
520 "collect globals: collected global array element #1"
521 gdb_test "print globalarr\[2\]" \
522 "\\$\[0-9\]+ = 2$cr" \
523 "collect globals: collected global array element #2"
524 gdb_test "print globalarr\[3\]" \
525 "\\$\[0-9\]+ = 3$cr" \
526 "collect globals: collected global array element #3"
527
08807d5a
PA
528 # Check that we didn't mess up sort&merging memory ranges to
529 # collect.
530 gdb_test "print globalarr2" \
531 "\\$\[0-9\]+ = \\{0, 1, 2, 3\\}$cr" \
532 "collect globals: collected global array 2"
533
a0c78a73
PA
534 # GDB would internal error collecting UNOP_MEMVAL's whose address
535 # expression wasn't an rvalue (that's regtested in the
536 # corresponding 'collect' action above). This just double checks
537 # we actually did collect what we wanted.
538 gdb_test "print globalarr3" \
539 "\\$\[0-9\]+ = \\{3, 2, 1, 0\\}$cr" \
540 "collect globals: collected global array 3"
541
c906108c
SS
542 gdb_test "tfind none" \
543 "#0 end .*" \
544 "collect globals: cease trace debugging"
545}
546
764880b7
PA
547# Test that when we've collected all fields of a structure
548# individually, we can print the whole structure in one go.
549proc gdb_collect_global_in_pieces_test { } {
550 global gdb_prompt
551
552 prepare_for_trace_test
553
554 # Find the comment-identified line for setting this tracepoint.
555 set testline 0
556 set msg "collect global in pieces: find tracepoint line"
557 gdb_test_multiple "list globals_test_func, +30" "$msg" {
558 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" {
559 set testline $expect_out(1,string)
560 pass "$msg"
561 }
562 }
563
564 if {$testline == 0} {
565 return
566 }
567
568 gdb_test "trace $testline" \
569 "Tracepoint \[0-9\]+ at .*" \
570 "collect global in pieces: set tracepoint"
571 gdb_trace_setactions "collect global in pieces: define actions" \
572 "" \
573 "collect global_pieces.a, global_pieces.b" \
574 "^$"
575
576 # Begin the test.
577 run_trace_experiment "global in pieces" globals_test_func
578
579 gdb_test "print /x global_pieces.a" " = 0x12345678" \
580 "collect global in pieces: print piece a"
581 gdb_test "print /x global_pieces.b" " = 0x87654321" \
582 "collect global in pieces: print piece b"
583
584 gdb_test "print /x global_pieces" " = \{a = 0x12345678, b = 0x87654321\}" \
585 "collect global in pieces: print whole object"
586
587 gdb_test "tfind none" "#0 end .*" \
588 "collect global in pieces: cease trace debugging"
589}
590
6710bf39
SS
591proc gdb_collect_return_test { } {
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 .*" {
610 pass "collect \$_ret: backtrace lists main"
611 }
612 -re ".*#1 .* in ?? .*" {
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
3065dfb6
SS
622proc 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
6e79d367
PA
665proc gdb_trace_collection_test {} {
666 global fpreg
667 global spreg
668 global pcreg
c906108c 669
c906108c
SS
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"
c906108c 697 gdb_collect_registers_test "\$regs"
6e79d367 698 gdb_collect_registers_test "\$$fpreg, \$$spreg, \$$pcreg"
c906108c 699 gdb_collect_globals_test
764880b7 700 gdb_collect_global_in_pieces_test
c906108c
SS
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
6710bf39 773 gdb_collect_return_test
3065dfb6
SS
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
c906108c
SS
781}
782
6e79d367
PA
783clean_restart $executable
784runto_main
785
786# We generously give ourselves one "pass" if we successfully
787# detect that this test cannot be run on this target!
788if { ![gdb_target_supports_trace] } then {
789 pass "Current target does not support trace"
790 return 1;
c906108c 791}
6e79d367 792
c906108c
SS
793# Body of test encased in a proc so we can return prematurely.
794gdb_trace_collection_test
795
796# Finished!
de7ff789 797gdb_test "tfind none" ".*" ""
This page took 1.744453 seconds and 4 git commands to generate.