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 | ||
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\\..*" | |
6a5870ce | 71 | }} |
b9fd1791 PA |
72 | |
73 | # Set multiple tracepoints at the same address. | |
74 | ||
6a5870ce | 75 | proc break_trace_same_addr_2 { trace_type1 trace_type2 option } \ |
0f4d39d5 | 76 | { with_test_prefix "2 $trace_type1 $trace_type2 $option" \ |
6a5870ce | 77 | { |
b9fd1791 | 78 | global executable |
b9fd1791 PA |
79 | global hex |
80 | ||
b9fd1791 PA |
81 | # Start with a fresh gdb. |
82 | clean_restart ${executable} | |
83 | if ![runto_main] { | |
84 | fail "Can't run to main" | |
b9fd1791 PA |
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\\..*" | |
6a5870ce | 108 | }} |
b9fd1791 PA |
109 | |
110 | # Set breakpoint and tracepoint at the same address. Delete breakpoint, and verify | |
111 | # that tracepoint still works. | |
112 | ||
6a5870ce | 113 | proc break_trace_same_addr_3 { trace_type option } \ |
0f4d39d5 | 114 | { with_test_prefix "3 $trace_type $option" \ |
6a5870ce | 115 | { |
b9fd1791 | 116 | global executable |
b9fd1791 PA |
117 | global hex |
118 | ||
b9fd1791 PA |
119 | # Start with a fresh gdb. |
120 | clean_restart ${executable} | |
121 | if ![runto_main] { | |
122 | fail "Can't run to main" | |
b9fd1791 PA |
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\\..*" | |
6a5870ce | 143 | }} |
b9fd1791 PA |
144 | |
145 | # Set breakpoint and tracepoint at the same address. Delete tracepoint, and verify | |
146 | # that breakpoint still works. | |
147 | ||
6a5870ce | 148 | proc break_trace_same_addr_4 { trace_type option } \ |
0f4d39d5 | 149 | { with_test_prefix "4 $trace_type $option" \ |
6a5870ce | 150 | { |
b9fd1791 | 151 | global executable |
b9fd1791 PA |
152 | global hex |
153 | ||
b9fd1791 PA |
154 | |
155 | # Start with a fresh gdb. | |
156 | clean_restart ${executable} | |
157 | if ![runto_main] { | |
158 | fail "Can't run to main" | |
b9fd1791 PA |
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\\..*" | |
6a5870ce | 180 | }} |
b9fd1791 | 181 | |
1e4d1764 YQ |
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 | ||
6a5870ce | 187 | proc break_trace_same_addr_5 { trace1 trace2 trace3 trace3_at_first_loc } \ |
0f4d39d5 | 188 | { with_test_prefix "5 $trace1 $trace2 ${trace3}@${trace3_at_first_loc}" \ |
6a5870ce | 189 | { |
1e4d1764 | 190 | global executable |
1e4d1764 YQ |
191 | global hex |
192 | global fpreg | |
193 | global spreg | |
194 | global pcreg | |
195 | ||
1e4d1764 YQ |
196 | # Start with a fresh gdb. |
197 | clean_restart ${executable} | |
198 | if ![runto_main] { | |
199 | fail "Can't run to main" | |
1e4d1764 YQ |
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" | |
6a5870ce | 254 | }} |
1e4d1764 YQ |
255 | |
256 | # Set two tracepoints at the same address, and enable/disable them. Verify | |
257 | # tracepoints work as expect. | |
258 | ||
6a5870ce | 259 | proc break_trace_same_addr_6 { trace1 enable1 trace2 enable2 } \ |
0f4d39d5 | 260 | { with_test_prefix "6 $trace1 $enable1 $trace2 $enable2" \ |
6a5870ce | 261 | { |
1e4d1764 | 262 | global executable |
1e4d1764 YQ |
263 | global hex |
264 | global gdb_prompt | |
265 | global spreg | |
266 | global pcreg | |
267 | ||
1e4d1764 YQ |
268 | # Start with a fresh gdb. |
269 | clean_restart ${executable} | |
270 | if ![runto_main] { | |
271 | fail "Can't run to main" | |
1e4d1764 YQ |
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 | } | |
6a5870ce | 322 | }} |
1e4d1764 YQ |
323 | |
324 | ||
b9fd1791 PA |
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 | ||
1e4d1764 YQ |
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 | ||
c0d4d1c0 | 339 | set libipa [get_in_proc_agent] |
b9fd1791 PA |
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 | |
c0d4d1c0 | 359 | if { [gdb_test "info sharedlibrary" ".*${libipa}.*" "IPA loaded"] != 0 } { |
b9fd1791 PA |
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} | |
a59306a3 | 366 | break_trace_same_addr_2 "ftrace" "ftrace" ${break_always_inserted} |
b9fd1791 PA |
367 | break_trace_same_addr_3 "ftrace" ${break_always_inserted} |
368 | break_trace_same_addr_4 "ftrace" ${break_always_inserted} | |
369 | } | |
1e4d1764 YQ |
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 | } | |
b9fd1791 | 398 | } |