Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2011-2016 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 | ||
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" | |
ae59b1da | 37 | return -1 |
b9fd1791 PA |
38 | } |
39 | ||
40 | # Set breakpoint and tracepoint at the same address. | |
41 | ||
6a5870ce | 42 | proc break_trace_same_addr_1 { trace_type option } \ |
0f4d39d5 | 43 | { with_test_prefix "1 $trace_type $option" \ |
6a5870ce | 44 | { |
b9fd1791 | 45 | global executable |
b9fd1791 PA |
46 | global hex |
47 | ||
b9fd1791 PA |
48 | # Start with a fresh gdb. |
49 | clean_restart ${executable} | |
50 | if ![runto_main] { | |
51 | fail "Can't run to main" | |
b9fd1791 PA |
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 | ||
bd0a71fa MK |
64 | gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \ |
65 | "continue to set_point" | |
b9fd1791 | 66 | |
bd0a71fa MK |
67 | gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \ |
68 | "continue to end" | |
b9fd1791 PA |
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\\..*" | |
6a5870ce | 73 | }} |
b9fd1791 PA |
74 | |
75 | # Set multiple tracepoints at the same address. | |
76 | ||
6a5870ce | 77 | proc break_trace_same_addr_2 { trace_type1 trace_type2 option } \ |
0f4d39d5 | 78 | { with_test_prefix "2 $trace_type1 $trace_type2 $option" \ |
6a5870ce | 79 | { |
b9fd1791 | 80 | global executable |
b9fd1791 PA |
81 | global hex |
82 | ||
b9fd1791 PA |
83 | # Start with a fresh gdb. |
84 | clean_restart ${executable} | |
85 | if ![runto_main] { | |
86 | fail "Can't run to main" | |
b9fd1791 PA |
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" | |
bd0a71fa MK |
103 | gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \ |
104 | "continue to end" | |
b9fd1791 PA |
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\\..*" | |
6a5870ce | 111 | }} |
b9fd1791 PA |
112 | |
113 | # Set breakpoint and tracepoint at the same address. Delete breakpoint, and verify | |
114 | # that tracepoint still works. | |
115 | ||
6a5870ce | 116 | proc break_trace_same_addr_3 { trace_type option } \ |
0f4d39d5 | 117 | { with_test_prefix "3 $trace_type $option" \ |
6a5870ce | 118 | { |
b9fd1791 | 119 | global executable |
b9fd1791 PA |
120 | global hex |
121 | ||
b9fd1791 PA |
122 | # Start with a fresh gdb. |
123 | clean_restart ${executable} | |
124 | if ![runto_main] { | |
125 | fail "Can't run to main" | |
b9fd1791 PA |
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 | ||
bd0a71fa MK |
138 | gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \ |
139 | "continue to marker" | |
b9fd1791 PA |
140 | gdb_test "delete break 4" |
141 | ||
bd0a71fa MK |
142 | gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \ |
143 | "continue to end" | |
b9fd1791 PA |
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\\..*" | |
6a5870ce | 148 | }} |
b9fd1791 PA |
149 | |
150 | # Set breakpoint and tracepoint at the same address. Delete tracepoint, and verify | |
151 | # that breakpoint still works. | |
152 | ||
6a5870ce | 153 | proc break_trace_same_addr_4 { trace_type option } \ |
0f4d39d5 | 154 | { with_test_prefix "4 $trace_type $option" \ |
6a5870ce | 155 | { |
b9fd1791 | 156 | global executable |
b9fd1791 PA |
157 | global hex |
158 | ||
b9fd1791 PA |
159 | |
160 | # Start with a fresh gdb. | |
161 | clean_restart ${executable} | |
162 | if ![runto_main] { | |
163 | fail "Can't run to main" | |
b9fd1791 PA |
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 | ||
bd0a71fa MK |
174 | gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \ |
175 | "continue to marker" | |
b9fd1791 PA |
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 | ||
bd0a71fa MK |
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" | |
b9fd1791 PA |
185 | gdb_test "tstop" "Trace is not running.*" |
186 | ||
187 | gdb_test "tfind" "Target failed to find requested trace frame\\..*" | |
6a5870ce | 188 | }} |
b9fd1791 | 189 | |
1e4d1764 YQ |
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 | ||
6a5870ce | 195 | proc break_trace_same_addr_5 { trace1 trace2 trace3 trace3_at_first_loc } \ |
0f4d39d5 | 196 | { with_test_prefix "5 $trace1 $trace2 ${trace3}@${trace3_at_first_loc}" \ |
6a5870ce | 197 | { |
1e4d1764 | 198 | global executable |
1e4d1764 YQ |
199 | global hex |
200 | global fpreg | |
201 | global spreg | |
202 | global pcreg | |
203 | ||
1e4d1764 YQ |
204 | # Start with a fresh gdb. |
205 | clean_restart ${executable} | |
206 | if ![runto_main] { | |
207 | fail "Can't run to main" | |
1e4d1764 YQ |
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 | ||
bd0a71fa MK |
227 | gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \ |
228 | "continue to marker" | |
1e4d1764 YQ |
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 | ||
bd0a71fa MK |
241 | gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \ |
242 | "continue to end" | |
1e4d1764 YQ |
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" | |
6a5870ce | 264 | }} |
1e4d1764 YQ |
265 | |
266 | # Set two tracepoints at the same address, and enable/disable them. Verify | |
267 | # tracepoints work as expect. | |
268 | ||
6a5870ce | 269 | proc break_trace_same_addr_6 { trace1 enable1 trace2 enable2 } \ |
0f4d39d5 | 270 | { with_test_prefix "6 $trace1 $enable1 $trace2 $enable2" \ |
6a5870ce | 271 | { |
1e4d1764 | 272 | global executable |
1e4d1764 YQ |
273 | global hex |
274 | global gdb_prompt | |
275 | global spreg | |
276 | global pcreg | |
277 | ||
1e4d1764 YQ |
278 | # Start with a fresh gdb. |
279 | clean_restart ${executable} | |
280 | if ![runto_main] { | |
281 | fail "Can't run to main" | |
1e4d1764 YQ |
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 | ||
bd0a71fa MK |
288 | gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \ |
289 | "continue to marker" | |
1e4d1764 YQ |
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" | |
bd0a71fa MK |
304 | gdb_test "continue" "Continuing\\.\[ \r\n\]+(Thread .* hit )?Breakpoint.*" \ |
305 | "continue to end" | |
1e4d1764 YQ |
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 | } | |
6a5870ce | 334 | }} |
1e4d1764 YQ |
335 | |
336 | ||
b9fd1791 PA |
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 | ||
1e4d1764 YQ |
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 | ||
c0d4d1c0 | 351 | set libipa [get_in_proc_agent] |
d9019901 | 352 | gdb_load_shlib $libipa |
b9fd1791 PA |
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 ftrace tests" | |
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 | |
c0d4d1c0 | 371 | if { [gdb_test "info sharedlibrary" ".*${libipa}.*" "IPA loaded"] != 0 } { |
b9fd1791 PA |
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} | |
a59306a3 | 378 | break_trace_same_addr_2 "ftrace" "ftrace" ${break_always_inserted} |
b9fd1791 PA |
379 | break_trace_same_addr_3 "ftrace" ${break_always_inserted} |
380 | break_trace_same_addr_4 "ftrace" ${break_always_inserted} | |
381 | } | |
1e4d1764 YQ |
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 | } | |
b9fd1791 | 410 | } |