1 |
330 |
jeremybenn |
# Copyright 1998, 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 |
|
|
# This file was written by Michael Snyder (msnyder@cygnus.com)
|
17 |
|
|
|
18 |
|
|
load_lib "trace-support.exp";
|
19 |
|
|
|
20 |
|
|
if $tracelevel then {
|
21 |
|
|
strace $tracelevel
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
gdb_exit
|
26 |
|
|
gdb_start
|
27 |
|
|
|
28 |
|
|
set testfile "actions"
|
29 |
|
|
set srcfile ${testfile}.c
|
30 |
|
|
set binfile $objdir/$subdir/report
|
31 |
|
|
if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
|
32 |
|
|
executable {debug nowarnings}] != "" } {
|
33 |
|
|
untested report.exp
|
34 |
|
|
return -1
|
35 |
|
|
}
|
36 |
|
|
gdb_load $binfile
|
37 |
|
|
gdb_test "tstop" ".*" ""
|
38 |
|
|
gdb_test "tfind none" ".*" ""
|
39 |
|
|
runto_main
|
40 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
41 |
|
|
|
42 |
|
|
# We generously give ourselves one "pass" if we successfully
|
43 |
|
|
# detect that this test cannot be run on this target!
|
44 |
|
|
if { ![gdb_target_supports_trace] } then {
|
45 |
|
|
pass "Current target does not support trace"
|
46 |
|
|
return 1;
|
47 |
|
|
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
set cr "\[\r\n\]+"
|
51 |
|
|
|
52 |
|
|
# If testing on a remote host, download the source file.
|
53 |
|
|
# remote_download host $srcdir/$subdir/$srcfile
|
54 |
|
|
|
55 |
|
|
#
|
56 |
|
|
# test general reporting of trace experiment results
|
57 |
|
|
#
|
58 |
|
|
|
59 |
|
|
set testline1 0
|
60 |
|
|
set testline2 0
|
61 |
|
|
set testline3 0
|
62 |
|
|
set testline4 0
|
63 |
|
|
set testline5 0
|
64 |
|
|
set testline6 0
|
65 |
|
|
|
66 |
|
|
set arg1 1
|
67 |
|
|
set arg2 2
|
68 |
|
|
set arg3 3
|
69 |
|
|
set arg4 4
|
70 |
|
|
set arg5 5
|
71 |
|
|
set arg6 6
|
72 |
|
|
|
73 |
|
|
set gdb_recursion_test_baseline [gdb_find_recursion_test_baseline $srcfile];
|
74 |
|
|
if { $gdb_recursion_test_baseline == -1 } {
|
75 |
|
|
fail "Could not find gdb_recursion_test function"
|
76 |
|
|
return;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
set return_me 0
|
80 |
|
|
|
81 |
|
|
gdb_test_multiple "list $gdb_recursion_test_baseline, +12" "" {
|
82 |
|
|
-re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 1 " {
|
83 |
|
|
set testline1 $expect_out(1,string)
|
84 |
|
|
exp_continue
|
85 |
|
|
}
|
86 |
|
|
-re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 2 " {
|
87 |
|
|
set testline2 $expect_out(1,string)
|
88 |
|
|
exp_continue
|
89 |
|
|
}
|
90 |
|
|
-re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 3 " {
|
91 |
|
|
set testline3 $expect_out(1,string)
|
92 |
|
|
exp_continue
|
93 |
|
|
}
|
94 |
|
|
-re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 4 " {
|
95 |
|
|
set testline4 $expect_out(1,string)
|
96 |
|
|
exp_continue
|
97 |
|
|
}
|
98 |
|
|
-re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 5 " {
|
99 |
|
|
set testline5 $expect_out(1,string)
|
100 |
|
|
exp_continue
|
101 |
|
|
}
|
102 |
|
|
-re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 6 " {
|
103 |
|
|
set testline6 $expect_out(1,string)
|
104 |
|
|
exp_continue
|
105 |
|
|
}
|
106 |
|
|
-re ".*$gdb_prompt $" {
|
107 |
|
|
if { ($testline1 == 0) || ($testline2 == 0) || ($testline3 == 0) || ($testline4 == 0) || ($testline5 == 0) || ($testline6 == 0) } {
|
108 |
|
|
untested report.exp
|
109 |
|
|
set return_me 1
|
110 |
|
|
all tests in this module will fail."
|
111 |
|
|
}
|
112 |
|
|
}
|
113 |
|
|
default {
|
114 |
|
|
untested report.exp
|
115 |
|
|
set return_me 1
|
116 |
|
|
all tests in this module will fail."
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
if { $return_me == 1 } then {
|
121 |
|
|
return -1;
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
#
|
125 |
|
|
# Setup trace experiment. This will involve:
|
126 |
|
|
# 1) a tracepoint where nothing is collected
|
127 |
|
|
# 2) a tracepoint where only regs are collected
|
128 |
|
|
# 3) a tracepoint where only args are collected
|
129 |
|
|
# 4) a tracepoint where only locals are collected
|
130 |
|
|
# 5) a tracepoint where some amount of stack memory is collected.
|
131 |
|
|
# 6) a tracepoint where some expressions are collected.
|
132 |
|
|
#
|
133 |
|
|
|
134 |
|
|
gdb_delete_tracepoints
|
135 |
|
|
set tdp1 [gdb_gettpnum $testline1]
|
136 |
|
|
set tdp2 [gdb_gettpnum $testline2]
|
137 |
|
|
set tdp3 [gdb_gettpnum $testline3]
|
138 |
|
|
set tdp4 [gdb_gettpnum $testline4]
|
139 |
|
|
set tdp5 [gdb_gettpnum $testline5]
|
140 |
|
|
set tdp6 [gdb_gettpnum $testline6]
|
141 |
|
|
|
142 |
|
|
if { $tdp1 <= 0 || $tdp2 <= 0 || $tdp3 <= 0 || \
|
143 |
|
|
$tdp4 <= 0 || $tdp5 <= 0 || $tdp6 <= 0 } then {
|
144 |
|
|
fail "setting tracepoints failed"
|
145 |
|
|
return;
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
gdb_trace_setactions "9.x: setup TP to collect regs" \
|
149 |
|
|
"$tdp2" \
|
150 |
|
|
"collect \$regs" "^$"
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
gdb_trace_setactions "9.x: setup TP to collect args" \
|
154 |
|
|
"$tdp3" \
|
155 |
|
|
"collect \$args" "^$"
|
156 |
|
|
|
157 |
|
|
gdb_trace_setactions "9.x: setup TP to collect locals" \
|
158 |
|
|
"$tdp4" \
|
159 |
|
|
"collect \$locs" "^$"
|
160 |
|
|
|
161 |
|
|
if [istarget "x86_64-*"] then {
|
162 |
|
|
set fpreg "rbp"
|
163 |
|
|
set spreg "rsp"
|
164 |
|
|
set pcreg "rip"
|
165 |
|
|
} elseif [istarget "i?86-*"] then {
|
166 |
|
|
set fpreg "ebp"
|
167 |
|
|
set spreg "esp"
|
168 |
|
|
set pcreg "eip"
|
169 |
|
|
} else {
|
170 |
|
|
set fpreg "fp"
|
171 |
|
|
set spreg "sp"
|
172 |
|
|
set pcreg "pc"
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
gdb_trace_setactions "9.x: setup TP to collect stack memory" \
|
176 |
|
|
"$tdp5" \
|
177 |
|
|
"collect \$$fpreg, \*\(void \*\*\) \$$spreg @ 64" "^$"
|
178 |
|
|
|
179 |
|
|
gdb_trace_setactions "9.x: setup TP to collect expressions" \
|
180 |
|
|
"$tdp6" \
|
181 |
|
|
"collect gdb_char_test, gdb_short_test, gdb_long_test" "^$"
|
182 |
|
|
|
183 |
|
|
gdb_test "tstart" ".*" ""
|
184 |
|
|
|
185 |
|
|
gdb_test "break end" ".*" ""
|
186 |
|
|
gdb_test "continue" \
|
187 |
|
|
"Continuing.*Breakpoint $decimal, end.*" \
|
188 |
|
|
"run trace experiment"
|
189 |
|
|
|
190 |
|
|
gdb_test "tstop" ".*" ""
|
191 |
|
|
|
192 |
|
|
#
|
193 |
|
|
# 9.1 test the tdump command
|
194 |
|
|
#
|
195 |
|
|
|
196 |
|
|
set timeout 60
|
197 |
|
|
|
198 |
|
|
gdb_tfind_test "9.1: init: make sure not debugging any trace frame" "none" "-1"
|
199 |
|
|
|
200 |
|
|
gdb_tfind_test "9.1: find frame for TP $tdp1" "tracepoint $tdp1" \
|
201 |
|
|
"\$tracepoint" "$tdp1"
|
202 |
|
|
|
203 |
|
|
# Nothing was collected at tdp1, so this tdump should be empty.
|
204 |
|
|
gdb_test "tdump" \
|
205 |
|
|
"Data collected at tracepoint $tdp1, trace frame $decimal:" \
|
206 |
|
|
"9.1: tdump, nothing collected"
|
207 |
|
|
|
208 |
|
|
gdb_tfind_test "9.1: find frame for TP $tdp2" "tracepoint $tdp2" \
|
209 |
|
|
"\$tracepoint" "$tdp2"
|
210 |
|
|
|
211 |
|
|
# regs were collected at tdp2.
|
212 |
|
|
# How to match for the output of "info registers" on an unknown architecture?
|
213 |
|
|
# For now, assume that most architectures have a register called "pc".
|
214 |
|
|
|
215 |
|
|
gdb_test "tdump" \
|
216 |
|
|
"\[\r\n\]$pcreg .*" \
|
217 |
|
|
"9.1: tdump, regs collected"
|
218 |
|
|
|
219 |
|
|
gdb_tfind_test "9.1: find frame for TP $tdp3" "tracepoint $tdp3" \
|
220 |
|
|
"\$tracepoint" "$tdp3"
|
221 |
|
|
|
222 |
|
|
# args were collected at tdp3
|
223 |
|
|
gdb_test "tdump" \
|
224 |
|
|
"depth = 3.*q1 = 2.*q2 = 2.*q3 = 3.*q4 = 4.*q5 = 5.*q6 = 6" \
|
225 |
|
|
"9.1: tdump, args collected"
|
226 |
|
|
|
227 |
|
|
gdb_tfind_test "9.1: find frame for TP $tdp4" "tracepoint $tdp4" \
|
228 |
|
|
"\$tracepoint" "$tdp4"
|
229 |
|
|
|
230 |
|
|
# locals were collected at tdp4
|
231 |
|
|
gdb_test "tdump" \
|
232 |
|
|
"q = 1" \
|
233 |
|
|
"9.1: tdump, locals collected"
|
234 |
|
|
|
235 |
|
|
gdb_tfind_test "9.1: find frame for TP $tdp5" "tracepoint $tdp5" \
|
236 |
|
|
"\$tracepoint" "$tdp5"
|
237 |
|
|
|
238 |
|
|
# stack was collected at tdp5, plus the frame pointer
|
239 |
|
|
gdb_test "tdump" \
|
240 |
|
|
".$fpreg = .*$spreg @ 64 = .*" \
|
241 |
|
|
"9.1: tdump, memrange collected"
|
242 |
|
|
|
243 |
|
|
gdb_tfind_test "9.1: find frame for TP $tdp6" "tracepoint $tdp6" \
|
244 |
|
|
"\$tracepoint" "$tdp6"
|
245 |
|
|
|
246 |
|
|
# globals were collected at tdp6
|
247 |
|
|
gdb_test "tdump" \
|
248 |
|
|
"gdb_char_test = 1.*gdb_short_test = 2.*gdb_long_test = 3" \
|
249 |
|
|
"9.1: tdump, global variables collected"
|
250 |
|
|
|
251 |
|
|
# 9.2 test tdump with arguments
|
252 |
|
|
# [no go, tdump doesn't have any arguments]
|
253 |
|
|
|
254 |
|
|
# 9.3 help tdump
|
255 |
|
|
|
256 |
|
|
gdb_test "help tdump" "Print everything collected at the current.*" \
|
257 |
|
|
"9.3: help tdump"
|
258 |
|
|
|
259 |
|
|
set linecount1 0
|
260 |
|
|
set linecount2 0
|
261 |
|
|
set linecount3 0
|
262 |
|
|
set linecount4 0
|
263 |
|
|
set linecount5 0
|
264 |
|
|
set linecount6 0
|
265 |
|
|
|
266 |
|
|
gdb_tfind_test "11.x, 12.1: find start frame" "start" "0"
|
267 |
|
|
|
268 |
|
|
#
|
269 |
|
|
# 11.x test built-in trace variables $trace_frame, $trace_line etc.
|
270 |
|
|
#
|
271 |
|
|
|
272 |
|
|
gdb_test "printf \"x %d x\\n\", \$trace_frame" "x 0 x" \
|
273 |
|
|
"11.1: test \$trace_frame"
|
274 |
|
|
|
275 |
|
|
gdb_test "printf \"x %d x\\n\", \$tracepoint" "x $tdp1 x" \
|
276 |
|
|
"11.2: test \$tracepoint"
|
277 |
|
|
|
278 |
|
|
gdb_test "printf \"x %d x\\n\", \$trace_line" "x $testline1 x" \
|
279 |
|
|
"11.3: test \$trace_line"
|
280 |
|
|
|
281 |
|
|
gdb_test_multiple "print \$trace_file" "11.4: test \$trace_file" {
|
282 |
|
|
-re "\\$\[0-9\]+ = \"$srcfile\"\[\r\n\]+$gdb_prompt $" {
|
283 |
|
|
pass "11.4: test \$trace_file"
|
284 |
|
|
}
|
285 |
|
|
-re "\\$\[0-9\]+ = \"$srcdir/$subdir/$srcfile\"\[\r\n\]+$gdb_prompt $" {
|
286 |
|
|
pass "11.4: test \$trace_file"
|
287 |
|
|
}
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
#gdb_test "print \$trace_file" "\"$srcdir/$subdir/$srcfile\"" \
|
291 |
|
|
# "11.4: test \$trace_file"
|
292 |
|
|
|
293 |
|
|
#
|
294 |
|
|
# 12.x test report generation using arbitrary GDB commands, loops etc.
|
295 |
|
|
#
|
296 |
|
|
|
297 |
|
|
gdb_test_multiple "while \$trace_frame != -1\n output \$trace_file\n printf \", line \%d \(tracepoint #\%d\)\\n\", \$trace_line, \$tracepoint\n tfind\n end" "12.1: trace report #1" {
|
298 |
|
|
-re " line $testline1 .tracepoint .$tdp1" {
|
299 |
|
|
set linecount1 [expr $linecount1 + 1]
|
300 |
|
|
exp_continue
|
301 |
|
|
}
|
302 |
|
|
-re " line $testline2 .tracepoint .$tdp2" {
|
303 |
|
|
set linecount2 [expr $linecount2 + 1]
|
304 |
|
|
exp_continue
|
305 |
|
|
}
|
306 |
|
|
-re " line $testline3 .tracepoint .$tdp3" {
|
307 |
|
|
set linecount3 [expr $linecount3 + 1]
|
308 |
|
|
exp_continue
|
309 |
|
|
}
|
310 |
|
|
-re " line $testline4 .tracepoint .$tdp4" {
|
311 |
|
|
set linecount4 [expr $linecount4 + 1]
|
312 |
|
|
exp_continue
|
313 |
|
|
}
|
314 |
|
|
-re " line $testline5 .tracepoint .$tdp5" {
|
315 |
|
|
set linecount5 [expr $linecount5 + 1]
|
316 |
|
|
exp_continue
|
317 |
|
|
}
|
318 |
|
|
-re " line $testline6 .tracepoint .$tdp6" {
|
319 |
|
|
set linecount6 [expr $linecount6 + 1]
|
320 |
|
|
exp_continue
|
321 |
|
|
}
|
322 |
|
|
-re ".*$gdb_prompt $" {
|
323 |
|
|
if { ($linecount1 < 4) || ($linecount2 < 4) || ($linecount3 < 4) || ($linecount4 < 4) || ($linecount5 < 4) || ($linecount6 < 4) } {
|
324 |
|
|
fail "12.1: trace report #1"
|
325 |
|
|
} else {
|
326 |
|
|
pass "12.1: trace report #1"
|
327 |
|
|
}
|
328 |
|
|
}
|
329 |
|
|
}
|
330 |
|
|
|
331 |
|
|
gdb_tfind_test "12.2: tfind end, selects no frame" "end" "-1"
|
332 |
|
|
gdb_tfind_test "12.2: find first TDP #2 frame" "tracepoint $tdp2" \
|
333 |
|
|
"\$tracepoint" "$tdp2"
|
334 |
|
|
|
335 |
|
|
set linecount2 0
|
336 |
|
|
|
337 |
|
|
gdb_test_multiple "while \$trace_frame != -1\n printf \"tracepoint #\%d, FP 0x\%08x, SP 0x\%08x, PC 0x%08x\\n\", \$tracepoint, \$fp, \$sp, \$pc\n tfind tracepoint\n end" "12.2: trace report #2" {
|
338 |
|
|
-re "tracepoint #$tdp2, FP $hex, SP $hex, PC $hex" {
|
339 |
|
|
set linecount2 [expr $linecount2 + 1]
|
340 |
|
|
exp_continue
|
341 |
|
|
}
|
342 |
|
|
-re ".*$gdb_prompt $" {
|
343 |
|
|
if { ($linecount2 < 4) } {
|
344 |
|
|
fail "12.2: trace report #2"
|
345 |
|
|
} else {
|
346 |
|
|
pass "12.2: trace report #2"
|
347 |
|
|
}
|
348 |
|
|
}
|
349 |
|
|
}
|
350 |
|
|
|
351 |
|
|
gdb_tfind_test "12.3: tfind end, selects no frame" "end" "-1"
|
352 |
|
|
gdb_tfind_test "12.3: find first TDP #3 frame" "tracepoint $tdp3" \
|
353 |
|
|
"\$tracepoint" "$tdp3"
|
354 |
|
|
|
355 |
|
|
set linecount3 0
|
356 |
|
|
|
357 |
|
|
gdb_test_multiple "while \$trace_frame != -1\n printf \"TDP #\%d, frame \%d: depth = \%d, q1 = \%d\\n\", \$tracepoint, \$trace_frame, depth, q1\n tfind tracepoint\n end" "12.3: trace report #3" {
|
358 |
|
|
-re "TDP #$tdp3, frame $decimal: depth = $decimal, q1 = $decimal" {
|
359 |
|
|
set linecount3 [expr $linecount3 + 1]
|
360 |
|
|
exp_continue
|
361 |
|
|
}
|
362 |
|
|
-re ".*$gdb_prompt $" {
|
363 |
|
|
if { ($linecount3 < 4) } {
|
364 |
|
|
fail "12.3: trace report #3"
|
365 |
|
|
} else {
|
366 |
|
|
pass "12.3: trace report #3"
|
367 |
|
|
}
|
368 |
|
|
}
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
gdb_tfind_test "12.4: tfind end, selects no frame" "end" "-1"
|
372 |
|
|
gdb_tfind_test "12.4: find first TDP #6 frame" "tracepoint $tdp6" \
|
373 |
|
|
"\$tracepoint" "$tdp6"
|
374 |
|
|
|
375 |
|
|
set linecount6 0
|
376 |
|
|
|
377 |
|
|
gdb_test_multiple "while \$trace_frame != -1\n printf \"TDP #\%d, frame %d: char_test = \%d, long_test = \%d\\n\", \$tracepoint, \$trace_frame, gdb_char_test, gdb_long_test\n tfind tracepoint\n end" "12.4: trace report #4" {
|
378 |
|
|
-re "TDP #$tdp6, frame $decimal: char_test = $arg1, long_test = $arg3" {
|
379 |
|
|
set linecount6 [expr $linecount6 + 1]
|
380 |
|
|
exp_continue
|
381 |
|
|
}
|
382 |
|
|
-re ".*$gdb_prompt $" {
|
383 |
|
|
if { ($linecount6 < 4) } {
|
384 |
|
|
fail "12.4: trace report #4"
|
385 |
|
|
} else {
|
386 |
|
|
pass "12.4: trace report #4"
|
387 |
|
|
}
|
388 |
|
|
}
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
# Finished!
|
392 |
|
|
gdb_tfind_test "finished: make sure not debugging any trace frame" "none" "-1"
|