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