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