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