Fix more cases of improper test names
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / trace-break.exp
1 # Copyright 2011-2016 Free Software Foundation, Inc.
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
15 load_lib "trace-support.exp"
16
17 standard_testfile
18 set executable $testfile
19 set expfile $testfile.exp
20
21 # Some targets have leading underscores on assembly symbols.
22 set additional_flags [gdb_target_symbol_prefix_flags]
23
24 if [prepare_for_testing "failed to prepare" $executable $srcfile \
25 [list debug $additional_flags]] {
26 return -1
27 }
28
29 if ![runto_main] {
30 fail "can't run to main to check for trace support"
31 return -1
32 }
33
34 if ![gdb_target_supports_trace] {
35 unsupported "target does not support trace"
36 return -1
37 }
38
39 # Set breakpoint and tracepoint at the same address.
40
41 proc break_trace_same_addr_1 { trace_type option } \
42 { with_test_prefix "1 $trace_type $option" \
43 {
44 global executable
45 global hex
46
47 # Start with a fresh gdb.
48 clean_restart ${executable}
49 if ![runto_main] {
50 fail "can't run to main"
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
63 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
64 "continue to set_point"
65
66 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
67 "continue to end"
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\\..*"
72 }}
73
74 # Set multiple tracepoints at the same address.
75
76 proc break_trace_same_addr_2 { trace_type1 trace_type2 option } \
77 { with_test_prefix "2 $trace_type1 $trace_type2 $option" \
78 {
79 global executable
80 global hex
81
82 # Start with a fresh gdb.
83 clean_restart ${executable}
84 if ![runto_main] {
85 fail "can't run to main"
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"
102 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
103 "continue to end"
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\\..*"
110 }}
111
112 # Set breakpoint and tracepoint at the same address. Delete breakpoint, and verify
113 # that tracepoint still works.
114
115 proc break_trace_same_addr_3 { trace_type option } \
116 { with_test_prefix "3 $trace_type $option" \
117 {
118 global executable
119 global hex
120
121 # Start with a fresh gdb.
122 clean_restart ${executable}
123 if ![runto_main] {
124 fail "can't run to main"
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
137 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
138 "continue to marker"
139 gdb_test "delete break 4"
140
141 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
142 "continue to end"
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\\..*"
147 }}
148
149 # Set breakpoint and tracepoint at the same address. Delete tracepoint, and verify
150 # that breakpoint still works.
151
152 proc break_trace_same_addr_4 { trace_type option } \
153 { with_test_prefix "4 $trace_type $option" \
154 {
155 global executable
156 global hex
157
158
159 # Start with a fresh gdb.
160 clean_restart ${executable}
161 if ![runto_main] {
162 fail "can't run to main"
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
173 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
174 "continue to marker"
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
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"
184 gdb_test "tstop" "Trace is not running.*"
185
186 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
187 }}
188
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
194 proc break_trace_same_addr_5 { trace1 trace2 trace3 trace3_at_first_loc } \
195 { with_test_prefix "5 $trace1 $trace2 ${trace3}@${trace3_at_first_loc}" \
196 {
197 global executable
198 global hex
199 global fpreg
200 global spreg
201 global pcreg
202
203 # Start with a fresh gdb.
204 clean_restart ${executable}
205 if ![runto_main] {
206 fail "can't run to main"
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
226 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
227 "continue to marker"
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
240 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
241 "continue to end"
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"
263 }}
264
265 # Set two tracepoints at the same address, and enable/disable them. Verify
266 # tracepoints work as expect.
267
268 proc break_trace_same_addr_6 { trace1 enable1 trace2 enable2 } \
269 { with_test_prefix "6 $trace1 $enable1 $trace2 $enable2" \
270 {
271 global executable
272 global hex
273 global gdb_prompt
274 global spreg
275 global pcreg
276
277 # Start with a fresh gdb.
278 clean_restart ${executable}
279 if ![runto_main] {
280 fail "can't run to main"
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
287 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
288 "continue to marker"
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"
303 gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \
304 "continue to end"
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 }
333 }}
334
335
336 foreach 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
343 foreach at_first_loc { "1" "0" } {
344 break_trace_same_addr_5 "trace" "trace" "trace" ${at_first_loc}
345 }
346
347 break_trace_same_addr_6 "trace" "enable" "trace" "disable"
348 break_trace_same_addr_6 "trace" "disable" "trace" "enable"
349
350 set libipa [get_in_proc_agent]
351 set remote_libipa [gdb_load_shlib $libipa]
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
357 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
358 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
359 untested "failed to compile"
360 return -1
361 }
362 clean_restart ${executable}
363
364 if ![runto_main] {
365 fail "can't run to main for ftrace tests"
366 return 0
367 }
368
369 gdb_reinitialize_dir $srcdir/$subdir
370 if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
371 untested "could not find IPA lib loaded"
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}
377 break_trace_same_addr_2 "ftrace" "ftrace" ${break_always_inserted}
378 break_trace_same_addr_3 "ftrace" ${break_always_inserted}
379 break_trace_same_addr_4 "ftrace" ${break_always_inserted}
380 }
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 }
409 }
This page took 0.039365 seconds and 4 git commands to generate.