daily update
[external/binutils.git] / gdb / testsuite / gdb.trace / collection.exp
1 # Copyright 1998, 2005, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 load_lib "trace-support.exp"
18
19 if $tracelevel then {
20         strace $tracelevel
21 }
22
23
24 set testfile "collection"
25 set srcfile ${testfile}.c
26 set executable $testfile
27 set binfile $objdir/$subdir/$executable
28
29 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
30         executable {debug nowarnings}] != "" } {
31     untested collection.exp
32     return -1
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
45 set ws "\[\r\n\t \]+"
46 set cr "\[\r\n\]+"
47
48 if [istarget "x86_64-*"] then {
49     set fpreg "rbp"
50     set spreg "rsp"
51     set pcreg "rip"
52 } elseif [istarget "i?86-*"] then {
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
62 #
63 # Utility procs
64 #
65
66 proc test_register { reg test_id } {
67     global cr
68     global gdb_prompt
69
70     gdb_test_multiple "print /x $reg" "" {
71         -re "\\$\[0-9\]+ = \[x0\]+$cr$gdb_prompt $" {
72             fail "collect $test_id: collected $reg (zero)"
73         }
74         -re "\\$\[0-9\]+ = \[x0-9a-fA-F\]+$cr$gdb_prompt $" {
75             pass "collect $test_id: collected $reg"
76         }
77         -re "\[Ee\]rror.*$gdb_prompt $" {
78             fail "collect $test_id: collected $reg (error)"
79         }
80     }
81 }
82
83 proc prepare_for_trace_test {} {
84     global executable
85
86     clean_restart $executable
87
88     runto_main
89
90     gdb_test "break begin" ".*" ""
91     gdb_test "break end" ".*" ""
92 }
93
94 proc run_trace_experiment { msg test_func } {
95     global gdb_prompt
96
97     gdb_test "continue" \
98         ".*Breakpoint \[0-9\]+, begin .*" \
99         "collect $msg: advance to begin"
100
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
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
124 proc gdb_collect_args_test { myargs msg } {
125     global cr
126     global gdb_prompt
127
128     prepare_for_trace_test
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)
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 "*-*-*"
177     gdb_test "print argarray\[0\]" \
178             "\\$\[0-9\]+ = 111$cr" \
179             "collect $msg: collected argarray #0"
180
181     setup_xfail "*-*-*"
182     gdb_test "print argarray\[1\]" \
183             "\\$\[0-9\]+ = 112$cr" \
184             "collect $msg: collected argarray #1"
185
186     setup_xfail "*-*-*"
187     gdb_test "print argarray\[2\]" \
188             "\\$\[0-9\]+ = 113$cr" \
189             "collect $msg: collected argarray #2"
190
191     setup_xfail "*-*-*"
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
201 proc gdb_collect_argstruct_test { myargs msg } {
202     global cr
203     global gdb_prompt
204
205     prepare_for_trace_test
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
237 proc gdb_collect_argarray_test { myargs msg } {
238     global cr
239     global gdb_prompt
240
241     prepare_for_trace_test
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
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 "*-*-*"
263     gdb_test "print argarray\[0\]" \
264             "\\$\[0-9\]+ = 111$cr" \
265             "collect $msg: collected argarray #0"
266
267     setup_xfail "*-*-*"
268     gdb_test "print argarray\[1\]" \
269             "\\$\[0-9\]+ = 112$cr" \
270             "collect $msg: collected argarray #1"
271
272     setup_xfail "*-*-*"
273     gdb_test "print argarray\[2\]" \
274             "\\$\[0-9\]+ = 113$cr" \
275             "collect $msg: collected argarray #2"
276
277     setup_xfail "*-*-*"
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
288 proc gdb_collect_locals_test { func mylocs msg } {
289     global cr
290     global gdb_prompt
291
292     prepare_for_trace_test
293
294     # Find the comment-identified line for setting this tracepoint.
295     set testline 0
296     gdb_test_multiple "list $func, +30" "collect $msg: find tracepoint line" {
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" \
322         "\\$\[0-9\]+ = 11 '.\[a-z0-7\]+'$cr" \
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
366 proc gdb_collect_registers_test { myregs } {
367     global cr
368     global gdb_prompt
369     global fpreg
370     global spreg
371     global pcreg
372
373     prepare_for_trace_test
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
386     test_register "\$$fpreg" $myregs
387     test_register "\$$spreg" $myregs
388     test_register "\$$pcreg" $myregs
389
390     gdb_test "tfind none" \
391             "#0  end .*" \
392             "collect $myregs: cease trace debugging"
393 }
394
395 proc gdb_collect_expression_test { func expr val msg } {
396     global cr
397     global gdb_prompt
398
399     prepare_for_trace_test
400
401     # Find the comment-identified line for setting this tracepoint.
402     set testline 0
403     gdb_test_multiple "list $func, +30" "collect $msg: find tracepoint line" {
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
437 proc gdb_collect_globals_test { } {
438     global cr
439     global gdb_prompt
440
441     prepare_for_trace_test
442
443     # Find the comment-identified line for setting this tracepoint.
444     set testline 0
445     gdb_test_multiple "list globals_test_func, +30" "collect globals: find tracepoint line" {
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
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
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" "^$" \
480             "collect globalstruct, globalp, globalarr" "^$" \
481             "collect \{int \[4\]\}$globalarr2_addr" "^$" \
482             "collect \{int \[2\]\}$globalarr2_addr" "^$" \
483             "collect \{int \[4\]\}globalarr3" "^$"
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
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
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
542     gdb_test "tfind none" \
543             "#0  end .*" \
544             "collect globals: cease trace debugging"
545 }
546
547 # Test that when we've collected all fields of a structure
548 # individually, we can print the whole structure in one go.
549 proc 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
591 proc gdb_trace_collection_test {} {
592     global fpreg
593     global spreg
594     global pcreg
595
596     gdb_collect_args_test "\$args" \
597             "args collectively"
598     gdb_collect_args_test "argc, argi, argf, argd, argstruct, argarray" \
599             "args individually"
600     gdb_collect_argstruct_test "\$args" \
601             "argstruct collectively"
602     gdb_collect_argstruct_test "argstruct" \
603             "argstruct individually"
604     gdb_collect_argarray_test "\$args" \
605             "argarray collectively"
606     gdb_collect_argarray_test "argarray" \
607             "argarray individually"
608     gdb_collect_locals_test local_test_func "\$locals" \
609             "auto locals collectively"
610     gdb_collect_locals_test local_test_func \
611             "locc, loci, locf, locd, locst, locar" \
612             "auto locals individually"
613     gdb_collect_locals_test reglocal_test_func "\$locals" \
614             "register locals collectively"
615     gdb_collect_locals_test reglocal_test_func \
616             "locc, loci, locf, locd, locst, locar" \
617             "register locals individually"
618     gdb_collect_locals_test statlocal_test_func "\$locals" \
619             "static locals collectively"
620     gdb_collect_locals_test statlocal_test_func \
621             "locc, loci, locf, locd, locst, locar" \
622             "static locals individually"
623     gdb_collect_registers_test "\$regs"
624     gdb_collect_registers_test "\$$fpreg, \$$spreg, \$$pcreg"
625     gdb_collect_globals_test
626     gdb_collect_global_in_pieces_test
627     
628     #
629     # Expression tests:
630     #
631     # *x        (**x, ...)
632     # x.y       (x.y.z, ...)
633     # x->y      (x->y->z, ...)
634     # x[2]      (x[2][3], ...) (const index)
635     # x[y]      (x[y][z], ...) (index to be char, short, long, float, double)
636     #  NOTE:
637     #  We test the following operators by using them in an array index
638     #  expression -- because the naked result of an operator is not really
639     #  collected.  To be sure the operator was evaluated correctly on the
640     #  target, we have to actually use the result eg. in an array offset
641     #  calculation.
642     # x[y +  z] (tests addition: y and z various combos of types, sclasses)
643     # x[y -  z] (tests subtraction) (ditto)
644     # x[y *  z] (tests multiplication) (ditto)
645     # x[y /  z] (tests division) (ditto)
646     # x[y %  z] (tests modulo division) (ditto)
647     # x[y == z] (tests equality relation) (ditto)              UNSUPPORTED
648     # x[y != z] (tests inequality relation) (ditto)            UNSUPPORTED
649     # x[y >  z] (tests greater-than relation) (ditto)          UNSUPPORTED
650     # x[y <  z] (tests less-than relation) (ditto)             UNSUPPORTED
651     # x[y >= z] (tests greater-than-or-equal relation) (ditto) UNSUPPORTED
652     # x[y <= z] (tests less-than-or-equal relation) (ditto)    UNSUPPORTED
653     # x[y && z] (tests logical and) (ditto)                    UNSUPPORTED
654     # x[y || z] (tests logical or) (ditto)                     UNSUPPORTED
655     # x[y &  z] (tests binary and) (ditto)                     UNSUPPORTED
656     # x[y |  z] (tests binary or) (ditto)                      UNSUPPORTED
657     # x[y ^  z] (tests binary xor) (ditto)                     UNSUPPORTED
658     # x[y ? z1 : z2] (tests ternary operator) (ditto)          UNSUPPORTED
659     # x[y << z] (tests shift-left) (ditto)                     UNSUPPORTED
660     # x[y >> z] (tests shift-right) (ditto)                    UNSUPPORTED
661     # x[y =  z] (tests assignment operator) (ditto)            UNSUPPORTED
662     # x[++y]    (tests pre-increment operator) (ditto)         UNSUPPORTED
663     # x[--y]    (tests pre-decrement operator) (ditto)         UNSUPPORTED
664     # x[y++]    (tests post-increment operator) (ditto)        UNSUPPORTED
665     # x[y--]    (tests post-decrement operator) (ditto)        UNSUPPORTED
666     # x[+y]     (tests unary plus) (ditto)
667     # x[-y]     (tests unary minus) (ditto)
668     # x[!y]     (tests logical not) (ditto)                    UNSUPPORTED
669     # x[~y]     (tests binary not) (ditto)                     UNSUPPORTED
670     # x[(y, z)] (tests comma expression) (ditto)
671     # cast expr
672     # stack data
673     
674     gdb_collect_expression_test globals_test_func \
675             "globalstruct.memberi"  "82"     "a.b"
676     gdb_collect_expression_test globals_test_func \
677             "globalp->memberc"      "81 'Q'" "a->b"
678     gdb_collect_expression_test globals_test_func \
679             "globalarr\[2\]"        "2"      "a\[2\]"
680     gdb_collect_expression_test globals_test_func \
681             "globalarr\[l3\]"       "3"      "a\[b\]"
682     gdb_collect_expression_test globals_test_func \
683             "globalarr\[l3 + l2\]"  "5"      "a\[b + c\]"
684     gdb_collect_expression_test globals_test_func \
685             "globalarr\[l3 - l2\]"  "1"      "a\[b - c\]"
686     gdb_collect_expression_test globals_test_func \
687             "globalarr\[l3 * l2\]"  "6"      "a\[b * c\]"
688     gdb_collect_expression_test globals_test_func \
689             "globalarr\[l6 / l3\]"  "2"      "a\[b / c\]"
690     gdb_collect_expression_test globals_test_func \
691             "globalarr\[l7 % l3\]"  "1"      "a\[b % c\]"
692     gdb_collect_expression_test globals_test_func \
693             "globalarr\[+l1\]"      "1"      "a\[+b\]"
694     gdb_collect_expression_test globals_test_func \
695             "globalarr\[-lminus\]"  "2"      "a\[-b\]"
696     gdb_collect_expression_test globals_test_func \
697             "globalarr\[\(l6, l7\)\]" "7"    "a\[\(b, c\)\]"
698
699 }
700
701 clean_restart $executable
702 runto_main
703
704 # We generously give ourselves one "pass" if we successfully
705 # detect that this test cannot be run on this target!
706 if { ![gdb_target_supports_trace] } then {
707     pass "Current target does not support trace"
708     return 1;
709 }
710
711 # Body of test encased in a proc so we can return prematurely.
712 gdb_trace_collection_test
713
714 # Finished!
715 gdb_test "tfind none" ".*" ""