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