Commit | Line | Data |
---|---|---|
9b254dd1 | 1 | # Copyright 1998, 2005, 2007, 2008 Free Software Foundation, Inc. |
c906108c SS |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c SS |
16 | if [istarget "m68k-*-elf"] then { |
17 | pass "Test not supported on this target" | |
18 | return; | |
19 | } | |
20 | ||
21 | load_lib "trace-support.exp" | |
22 | ||
23 | if $tracelevel then { | |
24 | strace $tracelevel | |
25 | } | |
26 | ||
27 | set prms_id 0 | |
28 | set bug_id 0 | |
29 | ||
30 | set testfile "collection" | |
31 | set srcfile ${testfile}.c | |
32 | set binfile $objdir/$subdir/$testfile | |
33 | ||
34 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
fc91c6c2 | 35 | executable {debug nowarnings}] != "" } { |
b60f0898 JB |
36 | untested collection.exp |
37 | return -1 | |
c906108c SS |
38 | } |
39 | ||
40 | # Tests: | |
41 | # 1) $args | |
42 | # 2) function args by name | |
43 | # 3) $locs | |
44 | # 4) function locals by name | |
45 | # 5) $regs | |
46 | # 6) registers by name ($sp, $fp?) | |
47 | # 7) globals by name | |
48 | # 8) expressions (lots of different kinds: local and global) | |
49 | ||
50 | set ws "\[\r\n\t \]+" | |
51 | set cr "\[\r\n\]+" | |
52 | ||
53 | # | |
54 | # Utility procs | |
55 | # | |
56 | ||
57 | proc test_register { reg test_id } { | |
58 | global cr | |
59 | global gdb_prompt | |
60 | ||
61 | send_gdb "print $reg\n" | |
62 | gdb_expect { | |
63 | -re "\\$\[0-9\]+ = \[x0\]+$cr$gdb_prompt " { | |
64 | fail "collect $test_id: collected $reg (zero)" | |
65 | } | |
66 | -re "\\$\[0-9\]+ = \[x0-9a-fA-F\]+$cr$gdb_prompt " { | |
67 | pass "collect $test_id: collected $reg" | |
68 | } | |
69 | -re "\[Ee\]rror.*$gdb_prompt " { | |
70 | fail "collect $test_id: collected $reg (error)" | |
71 | } | |
72 | timeout { | |
73 | fail "collect $test_id: collected $reg (timeout)" | |
74 | } | |
75 | } | |
76 | } | |
77 | ||
78 | proc run_trace_experiment { msg test_func } { | |
5f579bc5 NS |
79 | global gdb_prompt |
80 | gdb_run_cmd | |
81 | gdb_expect { | |
82 | -re ".*Breakpoint \[0-9\]+, begin .*$gdb_prompt $" { | |
83 | } | |
84 | -re ".*$gdb_prompt $" { | |
85 | fail "collect $msg: advance to go" | |
86 | } | |
87 | timeout { | |
88 | fail "collect $msg: advance to go (timeout)" | |
89 | } | |
90 | } | |
c906108c SS |
91 | gdb_test "tstart" \ |
92 | "\[\r\n\]+" \ | |
93 | "collect $msg: start trace experiment" | |
94 | gdb_test "continue" \ | |
95 | "Continuing.*Breakpoint \[0-9\]+, end.*" \ | |
96 | "collect $msg: run trace experiment" | |
97 | gdb_test "tstop" \ | |
98 | "\[\r\n\]+" \ | |
99 | "collect $msg: stop trace experiment" | |
100 | gdb_test "tfind start" \ | |
101 | "#0 $test_func .*" \ | |
102 | "collect $msg: tfind test frame" | |
103 | } | |
104 | ||
105 | ||
106 | # | |
107 | # Test procs | |
108 | # | |
109 | ||
110 | proc gdb_collect_args_test { myargs msg } { | |
111 | global cr | |
112 | global gdb_prompt | |
113 | ||
114 | # Make sure we're in a sane starting state. | |
115 | gdb_test "tstop" "" "" | |
116 | gdb_test "tfind none" "" "" | |
117 | gdb_delete_tracepoints | |
118 | ||
119 | gdb_test "trace args_test_func" \ | |
120 | "Tracepoint \[0-9\]+ at .*" \ | |
121 | "collect $msg: set tracepoint" | |
122 | gdb_trace_setactions "collect $msg: define actions" \ | |
123 | "" \ | |
124 | "collect $myargs" "^$" | |
125 | ||
126 | # Begin the test. | |
127 | run_trace_experiment $msg args_test_func | |
128 | ||
129 | gdb_test "print argc" \ | |
130 | "\\$\[0-9\]+ = 1 '.001'$cr" \ | |
131 | "collect $msg: collected arg char" | |
132 | gdb_test "print argi" \ | |
133 | "\\$\[0-9\]+ = 2$cr" \ | |
134 | "collect $msg: collected arg int" | |
135 | gdb_test "print argf" \ | |
136 | "\\$\[0-9\]+ = 3.\[23\]\[0-9\]*$cr" \ | |
137 | "collect $msg: collected arg float" | |
138 | gdb_test "print argd" \ | |
139 | "\\$\[0-9\]+ = 4.\[34\]\[0-9\]*$cr" \ | |
140 | "collect $msg: collected arg double" | |
141 | ||
142 | # struct arg as one of several args (near end of list) | |
143 | gdb_test "print argstruct.memberc" \ | |
144 | "\\$\[0-9\]+ = 101 'e'$cr" \ | |
145 | "collect $msg: collected arg struct member char" | |
146 | gdb_test "print argstruct.memberi" \ | |
147 | "\\$\[0-9\]+ = 102$cr" \ | |
148 | "collect $msg: collected arg struct member int" | |
149 | gdb_test "print argstruct.memberf" \ | |
150 | "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*$cr" \ | |
151 | "collect $msg: collected arg struct member float" | |
152 | gdb_test "print argstruct.memberd" \ | |
153 | "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*$cr" \ | |
154 | "collect $msg: collected arg struct member double" | |
155 | ||
156 | # array arg as one of several args (near end of list) | |
157 | gdb_test "print argarray\[0\]" \ | |
158 | "\\$\[0-9\]+ = 111$cr" \ | |
159 | "collect $msg: collected argarray #0" | |
160 | gdb_test "print argarray\[1\]" \ | |
161 | "\\$\[0-9\]+ = 112$cr" \ | |
162 | "collect $msg: collected argarray #1" | |
163 | gdb_test "print argarray\[2\]" \ | |
164 | "\\$\[0-9\]+ = 113$cr" \ | |
165 | "collect $msg: collected argarray #2" | |
166 | gdb_test "print argarray\[3\]" \ | |
167 | "\\$\[0-9\]+ = 114$cr" \ | |
168 | "collect $msg: collected argarray #3" | |
169 | ||
170 | gdb_test "tfind none" \ | |
171 | "#0 end .*" \ | |
172 | "collect $msg: cease trace debugging" | |
173 | } | |
174 | ||
175 | proc gdb_collect_argstruct_test { myargs msg } { | |
176 | global cr | |
177 | global gdb_prompt | |
178 | ||
179 | # Make sure we're in a sane starting state. | |
180 | gdb_test "tstop" "" "" | |
181 | gdb_test "tfind none" "" "" | |
182 | gdb_delete_tracepoints | |
183 | ||
184 | gdb_test "trace argstruct_test_func" \ | |
185 | "Tracepoint \[0-9\]+ at .*" \ | |
186 | "collect $msg: set tracepoint" | |
187 | gdb_trace_setactions "collect $msg: define actions" \ | |
188 | "" \ | |
189 | "collect $myargs" "^$" | |
190 | ||
191 | # Begin the test. | |
192 | run_trace_experiment $msg argstruct_test_func | |
193 | ||
194 | # struct argument as only argument | |
195 | gdb_test "print argstruct.memberc" \ | |
196 | "\\$\[0-9\]+ = 101 'e'$cr" \ | |
197 | "collect $msg: collected arg struct member char" | |
198 | gdb_test "print argstruct.memberi" \ | |
199 | "\\$\[0-9\]+ = 102$cr" \ | |
200 | "collect $msg: collected arg struct member int" | |
201 | gdb_test "print argstruct.memberf" \ | |
202 | "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*$cr" \ | |
203 | "collect $msg: collected arg struct member float" | |
204 | gdb_test "print argstruct.memberd" \ | |
205 | "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*$cr" \ | |
206 | "collect $msg: collected arg struct member double" | |
207 | ||
208 | gdb_test "tfind none" \ | |
209 | "#0 end .*" \ | |
210 | "collect $msg: cease trace debugging" | |
211 | } | |
212 | ||
213 | ||
214 | proc gdb_collect_argarray_test { myargs msg } { | |
215 | global cr | |
216 | global gdb_prompt | |
217 | ||
218 | # Make sure we're in a sane starting state. | |
219 | gdb_test "tstop" "" "" | |
220 | gdb_test "tfind none" "" "" | |
221 | gdb_delete_tracepoints | |
222 | ||
223 | gdb_test "trace argarray_test_func" \ | |
224 | "Tracepoint \[0-9\]+ at .*" \ | |
225 | "collect $msg: set tracepoint" | |
226 | gdb_trace_setactions "collect $msg: define actions" \ | |
227 | "" \ | |
228 | "collect $myargs" "^$" | |
229 | ||
230 | # Begin the test. | |
231 | run_trace_experiment $msg argarray_test_func | |
232 | ||
233 | # array arg as only argument | |
234 | gdb_test "print argarray\[0\]" \ | |
235 | "\\$\[0-9\]+ = 111$cr" \ | |
236 | "collect $msg: collected argarray #0" | |
237 | gdb_test "print argarray\[1\]" \ | |
238 | "\\$\[0-9\]+ = 112$cr" \ | |
239 | "collect $msg: collected argarray #1" | |
240 | gdb_test "print argarray\[2\]" \ | |
241 | "\\$\[0-9\]+ = 113$cr" \ | |
242 | "collect $msg: collected argarray #2" | |
243 | gdb_test "print argarray\[3\]" \ | |
244 | "\\$\[0-9\]+ = 114$cr" \ | |
245 | "collect $msg: collected argarray #3" | |
246 | ||
247 | gdb_test "tfind none" \ | |
248 | "#0 end .*" \ | |
249 | "collect $msg: cease trace debugging" | |
250 | } | |
251 | ||
252 | ||
253 | proc gdb_collect_locals_test { func mylocs msg } { | |
254 | global cr | |
255 | global gdb_prompt | |
256 | ||
257 | # Make sure we're in a sane starting state. | |
258 | gdb_test "tstop" "" "" | |
259 | gdb_test "tfind none" "" "" | |
260 | gdb_delete_tracepoints | |
261 | ||
262 | # Find the comment-identified line for setting this tracepoint. | |
263 | set testline 0 | |
264 | send_gdb "list $func, +30\n" | |
265 | gdb_expect { | |
266 | -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" { | |
267 | set testline $expect_out(1,string) | |
268 | pass "collect $msg: find tracepoint line" | |
269 | } | |
270 | -re ".*$gdb_prompt " { | |
271 | fail "collect $msg: find tracepoint line (skipping locals test)" | |
272 | return | |
273 | } | |
274 | timeout { | |
275 | fail "collect $msg: find tracepoint line (skipping locals test)" | |
276 | return | |
277 | } | |
278 | } | |
279 | ||
280 | gdb_test "trace $testline" \ | |
281 | "Tracepoint \[0-9\]+ at .*" \ | |
282 | "collect $msg: set tracepoint" | |
283 | gdb_trace_setactions "collect $msg: define actions" \ | |
284 | "" \ | |
285 | "collect $mylocs" "^$" | |
286 | ||
287 | # Begin the test. | |
288 | run_trace_experiment $msg $func | |
289 | ||
290 | gdb_test "print locc" \ | |
5f579bc5 | 291 | "\\$\[0-9\]+ = 11 '.\[a-z0-7\]+'$cr" \ |
c906108c SS |
292 | "collect $msg: collected local char" |
293 | gdb_test "print loci" \ | |
294 | "\\$\[0-9\]+ = 12$cr" \ | |
295 | "collect $msg: collected local int" | |
296 | gdb_test "print locf" \ | |
297 | "\\$\[0-9\]+ = 13.\[23\]\[0-9\]*$cr" \ | |
298 | "collect $msg: collected local float" | |
299 | gdb_test "print locd" \ | |
300 | "\\$\[0-9\]+ = 14.\[34\]\[0-9\]*$cr" \ | |
301 | "collect $msg: collected local double" | |
302 | ||
303 | gdb_test "print locst.memberc" \ | |
304 | "\\$\[0-9\]+ = 15 '.017'$cr" \ | |
305 | "collect $msg: collected local member char" | |
306 | gdb_test "print locst.memberi" \ | |
307 | "\\$\[0-9\]+ = 16$cr" \ | |
308 | "collect $msg: collected local member int" | |
309 | gdb_test "print locst.memberf" \ | |
310 | "\\$\[0-9\]+ = 17.\[67\]\[0-9\]*$cr" \ | |
311 | "collect $msg: collected local member float" | |
312 | gdb_test "print locst.memberd" \ | |
313 | "\\$\[0-9\]+ = 18.\[78\]\[0-9\]*$cr" \ | |
314 | "collect $msg: collected local member double" | |
315 | ||
316 | gdb_test "print locar\[0\]" \ | |
317 | "\\$\[0-9\]+ = 121$cr" \ | |
318 | "collect $msg: collected locarray #0" | |
319 | gdb_test "print locar\[1\]" \ | |
320 | "\\$\[0-9\]+ = 122$cr" \ | |
321 | "collect $msg: collected locarray #1" | |
322 | gdb_test "print locar\[2\]" \ | |
323 | "\\$\[0-9\]+ = 123$cr" \ | |
324 | "collect $msg: collected locarray #2" | |
325 | gdb_test "print locar\[3\]" \ | |
326 | "\\$\[0-9\]+ = 124$cr" \ | |
327 | "collect $msg: collected locarray #3" | |
328 | ||
329 | ||
330 | gdb_test "tfind none" \ | |
331 | "#0 end .*" \ | |
332 | "collect $msg: cease trace debugging" | |
333 | } | |
334 | ||
335 | proc gdb_collect_registers_test { myregs } { | |
336 | global cr | |
337 | global gdb_prompt | |
338 | ||
339 | # Make sure we're in a sane starting state. | |
340 | gdb_test "tstop" "" "" | |
341 | gdb_test "tfind none" "" "" | |
342 | gdb_delete_tracepoints | |
343 | ||
344 | # We'll simply re-use the args_test_function for this test | |
345 | gdb_test "trace args_test_func" \ | |
346 | "Tracepoint \[0-9\]+ at .*" \ | |
347 | "collect $myregs: set tracepoint" | |
348 | gdb_trace_setactions "collect $myregs: define actions" \ | |
349 | "" \ | |
350 | "collect $myregs" "^$" | |
351 | ||
352 | # Begin the test. | |
353 | run_trace_experiment $myregs args_test_func | |
354 | ||
355 | test_register "\$fp" $myregs | |
356 | test_register "\$sp" $myregs | |
357 | test_register "\$pc" $myregs | |
358 | ||
359 | gdb_test "tfind none" \ | |
360 | "#0 end .*" \ | |
361 | "collect $myregs: cease trace debugging" | |
362 | } | |
363 | ||
364 | proc gdb_collect_expression_test { func expr val msg } { | |
365 | global cr | |
366 | global gdb_prompt | |
367 | ||
368 | # Make sure we're in a sane starting state. | |
369 | gdb_test "tstop" "" "" | |
370 | gdb_test "tfind none" "" "" | |
371 | gdb_delete_tracepoints | |
372 | ||
373 | # Find the comment-identified line for setting this tracepoint. | |
374 | set testline 0 | |
375 | send_gdb "list $func, +30\n" | |
376 | gdb_expect { | |
377 | -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" { | |
378 | set testline $expect_out(1,string) | |
379 | pass "collect $msg: find tracepoint line" | |
380 | } | |
381 | -re ".*$gdb_prompt " { | |
382 | fail "collect $msg: find tracepoint line (skipping locals test)" | |
383 | return | |
384 | } | |
385 | timeout { | |
386 | fail "collect $msg: find tracepoint line (skipping locals test)" | |
387 | return | |
388 | } | |
389 | } | |
390 | ||
391 | gdb_test "trace $testline" \ | |
392 | "Tracepoint \[0-9\]+ at .*" \ | |
393 | "collect $msg: set tracepoint" | |
394 | gdb_trace_setactions "collect $msg: define actions" \ | |
395 | "" \ | |
396 | "collect $expr" "^$" | |
397 | ||
398 | # Begin the test. | |
399 | run_trace_experiment $msg $func | |
400 | ||
401 | gdb_test "print $expr" \ | |
402 | "\\$\[0-9\]+ = $val$cr" \ | |
403 | "collect $msg: got expected value '$val'" | |
404 | ||
405 | gdb_test "tfind none" \ | |
406 | "#0 end .*" \ | |
407 | "collect $msg: cease trace debugging" | |
408 | } | |
409 | ||
410 | proc gdb_collect_globals_test { } { | |
411 | global cr | |
412 | global gdb_prompt | |
413 | ||
414 | # Make sure we're in a sane starting state. | |
415 | gdb_test "tstop" "" "" | |
416 | gdb_test "tfind none" "" "" | |
417 | gdb_delete_tracepoints | |
418 | ||
419 | # Find the comment-identified line for setting this tracepoint. | |
420 | set testline 0 | |
421 | send_gdb "list globals_test_func, +30\n" | |
422 | gdb_expect { | |
423 | -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+ Set_Tracepoint_Here .*$gdb_prompt" { | |
424 | set testline $expect_out(1,string) | |
425 | pass "collect globals: find tracepoint line" | |
426 | } | |
427 | -re ".*$gdb_prompt " { | |
428 | fail "collect globals: find tracepoint line (skipping global test)" | |
429 | return | |
430 | } | |
431 | timeout { | |
432 | fail "collect globals: find tracepoint line (skipping global test)" | |
433 | return | |
434 | } | |
435 | } | |
436 | ||
437 | gdb_test "trace $testline" \ | |
438 | "Tracepoint \[0-9\]+ at .*" \ | |
439 | "collect globals: set tracepoint" | |
440 | gdb_trace_setactions "collect globals: define actions" \ | |
441 | "" \ | |
442 | "collect globalc, globali, globalf, globald" "^$" \ | |
443 | "collect globalstruct, globalp, globalarr" "^$" | |
444 | ||
445 | # Begin the test. | |
446 | run_trace_experiment "globals" globals_test_func | |
447 | ||
448 | gdb_test "print globalc" \ | |
449 | "\\$\[0-9\]+ = 71 'G'$cr" \ | |
450 | "collect globals: collected global char" | |
451 | gdb_test "print globali" \ | |
452 | "\\$\[0-9\]+ = 72$cr" \ | |
453 | "collect globals: collected global int" | |
454 | gdb_test "print globalf" \ | |
455 | "\\$\[0-9\]+ = 73.\[23\]\[0-9\]*$cr" \ | |
456 | "collect globals: collected global float" | |
457 | gdb_test "print globald" \ | |
458 | "\\$\[0-9\]+ = 74.\[34\]\[0-9\]*$cr" \ | |
459 | "collect globals: collected global double" | |
460 | ||
461 | gdb_test "print globalstruct.memberc" \ | |
462 | "\\$\[0-9\]+ = 81 'Q'$cr" \ | |
463 | "collect globals: collected struct char member" | |
464 | gdb_test "print globalstruct.memberi" \ | |
465 | "\\$\[0-9\]+ = 82$cr" \ | |
466 | "collect globals: collected struct member int" | |
467 | gdb_test "print globalstruct.memberf" \ | |
468 | "\\$\[0-9\]+ = 83.\[23\]\[0-9\]*$cr" \ | |
469 | "collect globals: collected struct member float" | |
470 | gdb_test "print globalstruct.memberd" \ | |
471 | "\\$\[0-9\]+ = 84.\[34\]\[0-9\]*$cr" \ | |
472 | "collect globals: collected struct member double" | |
473 | ||
474 | gdb_test "print globalp == &globalstruct" \ | |
475 | "\\$\[0-9\]+ = 1$cr" \ | |
476 | "collect globals: collected global pointer" | |
477 | ||
478 | gdb_test "print globalarr\[1\]" \ | |
479 | "\\$\[0-9\]+ = 1$cr" \ | |
480 | "collect globals: collected global array element #1" | |
481 | gdb_test "print globalarr\[2\]" \ | |
482 | "\\$\[0-9\]+ = 2$cr" \ | |
483 | "collect globals: collected global array element #2" | |
484 | gdb_test "print globalarr\[3\]" \ | |
485 | "\\$\[0-9\]+ = 3$cr" \ | |
486 | "collect globals: collected global array element #3" | |
487 | ||
488 | gdb_test "tfind none" \ | |
489 | "#0 end .*" \ | |
490 | "collect globals: cease trace debugging" | |
491 | } | |
492 | ||
493 | proc gdb_trace_collection_test { } { | |
494 | global gdb_prompt; | |
495 | ||
496 | gdb_test "set width 0" "" "" | |
497 | delete_breakpoints | |
498 | ||
499 | # We generously give ourselves one "pass" if we successfully | |
500 | # detect that this test cannot be run on this target! | |
501 | if { ![gdb_target_supports_trace] } then { | |
0ef2251b | 502 | pass "Current target does not support trace" |
c906108c SS |
503 | return 1; |
504 | } | |
505 | ||
506 | gdb_test "break begin" "" "" | |
507 | gdb_test "break end" "" "" | |
508 | gdb_collect_args_test "\$args" \ | |
509 | "args collectively" | |
510 | gdb_collect_args_test "argc, argi, argf, argd, argstruct, argarray" \ | |
511 | "args individually" | |
512 | gdb_collect_argstruct_test "\$args" \ | |
513 | "argstruct collectively" | |
514 | gdb_collect_argstruct_test "argstruct" \ | |
515 | "argstruct individually" | |
516 | gdb_collect_argarray_test "\$args" \ | |
517 | "argarray collectively" | |
518 | gdb_collect_argarray_test "argarray" \ | |
519 | "argarray individually" | |
520 | gdb_collect_locals_test local_test_func "\$locals" \ | |
521 | "auto locals collectively" | |
522 | gdb_collect_locals_test local_test_func \ | |
523 | "locc, loci, locf, locd, locst, locar" \ | |
524 | "auto locals individually" | |
525 | gdb_collect_locals_test reglocal_test_func "\$locals" \ | |
526 | "register locals collectively" | |
527 | gdb_collect_locals_test reglocal_test_func \ | |
528 | "locc, loci, locf, locd, locst, locar" \ | |
529 | "register locals individually" | |
530 | gdb_collect_locals_test statlocal_test_func "\$locals" \ | |
531 | "static locals collectively" | |
532 | gdb_collect_locals_test statlocal_test_func \ | |
533 | "locc, loci, locf, locd, locst, locar" \ | |
534 | "static locals individually" | |
535 | ||
536 | gdb_collect_registers_test "\$regs" | |
537 | gdb_collect_registers_test "\$fp, \$sp, \$pc" | |
538 | gdb_collect_globals_test | |
539 | ||
540 | # | |
541 | # Expression tests: | |
542 | # | |
543 | # *x (**x, ...) | |
544 | # x.y (x.y.z, ...) | |
545 | # x->y (x->y->z, ...) | |
546 | # x[2] (x[2][3], ...) (const index) | |
547 | # x[y] (x[y][z], ...) (index to be char, short, long, float, double) | |
548 | # NOTE: | |
549 | # We test the following operators by using them in an array index | |
550 | # expression -- because the naked result of an operator is not really | |
551 | # collected. To be sure the operator was evaluated correctly on the | |
552 | # target, we have to actually use the result eg. in an array offset | |
553 | # calculation. | |
554 | # x[y + z] (tests addition: y and z various combos of types, sclasses) | |
555 | # x[y - z] (tests subtraction) (ditto) | |
556 | # x[y * z] (tests multiplication) (ditto) | |
557 | # x[y / z] (tests division) (ditto) | |
558 | # x[y % z] (tests modulo division) (ditto) | |
559 | # x[y == z] (tests equality relation) (ditto) UNSUPPORTED | |
560 | # x[y != z] (tests inequality relation) (ditto) UNSUPPORTED | |
561 | # x[y > z] (tests greater-than relation) (ditto) UNSUPPORTED | |
562 | # x[y < z] (tests less-than relation) (ditto) UNSUPPORTED | |
563 | # x[y >= z] (tests greater-than-or-equal relation) (ditto) UNSUPPORTED | |
564 | # x[y <= z] (tests less-than-or-equal relation) (ditto) UNSUPPORTED | |
565 | # x[y && z] (tests logical and) (ditto) UNSUPPORTED | |
566 | # x[y || z] (tests logical or) (ditto) UNSUPPORTED | |
567 | # x[y & z] (tests binary and) (ditto) UNSUPPORTED | |
568 | # x[y | z] (tests binary or) (ditto) UNSUPPORTED | |
569 | # x[y ^ z] (tests binary xor) (ditto) UNSUPPORTED | |
570 | # x[y ? z1 : z2] (tests ternary operator) (ditto) UNSUPPORTED | |
571 | # x[y << z] (tests shift-left) (ditto) UNSUPPORTED | |
572 | # x[y >> z] (tests shift-right) (ditto) UNSUPPORTED | |
573 | # x[y = z] (tests assignment operator) (ditto) UNSUPPORTED | |
574 | # x[++y] (tests pre-increment operator) (ditto) UNSUPPORTED | |
575 | # x[--y] (tests pre-decrement operator) (ditto) UNSUPPORTED | |
576 | # x[y++] (tests post-increment operator) (ditto) UNSUPPORTED | |
577 | # x[y--] (tests post-decrement operator) (ditto) UNSUPPORTED | |
578 | # x[+y] (tests unary plus) (ditto) | |
579 | # x[-y] (tests unary minus) (ditto) | |
580 | # x[!y] (tests logical not) (ditto) UNSUPPORTED | |
581 | # x[~y] (tests binary not) (ditto) UNSUPPORTED | |
582 | # x[(y, z)] (tests comma expression) (ditto) | |
583 | # cast expr | |
584 | # stack data | |
585 | ||
586 | gdb_collect_expression_test globals_test_func \ | |
587 | "globalstruct.memberi" "82" "a.b" | |
588 | gdb_collect_expression_test globals_test_func \ | |
589 | "globalp->memberc" "81 'Q'" "a->b" | |
590 | gdb_collect_expression_test globals_test_func \ | |
591 | "globalarr\[2\]" "2" "a\[2\]" | |
592 | gdb_collect_expression_test globals_test_func \ | |
593 | "globalarr\[l3\]" "3" "a\[b\]" | |
594 | gdb_collect_expression_test globals_test_func \ | |
595 | "globalarr\[l3 + l2\]" "5" "a\[b + c\]" | |
596 | gdb_collect_expression_test globals_test_func \ | |
597 | "globalarr\[l3 - l2\]" "1" "a\[b - c\]" | |
598 | gdb_collect_expression_test globals_test_func \ | |
599 | "globalarr\[l3 * l2\]" "6" "a\[b * c\]" | |
600 | gdb_collect_expression_test globals_test_func \ | |
601 | "globalarr\[l6 / l3\]" "2" "a\[b / c\]" | |
602 | gdb_collect_expression_test globals_test_func \ | |
603 | "globalarr\[l7 % l3\]" "1" "a\[b % c\]" | |
604 | gdb_collect_expression_test globals_test_func \ | |
605 | "globalarr\[+l1\]" "1" "a\[+b\]" | |
606 | gdb_collect_expression_test globals_test_func \ | |
607 | "globalarr\[-lminus\]" "2" "a\[-b\]" | |
608 | gdb_collect_expression_test globals_test_func \ | |
609 | "globalarr\[\(l6, l7\)\]" "7" "a\[\(b, c\)\]" | |
610 | ||
611 | } | |
612 | ||
613 | # Start with a fresh gdb. | |
614 | ||
615 | gdb_exit | |
616 | gdb_start | |
617 | gdb_reinitialize_dir $srcdir/$subdir | |
618 | gdb_load $binfile | |
619 | ||
620 | if [target_info exists gdb_stub] { | |
621 | gdb_step_for_stub; | |
622 | } | |
623 | ||
624 | # Body of test encased in a proc so we can return prematurely. | |
625 | gdb_trace_collection_test | |
626 | ||
627 | # Finished! | |
628 | gdb_test "tfind none" "" "" | |
629 | ||
630 | ||
631 |