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