]>
Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 1998-2019 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 | # This file was written by Michael Snyder (msnyder@cygnus.com) |
17 | ||
4ec70201 | 18 | load_lib "trace-support.exp" |
c906108c | 19 | |
c906108c SS |
20 | |
21 | gdb_exit | |
22 | gdb_start | |
23 | ||
497a5eb0 | 24 | standard_testfile |
8bca2978 SL |
25 | if ![gdb_trace_common_supports_arch] { |
26 | unsupported "no trace-common.h support for arch" | |
27 | return -1 | |
28 | } | |
f8b7eaf3 DJ |
29 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ |
30 | executable {debug nowarnings}] != "" } { | |
84c93cd5 | 31 | untested "failed to compile" |
f8b7eaf3 | 32 | return -1 |
c906108c SS |
33 | } |
34 | gdb_reinitialize_dir $srcdir/$subdir | |
35 | ||
36 | # If testing on a remote host, download the source file. | |
37 | # remote_download host $srcdir/$subdir/$srcfile | |
38 | ||
39 | gdb_file_cmd $binfile | |
40 | ||
41 | # define relative source line numbers: | |
42 | # all subsequent line numbers are relative to this first one (baseline) | |
43 | ||
4ec70201 | 44 | set baseline [gdb_find_recursion_test_baseline $srcfile] |
c906108c | 45 | if { $baseline == -1 } then { |
bc6c7af4 | 46 | fail "could not find gdb_recursion_test function" |
4ec70201 | 47 | return |
c906108c SS |
48 | } |
49 | ||
50 | set testline1 [expr $baseline + 7] | |
51 | ||
52 | # | |
53 | # test actions command | |
54 | # | |
55 | ||
56 | gdb_delete_tracepoints | |
4ec70201 PA |
57 | set trcpt1 [gdb_gettpnum gdb_c_test] |
58 | set trcpt2 [gdb_gettpnum gdb_asm_test] | |
59 | set trcpt3 [gdb_gettpnum $testline1] | |
c906108c SS |
60 | if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then { |
61 | fail "setting tracepoints" | |
4ec70201 | 62 | return |
c906108c SS |
63 | } |
64 | ||
65 | # 5.1 actions of specified tracepoint | |
66 | ||
0ab48859 | 67 | gdb_test_multiple "info tracepoints" "5.1a: set three tracepoints, no actions" { |
c906108c SS |
68 | -re "Actions for tracepoint \[0-9\]+:.*$gdb_prompt $" { |
69 | fail "5.1a: testsuite failure (tracepoint already has action)!" | |
70 | } | |
71 | -re "No tracepoints.*$gdb_prompt $" { | |
72 | fail "5.1a: set three tracepoints, no actions (No tracepoints!)" | |
73 | } | |
74 | -re "$gdb_prompt $" { | |
75 | pass "5.1a: set three tracepoints, no actions" | |
76 | } | |
77 | } | |
78 | ||
79 | gdb_trace_setactions "5.1b: set actions for first tracepoint" \ | |
80 | "$trcpt1" \ | |
81 | "collect gdb_char_test" "^$" | |
82 | ||
1042e4c0 SS |
83 | gdb_test "info tracepoints" \ |
84 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
85 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+. | |
a7bdde9e | 86 | \[\t \]+collect gdb_char_test. |
f2a8bc8a | 87 | \[\t \]+not installed on target. |
1042e4c0 | 88 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+. |
f2a8bc8a YQ |
89 | \[\t \]+not installed on target. |
90 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+. | |
91 | \[\t \]+not installed on target." \ | |
1042e4c0 | 92 | "5.1c: verify actions set for first tracepoint" |
c906108c SS |
93 | |
94 | gdb_trace_setactions "5.1d: set actions for second tracepoint" \ | |
95 | "$trcpt2" \ | |
96 | "collect gdb_short_test" "^$" | |
97 | ||
1042e4c0 SS |
98 | gdb_test "info tracepoints" \ |
99 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
100 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+. | |
a7bdde9e | 101 | \[\t \]+collect gdb_char_test. |
f2a8bc8a | 102 | \[\t \]+not installed on target. |
1042e4c0 | 103 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+. |
a7bdde9e | 104 | \[\t \]+collect gdb_short_test. |
f2a8bc8a YQ |
105 | \[\t \]+not installed on target. |
106 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+. | |
107 | \[\t \]+not installed on target." \ | |
1042e4c0 | 108 | "5.1e: verify actions set for second tracepoint" |
c906108c SS |
109 | |
110 | gdb_trace_setactions "5.2a: set actions for last (default) tracepoint" \ | |
111 | "" \ | |
112 | "collect gdb_long_test" "^$" | |
113 | ||
1042e4c0 SS |
114 | gdb_test "info tracepoints" \ |
115 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
116 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+. | |
a7bdde9e | 117 | \[\t \]+collect gdb_char_test. |
f2a8bc8a | 118 | \[\t \]+not installed on target. |
1042e4c0 | 119 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+. |
a7bdde9e | 120 | \[\t \]+collect gdb_short_test. |
f2a8bc8a | 121 | \[\t \]+not installed on target. |
1042e4c0 | 122 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+. |
f2a8bc8a YQ |
123 | \[\t \]+collect gdb_long_test. |
124 | \[\t \]+not installed on target." \ | |
e9eb0d14 | 125 | "5.2b: verify actions set for second tracepoint" |
c906108c SS |
126 | |
127 | # 5.3 replace actions set earlier | |
128 | ||
129 | gdb_trace_setactions "5.3a: reset actions for first tracepoint" \ | |
130 | "$trcpt1" \ | |
131 | "collect gdb_struct1_test" "^$" | |
132 | ||
1042e4c0 SS |
133 | gdb_test "info tracepoints" \ |
134 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
135 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+. | |
a7bdde9e | 136 | \[\t \]+collect gdb_struct1_test. |
f2a8bc8a | 137 | \[\t \]+not installed on target. |
1042e4c0 | 138 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+. |
a7bdde9e | 139 | \[\t \]+collect gdb_short_test. |
f2a8bc8a | 140 | \[\t \]+not installed on target. |
1042e4c0 | 141 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+. |
f2a8bc8a YQ |
142 | \[\t \]+collect gdb_long_test. |
143 | \[\t \]+not installed on target." \ | |
1042e4c0 | 144 | "5.3b: verify actions set for first tracepoint" |
c906108c SS |
145 | |
146 | # | |
147 | # test end command (all by itself) | |
148 | # | |
149 | ||
150 | # 5.4 end outside of context | |
151 | ||
152 | gdb_test "end" "This command cannot be used at the top level." \ | |
153 | "5.4: 'end' command out of context" | |
154 | ||
155 | # 5.5 empty actions (just an end with no other actions) | |
156 | ||
157 | gdb_trace_setactions "5.5a: set empty actions for first tracepoint" \ | |
158 | "$trcpt1" | |
159 | ||
0ab48859 | 160 | gdb_test_multiple "info tracepoints" "5.5c: verify NO actions for first tracepoint" { |
c906108c SS |
161 | -re "No tracepoints.*$gdb_prompt $" { |
162 | fail "5.5c: verify NO actions for first tracepoint" | |
163 | } | |
164 | -re "Actions for.* $trcpt1:.*$gdb_prompt $" { | |
165 | fail "5.5c: verify NO actions for first tracepoint" | |
166 | } | |
167 | -re "$gdb_prompt $" { | |
168 | pass "5.5c: verify NO actions for first tracepoint" | |
169 | } | |
170 | } | |
171 | ||
172 | # 5.6 actions for invalid tracepoint number | |
173 | ||
174 | gdb_test "actions [expr $trcpt2 + $trcpt3]" \ | |
175 | "No tracepoint number [expr $trcpt2 + $trcpt3]." \ | |
176 | "5.6: actions for invalid tracepoint number" | |
177 | ||
178 | # 5.7 invalid action (other than 'collect', 'while-stepping' or 'end') | |
179 | # "warning: .print gdb_c_test. is not a supported trace.*> $" \ | |
180 | ||
181 | gdb_trace_setactions "5.7: invalid action" \ | |
182 | "$trcpt1" \ | |
183 | "print gdb_c_test" \ | |
fff87407 | 184 | "`print gdb_c_test' is not a supported tracepoint action" |
c906108c SS |
185 | |
186 | # 5.8 help actions (collect, while-stepping, end) | |
187 | ||
188 | gdb_test "help actions" \ | |
189 | "Specify the actions to be taken at a tracepoint.*" \ | |
190 | "5.8a: help actions" | |
191 | ||
192 | gdb_test "help collect" \ | |
193 | "Specify one or more data items to be collected at a tracepoint.*" \ | |
194 | "5.8b: help collect" | |
195 | ||
196 | gdb_test "help while-stepping" \ | |
197 | "Specify single-stepping behavior at a tracepoint.*" \ | |
198 | "5.8c: help while-stepping" | |
199 | ||
200 | gdb_test "help end" "Ends a list of commands or actions.*" \ | |
201 | "5.8d: help end" | |
202 | ||
236f1d4d SS |
203 | # 5.9 default-collect |
204 | ||
e68d8fd4 | 205 | gdb_test_no_output "set default-collect gdb_char_test, gdb_long_test - 100" \ |
236f1d4d SS |
206 | "5.9a: set default-collect" |
207 | ||
208 | gdb_test "show default-collect" \ | |
209 | "The list of expressions to collect by default is \"gdb_char_test, gdb_long_test - 100\"..*" \ | |
210 | "5.9b: show default-collect" | |
6da95a67 | 211 | |
e68d8fd4 | 212 | gdb_test_no_output "set default-collect" \ |
64e17368 SS |
213 | "5.9c: set default-collect" |
214 | ||
6da95a67 SS |
215 | # 5.10 teval |
216 | ||
217 | gdb_test "tvariable \$tsv" \ | |
218 | "Trace state variable \\\$tsv created, with initial value 0." \ | |
bb95117e | 219 | "create a trace state variable" |
6da95a67 SS |
220 | |
221 | gdb_trace_setactions "5.10a: set teval action for first tracepoint" \ | |
222 | "$trcpt1" \ | |
223 | "teval gdb_char_test" "^$" | |
224 | ||
225 | gdb_trace_setactions "5.10a: set teval action for second tracepoint" \ | |
226 | "$trcpt2" \ | |
227 | "teval \$tsv += 1" "^$" | |
228 | ||
229 | gdb_test "info tracepoints" \ | |
230 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
231 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+. | |
a7bdde9e | 232 | \[\t \]+teval gdb_char_test. |
f2a8bc8a | 233 | \[\t \]+not installed on target. |
6da95a67 | 234 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+. |
a7bdde9e | 235 | \[\t \]+teval \\\$tsv \\\+= 1. |
f2a8bc8a | 236 | \[\t \]+not installed on target. |
6da95a67 | 237 | \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+. |
f2a8bc8a YQ |
238 | \[\t \]+collect gdb_long_test. |
239 | \[\t \]+not installed on target." \ | |
6da95a67 SS |
240 | "5.10a: verify teval actions set for two tracepoints" |
241 | ||
4496bed7 PA |
242 | # Load the binary to the target too. |
243 | gdb_load $binfile | |
244 | ||
9f6dbe2b PA |
245 | # Can't use runto_main here, because that would delete the tracepoints |
246 | # created above. | |
247 | gdb_breakpoint "main" | |
b7a273f8 | 248 | gdb_run_cmd |
9f6dbe2b | 249 | if {[gdb_test "" "Breakpoint .*"] != 0} { |
bc6c7af4 | 250 | fail "can't run to main" |
9f6dbe2b PA |
251 | return -1 |
252 | } | |
253 | ||
b7a273f8 YQ |
254 | if ![gdb_target_supports_trace] { |
255 | unsupported "target does not support trace" | |
256 | return -1 | |
257 | } | |
258 | ||
259 | gdb_trace_setactions "set actions for first tracepoint" \ | |
260 | "$trcpt1" \ | |
261 | "collect \$regs" "^$" \ | |
262 | "end" "" | |
263 | ||
264 | # Check the definition of tracepoints. These tracepoints may have | |
265 | # different number in different runs. | |
266 | ||
267 | proc check_tracepoint { data_source } { | |
268 | with_test_prefix "$data_source" { | |
269 | global gdb_prompt | |
270 | global srcfile | |
271 | ||
272 | set tp_on_gdb_c_test 0 | |
273 | set tp_on_gdb_asm_test 0 | |
274 | set tp_on_gdb_recursion_test 0 | |
275 | ||
276 | # Since the three tracepoints may appear in different orders, so | |
277 | # we can't do 'info tracepoints' to match the output. Instead, we | |
278 | # show each tracepoint one by one and record the number of each | |
279 | # tracepoint shown up the output. Check the number finally. | |
280 | for {set i 1} {$i < 4} {incr i 1} { | |
281 | set test "info tracepoints $i" | |
282 | gdb_test_multiple "info tracepoints $i" $test { | |
283 | -re "\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+\\r\\n\[\t \]+collect \\\$regs\\r\\n\[\t \]+installed on target" { | |
284 | incr tp_on_gdb_c_test | |
285 | exp_continue | |
286 | } | |
287 | -re "\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_asm_test at .*$srcfile:\[0-9\]+\\r\\n\[\t \]+teval \\\$tsv \\+= 1\\r\\n\[\t \]+installed on target" { | |
288 | incr tp_on_gdb_asm_test | |
289 | exp_continue | |
290 | } | |
291 | -re "\[0-9\]+\[\t \]+tracepoint keep y.* in gdb_recursion_test at .*$srcfile:\[0-9\]+\\r\\n\[\t \]+collect gdb_long_test\\r\\n\[\t \]+installed on target" { | |
292 | incr tp_on_gdb_recursion_test | |
293 | exp_continue | |
294 | } | |
295 | -re "${gdb_prompt} $" { | |
296 | } | |
297 | } | |
298 | } | |
299 | ||
300 | if {$tp_on_gdb_c_test == 1} { | |
301 | pass "tracepoint on gdb_c_test" | |
302 | } else { | |
303 | fail "tracepoint on gdb_c_test" | |
304 | } | |
305 | if {$tp_on_gdb_asm_test == 1} { | |
306 | pass "tracepoint on gdb_asm_test" | |
307 | } else { | |
308 | fail "tracepoint on gdb_asm_test" | |
309 | } | |
310 | if {$tp_on_gdb_recursion_test == 1} { | |
311 | pass "tracepoint on gdb_recursion_test" | |
312 | } else { | |
313 | fail "tracepoint on gdb_recursion_test $tp_on_gdb_recursion_test" | |
314 | } | |
315 | } | |
316 | } | |
317 | ||
318 | # Start and stop the tracing, so that we can save tracepoints | |
319 | # definitions to trace file. | |
320 | gdb_test_no_output "tstart" "" | |
321 | check_tracepoint "live" | |
322 | gdb_test_no_output "tstop" "" | |
323 | set tracefile [standard_output_file ${testfile}] | |
324 | gdb_test "tsave ${tracefile}.tf" \ | |
e7ab3185 TT |
325 | "Trace data saved to file '${tracefile}.tf'\.\\r" \ |
326 | "tsave ${testfile}.tf" | |
393fd4c3 YQ |
327 | gdb_test "tsave -ctf ${tracefile}.ctf" \ |
328 | "Trace data saved to directory '${tracefile}.ctf'\.\\r" \ | |
329 | "save ctf trace file" | |
b7a273f8 YQ |
330 | |
331 | # Restart GDB and read the trace data in tfile target. | |
332 | gdb_exit | |
333 | gdb_start | |
334 | gdb_reinitialize_dir $srcdir/$subdir | |
335 | gdb_file_cmd $binfile | |
336 | gdb_test "target tfile ${tracefile}.tf" ".*" \ | |
337 | "change to tfile target" | |
338 | check_tracepoint "tfile" | |
393fd4c3 YQ |
339 | |
340 | # Try to read ctf data if GDB supports. | |
341 | set gdb_can_read_ctf_data 0 | |
342 | gdb_test_multiple "target ctf" "" { | |
343 | -re "Undefined target command: \"ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" { | |
344 | set gdb_can_read_ctf_data 0 | |
345 | } | |
346 | -re "No CTF directory specified.*\r\n$gdb_prompt $" { | |
347 | set gdb_can_read_ctf_data 1 | |
348 | } | |
349 | } | |
350 | ||
351 | if { $gdb_can_read_ctf_data } { | |
352 | gdb_exit | |
353 | gdb_start | |
354 | gdb_reinitialize_dir $srcdir/$subdir | |
355 | gdb_file_cmd $binfile | |
356 | gdb_test "target ctf ${tracefile}.ctf" ".*" \ | |
357 | "change to ctf target" | |
358 | check_tracepoint "ctf" | |
359 | } |