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