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