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