]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/trace-break.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / trace-break.exp
CommitLineData
e2882c85 1# Copyright 2011-2018 Free Software Foundation, Inc.
b9fd1791
PA
2# This program is free software; you can redistribute it and/or modify
3# it under the terms of the GNU General Public License as published by
4# the Free Software Foundation; either version 3 of the License, or
5# (at your option) any later version.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU General Public License for more details.
11#
12# You should have received a copy of the GNU General Public License
13# along with this program. If not, see <http://www.gnu.org/licenses/>.
14
4ec70201 15load_lib "trace-support.exp"
b9fd1791 16
497a5eb0 17standard_testfile
b9fd1791 18set executable $testfile
b9fd1791
PA
19set expfile $testfile.exp
20
21# Some targets have leading underscores on assembly symbols.
22set additional_flags [gdb_target_symbol_prefix_flags]
23
5b362f04 24if [prepare_for_testing "failed to prepare" $executable $srcfile \
b9fd1791 25 [list debug $additional_flags]] {
b9fd1791
PA
26 return -1
27}
28
29if ![runto_main] {
bc6c7af4 30 fail "can't run to main to check for trace support"
b9fd1791
PA
31 return -1
32}
33
34if ![gdb_target_supports_trace] {
35 unsupported "target does not support trace"
ae59b1da 36 return -1
b9fd1791
PA
37}
38
39# Set breakpoint and tracepoint at the same address.
40
6a5870ce 41proc break_trace_same_addr_1 { trace_type option } \
0f4d39d5 42{ with_test_prefix "1 $trace_type $option" \
6a5870ce 43{
b9fd1791 44 global executable
b9fd1791
PA
45 global hex
46
b9fd1791
PA
47 # Start with a fresh gdb.
48 clean_restart ${executable}
49 if ![runto_main] {
bc6c7af4 50 fail "can't run to main"
b9fd1791
PA
51 return -1
52 }
53
54 gdb_test_no_output "set breakpoint always-inserted ${option}"
55
56 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
57
58 gdb_test "break set_point" "Breakpoint \[0-9\] at $hex: file.*"
59 gdb_test "${trace_type} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
60
61 gdb_test_no_output "tstart"
62
bd0a71fa
MK
63 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
64 "continue to set_point"
b9fd1791 65
bd0a71fa
MK
66 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
67 "continue to end"
b9fd1791
PA
68 gdb_test_no_output "tstop"
69
70 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
71 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
6a5870ce 72}}
b9fd1791
PA
73
74# Set multiple tracepoints at the same address.
75
6a5870ce 76proc break_trace_same_addr_2 { trace_type1 trace_type2 option } \
0f4d39d5 77{ with_test_prefix "2 $trace_type1 $trace_type2 $option" \
6a5870ce 78{
b9fd1791 79 global executable
b9fd1791
PA
80 global hex
81
b9fd1791
PA
82 # Start with a fresh gdb.
83 clean_restart ${executable}
84 if ![runto_main] {
bc6c7af4 85 fail "can't run to main"
b9fd1791
PA
86 return -1
87 }
88
89 gdb_test_no_output "set breakpoint always-inserted ${option}"
90
91 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
92
93 gdb_test "${trace_type1} set_point" \
94 "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
95 "${trace_type1} set_point (1)"
96
97 gdb_test "${trace_type2} set_point" \
98 "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
99 "${trace_type2} set_point (2)"
100
101 gdb_test_no_output "tstart"
bd0a71fa
MK
102 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
103 "continue to end"
b9fd1791
PA
104
105 gdb_test_no_output "tstop"
106
107 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
108 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
109 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
6a5870ce 110}}
b9fd1791
PA
111
112# Set breakpoint and tracepoint at the same address. Delete breakpoint, and verify
113# that tracepoint still works.
114
6a5870ce 115proc break_trace_same_addr_3 { trace_type option } \
0f4d39d5 116{ with_test_prefix "3 $trace_type $option" \
6a5870ce 117{
b9fd1791 118 global executable
b9fd1791
PA
119 global hex
120
b9fd1791
PA
121 # Start with a fresh gdb.
122 clean_restart ${executable}
123 if ![runto_main] {
bc6c7af4 124 fail "can't run to main"
b9fd1791
PA
125 return -1
126 }
127
128 gdb_test_no_output "set breakpoint always-inserted ${option}"
129 gdb_test "break marker" "Breakpoint \[0-9\] at $hex: file.*"
130 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
131
132 gdb_test "break set_point" "Breakpoint \[0-9\] at $hex: file.*"
133 gdb_test "${trace_type} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
134
135 gdb_test_no_output "tstart"
136
bd0a71fa
MK
137 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
138 "continue to marker"
b9fd1791
PA
139 gdb_test "delete break 4"
140
bd0a71fa
MK
141 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
142 "continue to end"
b9fd1791
PA
143 gdb_test_no_output "tstop"
144
145 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
146 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
6a5870ce 147}}
b9fd1791
PA
148
149# Set breakpoint and tracepoint at the same address. Delete tracepoint, and verify
150# that breakpoint still works.
151
6a5870ce 152proc break_trace_same_addr_4 { trace_type option } \
0f4d39d5 153{ with_test_prefix "4 $trace_type $option" \
6a5870ce 154{
b9fd1791 155 global executable
b9fd1791
PA
156 global hex
157
b9fd1791
PA
158
159 # Start with a fresh gdb.
160 clean_restart ${executable}
161 if ![runto_main] {
bc6c7af4 162 fail "can't run to main"
b9fd1791
PA
163 return -1
164 }
165
166 gdb_test_no_output "set breakpoint always-inserted ${option}"
167 gdb_test "break marker" "Breakpoint \[0-9\] at $hex: file.*"
168 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
169
170 gdb_test "break set_point" "Breakpoint \[0-9\] at $hex: file.*"
171 gdb_test "${trace_type} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
172
bd0a71fa
MK
173 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
174 "continue to marker"
b9fd1791
PA
175 # Delete tracepoint set on set_point.
176 gdb_test "delete trace 5"
177
178 gdb_test "tstart" "No tracepoints defined, not starting trace.*"
179
bd0a71fa
MK
180 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
181 "continue to set_point"
182 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
183 "continue to end"
b9fd1791
PA
184 gdb_test "tstop" "Trace is not running.*"
185
186 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
6a5870ce 187}}
b9fd1791 188
1e4d1764
YQ
189# Set two tracepoints TRACE1 and TRACE2 at two locations, and start tracing.
190# Then, set tracepoint TRACE3 at either of these two locations.
191# TRACE3_AT_FIRST_LOC is a boolean variable to decide insert TRACE3 at which
192# of two locations. Verify these tracepoints work as expected.
193
6a5870ce 194proc break_trace_same_addr_5 { trace1 trace2 trace3 trace3_at_first_loc } \
0f4d39d5 195{ with_test_prefix "5 $trace1 $trace2 ${trace3}@${trace3_at_first_loc}" \
6a5870ce 196{
1e4d1764 197 global executable
1e4d1764
YQ
198 global hex
199 global fpreg
200 global spreg
201 global pcreg
202
1e4d1764
YQ
203 # Start with a fresh gdb.
204 clean_restart ${executable}
205 if ![runto_main] {
bc6c7af4 206 fail "can't run to main"
1e4d1764
YQ
207 return -1
208 }
209
210 gdb_test "break marker" "Breakpoint \[0-9\] at $hex: file.*"
211 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
212
213 gdb_test "${trace1} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
214 "${trace1} set_point 1"
215 gdb_trace_setactions "set action for tracepoint 1" "" \
216 "collect \$$pcreg" "^$"
217 gdb_test "${trace2} after_set_point" \
218 "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
219 "${trace2} after_set_point 1"
220
221 gdb_trace_setactions "set action for tracepoint 2" "" \
222 "collect \$$spreg" "^$"
223
224 gdb_test_no_output "tstart"
225
bd0a71fa
MK
226 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
227 "continue to marker"
1e4d1764
YQ
228
229 if [string equal $trace3_at_first_loc "1"] {
230 gdb_test "${trace3} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
231 "${trace3} set_point 2"
232 } else {
233 gdb_test "${trace3} after_set_point" \
234 "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
235 "${trace2} after_set_point 2"
236 }
237 gdb_trace_setactions "set action for tracepoint 3" "" \
238 "collect \$$fpreg" "^$"
239
bd0a71fa
MK
240 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
241 "continue to end"
1e4d1764
YQ
242 gdb_test_no_output "tstop"
243
244 gdb_test "tfind tracepoint 4" "Found trace frame \[0-9\], tracepoint .*" \
245 "tfind test frame of tracepoint 4"
246 gdb_test "tdump" \
247 "Data collected at tracepoint .*, trace frame \[0-9\]:.*\\$${pcreg} = .*" \
248 "tdump 1"
249 gdb_test "tfind 0" "Found trace frame 0, tracepoint .*" \
250 "reset to frame 0 (1)"
251 gdb_test "tfind tracepoint 5" "Found trace frame \[0-9\], tracepoint .*" \
252 "tfind test frame of tracepoint 5"
253 gdb_test "tdump" \
254 "Data collected at tracepoint .*, trace frame \[0-9\]:.*\\$${spreg} = .*" \
255 "tdump 2"
256 gdb_test "tfind 0" "Found trace frame 0, tracepoint .*" \
257 "reset to frame 0 (2)"
258 gdb_test "tfind tracepoint 6" "Found trace frame \[0-9\], tracepoint .*" \
259 "tfind test frame of tracepoint 6"
260 gdb_test "tdump" \
261 "Data collected at tracepoint .*, trace frame \[0-9\]:.*\\$${fpreg} = .*" \
262 "tdump 3"
6a5870ce 263}}
1e4d1764
YQ
264
265# Set two tracepoints at the same address, and enable/disable them. Verify
266# tracepoints work as expect.
267
6a5870ce 268proc break_trace_same_addr_6 { trace1 enable1 trace2 enable2 } \
0f4d39d5 269{ with_test_prefix "6 $trace1 $enable1 $trace2 $enable2" \
6a5870ce 270{
1e4d1764 271 global executable
1e4d1764
YQ
272 global hex
273 global gdb_prompt
274 global spreg
275 global pcreg
276
1e4d1764
YQ
277 # Start with a fresh gdb.
278 clean_restart ${executable}
279 if ![runto_main] {
bc6c7af4 280 fail "can't run to main"
1e4d1764
YQ
281 return -1
282 }
283
284 gdb_test "break marker" "Breakpoint \[0-9\] at $hex: file.*"
285 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
286
bd0a71fa
MK
287 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
288 "continue to marker"
1e4d1764
YQ
289
290 gdb_test "${trace1} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
291 "${trace1} set_point 1"
292 gdb_trace_setactions "set action for tracepoint 1" "" \
293 "collect \$$pcreg" "^$"
294 gdb_test "${trace2} set_point" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*" \
295 "${trace2} set_point 2"
296 gdb_trace_setactions "set action for tracepoint 2" "" \
297 "collect \$$spreg" "^$"
298
299 gdb_test_no_output "$enable1 4"
300 gdb_test_no_output "$enable2 5"
301
302 gdb_test_no_output "tstart"
bd0a71fa
MK
303 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
304 "continue to end"
1e4d1764
YQ
305 gdb_test_no_output "tstop"
306
307
308 if [string equal $enable1 "enable"] {
309 gdb_test "tfind tracepoint 4" "Found trace frame \[0-9\], tracepoint .*" \
310 "tfind test frame of tracepoint 4"
311 gdb_test "tdump" \
312 "Data collected at tracepoint .*, trace frame \[0-9\]:.*\\$${pcreg} = .*" \
313 "tdump 1"
314 gdb_test "tfind 0" "Found trace frame 0, tracepoint .*" \
315 "reset to frame 0 (1)"
316 } else {
317 gdb_test "tfind tracepoint 4" "Target failed to find requested trace frame.*" \
318 "tfind test frame of tracepoint 4"
319 }
320
321 if [string equal $enable2 "enable"] {
322 gdb_test "tfind tracepoint 5" "Found trace frame \[0-9\], tracepoint .*" \
323 "tfind test frame of tracepoint 5"
324 gdb_test "tdump" \
325 "Data collected at tracepoint .*, trace frame \[0-9\]:.*\\$${spreg} = .*" \
326 "tdump 2"
327 gdb_test "tfind 0" "Found trace frame 0, tracepoint .*" \
328 "reset to frame 0 (2)"
329 } else {
330 gdb_test "tfind tracepoint 5" "Target failed to find requested trace frame.*" \
331 "tfind test frame of tracepoint 5"
332 }
6a5870ce 333}}
1e4d1764
YQ
334
335
b9fd1791
PA
336foreach break_always_inserted { "on" "off" } {
337 break_trace_same_addr_1 "trace" ${break_always_inserted}
338 break_trace_same_addr_2 "trace" "trace" ${break_always_inserted}
339 break_trace_same_addr_3 "trace" ${break_always_inserted}
340 break_trace_same_addr_4 "trace" ${break_always_inserted}
341}
342
1e4d1764
YQ
343foreach at_first_loc { "1" "0" } {
344 break_trace_same_addr_5 "trace" "trace" "trace" ${at_first_loc}
345}
346
347break_trace_same_addr_6 "trace" "enable" "trace" "disable"
348break_trace_same_addr_6 "trace" "disable" "trace" "enable"
349
c0d4d1c0 350set libipa [get_in_proc_agent]
952ebca5 351set remote_libipa [gdb_load_shlib $libipa]
b9fd1791
PA
352
353# Can't use prepare_for_testing, because that splits compiling into
354# building objects and then linking, and we'd fail with "linker input
355# file unused because linking not done" when building the object.
356
357if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
358 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
84c93cd5 359 untested "failed to compile"
b9fd1791
PA
360 return -1
361}
362clean_restart ${executable}
363
364if ![runto_main] {
bc6c7af4 365 fail "can't run to main for ftrace tests"
b9fd1791
PA
366 return 0
367}
368
369gdb_reinitialize_dir $srcdir/$subdir
952ebca5 370if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
bc6c7af4 371 untested "could not find IPA lib loaded"
b9fd1791
PA
372} else {
373 foreach break_always_inserted { "on" "off" } {
374 break_trace_same_addr_1 "ftrace" ${break_always_inserted}
375 break_trace_same_addr_2 "trace" "ftrace" ${break_always_inserted}
376 break_trace_same_addr_2 "ftrace" "trace" ${break_always_inserted}
a59306a3 377 break_trace_same_addr_2 "ftrace" "ftrace" ${break_always_inserted}
b9fd1791
PA
378 break_trace_same_addr_3 "ftrace" ${break_always_inserted}
379 break_trace_same_addr_4 "ftrace" ${break_always_inserted}
380 }
1e4d1764
YQ
381
382 foreach trace1 { "trace" "ftrace" } {
383 foreach trace2 { "trace" "ftrace" } {
384 foreach trace3 { "trace" "ftrace" } {
385
386 if { [string equal $trace1 "trace"]
387 && [string equal $trace2 "trace"]
388 && [string equal $trace3 "trace"] } {
389 continue
390 }
391
392 foreach at_first_loc { "1" "0" } {
393 break_trace_same_addr_5 $trace1 $trace2 $trace3 $at_first_loc
394 }
395 }
396 }
397 }
398
399 foreach trace1 { "trace" "ftrace" } {
400 foreach trace2 { "trace" "ftrace" } {
401 if { [string equal $trace1 "trace"]
402 && [string equal $trace2 "trace"] } {
403 continue
404 }
405 break_trace_same_addr_6 $trace1 "enable" $trace2 "disable"
406 break_trace_same_addr_6 $trace1 "disable" $trace2 "enable"
407 }
408 }
b9fd1791 409}