]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2011-2023 Free Software Foundation, Inc. |
1e4d1764 YQ |
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" |
1e4d1764 | 16 | |
d6195dc9 | 17 | require allow_shlib_tests |
1e4d1764 | 18 | |
fbee47e0 | 19 | require gdb_trace_common_supports_arch |
8bca2978 | 20 | |
497a5eb0 | 21 | standard_testfile |
1e4d1764 YQ |
22 | set libfile1 "change-loc-1" |
23 | set libfile2 "change-loc-2" | |
1e4d1764 YQ |
24 | set executable $testfile |
25 | set libsrc1 $srcdir/$subdir/$libfile1.c | |
26 | set libsrc2 $srcdir/$subdir/$libfile2.c | |
497a5eb0 TT |
27 | set lib_sl1 [standard_output_file $libfile1.sl] |
28 | set lib_sl2 [standard_output_file $libfile2.sl] | |
1e4d1764 YQ |
29 | |
30 | set lib_opts debug | |
31 | ||
1e4d1764 YQ |
32 | # Some targets have leading underscores on assembly symbols. |
33 | set additional_flags [list debug shlib=$lib_sl1 shlib_load [gdb_target_symbol_prefix_flags]] | |
34 | ||
35 | if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != "" | |
36 | || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != "" | |
37 | || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} { | |
84c93cd5 | 38 | untested "failed to compile" |
1e4d1764 YQ |
39 | return -1 |
40 | } | |
41 | ||
42 | clean_restart $executable | |
43 | ||
d9019901 SM |
44 | gdb_load_shlib $lib_sl1 |
45 | gdb_load_shlib $lib_sl2 | |
1e4d1764 YQ |
46 | |
47 | if ![runto_main] { | |
1e4d1764 YQ |
48 | return -1 |
49 | } | |
50 | ||
89c6d320 | 51 | if {![gdb_target_supports_trace]} { |
bc6c7af4 | 52 | unsupported "current target does not support trace" |
ae59b1da | 53 | return -1 |
1e4d1764 YQ |
54 | } |
55 | ||
1e4d1764 YQ |
56 | |
57 | # Set tracepoint during tracing experiment. | |
58 | ||
0a251e08 YQ |
59 | proc tracepoint_change_loc_1 { trace_type } { |
60 | with_test_prefix "1 $trace_type" { | |
61 | global testfile | |
62 | global srcfile | |
63 | global pcreg | |
64 | global gdb_prompt | |
65 | ||
66 | clean_restart ${testfile} | |
67 | if ![runto_main] { | |
0a251e08 | 68 | return -1 |
f4647387 | 69 | } |
0a251e08 YQ |
70 | gdb_test_no_output "delete break 1" |
71 | ||
72 | # Set a tracepoint we'll never meet. Just to avoid the | |
73 | # complain after type `tstart' later. | |
74 | gdb_test "next" ".*" | |
75 | gdb_test "trace main" \ | |
76 | "Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \ | |
77 | "set tracepoint on main" | |
78 | ||
79 | gdb_test "break marker" \ | |
80 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
81 | "breakpoint on marker" | |
82 | ||
83 | gdb_test_no_output "tstart" | |
84 | ||
85 | gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ | |
86 | "continue to marker 1" | |
87 | # Set a tracepoint during tracing. | |
88 | set test "set tracepoint on set_tracepoint" | |
89 | gdb_test_multiple "${trace_type} set_tracepoint" $test { | |
90 | -re "Target returns error code .* too far .*$gdb_prompt $" { | |
91 | if [string equal $trace_type "ftrace"] { | |
92 | # The target was unable to install the fast tracepoint | |
93 | # (e.g., jump pad too far from tracepoint). | |
94 | pass "$test (too far)" | |
95 | } else { | |
96 | fail $test | |
97 | } | |
98 | } | |
99 | -re "\r\n$gdb_prompt $" { | |
100 | pass $test | |
101 | } | |
f4647387 | 102 | } |
1e4d1764 | 103 | |
0a251e08 YQ |
104 | gdb_trace_setactions "set action for tracepoint" "" \ |
105 | "collect \$$pcreg" "^$" | |
1e4d1764 | 106 | |
0a251e08 YQ |
107 | # tracepoint has two locations after shlib change-loc-1 is loaded. |
108 | gdb_test "info trace" \ | |
109 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
1e4d1764 | 110 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*" \ |
0a251e08 YQ |
111 | "tracepoint with two locations" |
112 | ||
113 | set test "continue to marker 2" | |
114 | gdb_test_multiple "continue" $test { | |
115 | -re "Target returns error code .* too far .*$gdb_prompt $" { | |
116 | if [string equal $trace_type "ftrace"] { | |
117 | # Expected if the target was unable to install the | |
118 | # fast tracepoint (e.g., jump pad too far from | |
119 | # tracepoint). | |
120 | pass "$test (too far)" | |
121 | # Skip the rest of the tests. | |
122 | return | |
123 | } else { | |
124 | fail "continue to marker 2" | |
125 | fail $test | |
126 | } | |
f4647387 | 127 | |
0a251e08 YQ |
128 | } |
129 | -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { | |
130 | pass "continue to marker 2" | |
131 | } | |
132 | } | |
133 | ||
134 | # tracepoint has three locations after shlib change-loc-2 is | |
135 | # loaded. | |
136 | gdb_test "info trace" \ | |
137 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
1e4d1764 | 138 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* in func4 .*" \ |
0a251e08 | 139 | "tracepoint with three locations" |
1e4d1764 | 140 | |
0a251e08 YQ |
141 | gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ |
142 | "continue to marker 3" | |
bfccc43c | 143 | |
0a251e08 YQ |
144 | # shlib is unloaded, there are still three locations, but one |
145 | # is pending. | |
146 | gdb_test "info trace" \ | |
147 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
f2a8bc8a | 148 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.* |
ba84e0da MK |
149 | (4\.\[1-3].* in func4.*\tinstalled on target.*){2}" \ |
150 | "tracepoint with two locations - installed (unload)" | |
151 | ||
152 | gdb_test "info trace" \ | |
153 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
154 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.* | |
155 | 4\.\[1-3].* \<PENDING\>\[\t \]+set_tracepoint.*" \ | |
156 | "tracepoint with two locations - pending (unload)" | |
bfccc43c | 157 | |
0a251e08 | 158 | gdb_test_no_output "tstop" |
1e4d1764 | 159 | |
0a251e08 YQ |
160 | gdb_test "tfind" "Found trace frame 0, tracepoint 4.*" \ |
161 | "tfind frame 0" | |
162 | gdb_test "tfind" \ | |
163 | "Target failed to find requested trace frame\\..*" | |
164 | } | |
165 | } | |
1e4d1764 | 166 | |
bfccc43c YQ |
167 | # Set pending tracepoint. |
168 | ||
0a251e08 YQ |
169 | proc tracepoint_change_loc_2 { trace_type } { |
170 | with_test_prefix "2 $trace_type" { | |
171 | global srcdir | |
172 | global srcfile | |
173 | global subdir | |
174 | global pcreg | |
175 | global binfile | |
176 | global gdb_prompt | |
177 | ||
a7e727ae | 178 | clean_restart |
0a251e08 YQ |
179 | |
180 | gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" { | |
181 | -re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" { | |
182 | gdb_test "y" "\(Fast t|T\)racepoint.*set_tracepoint.*pending." "set pending tracepoint" | |
183 | } | |
bfccc43c | 184 | } |
bfccc43c | 185 | |
0a251e08 YQ |
186 | gdb_trace_setactions "set action for tracepoint" "" \ |
187 | "collect \$$pcreg" "^$" | |
bfccc43c | 188 | |
0a251e08 YQ |
189 | # tracepoint has no location information now. Make sure nothing |
190 | # else is displayed. | |
191 | gdb_test "info trace" \ | |
192 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
f2a8bc8a | 193 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*PENDING.*set_tracepoint\r\n\[\t \]+collect \\$$pcreg\r" \ |
0a251e08 | 194 | "single pending tracepoint info (without symbols)" |
bfccc43c | 195 | |
0a251e08 YQ |
196 | gdb_load ${binfile} |
197 | # tracepoint has one location after executable is loaded. | |
198 | gdb_test "info trace" \ | |
199 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
bfccc43c | 200 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*func4.*" \ |
0a251e08 | 201 | "tracepoint with one location" |
bfccc43c | 202 | |
0a251e08 | 203 | set main_bp 0 |
e777225b | 204 | gdb_test_multiple "break -q main" "set breakpoint on main" { |
0a251e08 YQ |
205 | -re "Breakpoint (\[0-9\]*) at .*, line.*$gdb_prompt $" { |
206 | set main_bp $expect_out(1,string) | |
207 | } | |
bfccc43c | 208 | } |
0a251e08 | 209 | gdb_run_cmd |
bfccc43c | 210 | |
0a251e08 YQ |
211 | gdb_test "" \ |
212 | ".*Breakpoint.*main.*at.*$srcfile.*" \ | |
213 | "run to main" | |
214 | gdb_test_no_output "delete break $main_bp" | |
bfccc43c | 215 | |
0a251e08 YQ |
216 | # tracepoint has two locations after shlib change-loc-1 is loaded. |
217 | gdb_test "info trace" \ | |
218 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
bfccc43c | 219 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*" \ |
0a251e08 YQ |
220 | "tracepoint with two locations" |
221 | ||
222 | gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
223 | "breakpoint on marker" | |
224 | ||
225 | # tracepoint with two locations will be downloaded and installed. | |
226 | set test "tstart" | |
227 | gdb_test_multiple "tstart" $test { | |
228 | -re "^tstart\r\n$gdb_prompt $" { | |
229 | pass "tstart" | |
230 | } | |
231 | -re "Target returns error code .* too far .*$gdb_prompt $" { | |
232 | if [string equal $trace_type "ftrace"] { | |
233 | # The target was unable to install the fast tracepoint | |
234 | # (e.g., jump pad too far from tracepoint). | |
235 | pass "$test (too far)" | |
236 | # Skip the rest of the tests. | |
237 | return | |
238 | } else { | |
239 | fail $test | |
240 | } | |
241 | } | |
bfccc43c | 242 | } |
bfccc43c | 243 | |
0a251e08 YQ |
244 | gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ |
245 | "continue to marker 1" | |
f4647387 | 246 | |
0a251e08 YQ |
247 | gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ |
248 | "continue to marker 2" | |
bfccc43c | 249 | |
0a251e08 YQ |
250 | # tracepoint has three locations after shlib change-loc-2 is loaded. |
251 | gdb_test "info trace" \ | |
252 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
bfccc43c | 253 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* in func4 .*" \ |
0a251e08 | 254 | "tracepoint with three locations" |
bfccc43c | 255 | |
0a251e08 YQ |
256 | gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ |
257 | "continue to marker 3" | |
bfccc43c | 258 | |
0a251e08 YQ |
259 | # shlib is unloaded, there are still three locations, but one is pending. |
260 | gdb_test "info trace" \ | |
261 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
f2a8bc8a | 262 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.* |
ba84e0da MK |
263 | (1\.\[1-3].* in func4.*\tinstalled on target.*){2}" \ |
264 | "tracepoint with two locations - installed (unload)" | |
265 | ||
266 | gdb_test "info trace" \ | |
267 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
268 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.* | |
269 | 1\.\[1-3].* \<PENDING\>\[\t \]+set_tracepoint.*" \ | |
270 | "tracepoint with two locations - pending (unload)" | |
bfccc43c | 271 | |
0a251e08 | 272 | gdb_test_no_output "tstop" |
bfccc43c | 273 | |
0a251e08 YQ |
274 | gdb_test "tfind" "Found trace frame 0, tracepoint 1.*" "tfind frame 0" |
275 | gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind frame 1" | |
276 | gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind frame 2" | |
277 | gdb_test "tfind" "Target failed to find requested trace frame\\..*" | |
278 | } | |
279 | } | |
1e4d1764 | 280 | |
4082afcc PA |
281 | # Test that setting a tracepoint while the trace experiment is ongoing |
282 | # doesn't work when we force-disable the InstallInTrace RSP feature. | |
283 | ||
284 | proc tracepoint_install_in_trace_disabled { trace_type } { | |
285 | with_test_prefix "InstallInTrace disabled: $trace_type" { | |
286 | global testfile | |
287 | global srcfile | |
288 | global pcreg | |
289 | global gdb_prompt | |
290 | ||
291 | clean_restart ${testfile} | |
292 | if ![runto_main] { | |
4082afcc PA |
293 | return -1 |
294 | } | |
295 | ||
296 | # This test only makes sense with the remote target. | |
297 | if ![gdb_is_target_remote] { | |
298 | return | |
299 | } | |
300 | ||
301 | gdb_test_no_output "delete break 1" | |
302 | ||
303 | # Set a tracepoint we'll never meet. Just to avoid the | |
304 | # complain after `tstart' later. | |
305 | gdb_test "next" ".*" | |
306 | gdb_test "trace main" \ | |
307 | "Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \ | |
308 | "set tracepoint on main" | |
309 | ||
310 | gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
311 | "breakpoint on marker" | |
312 | ||
313 | gdb_test_no_output "tstart" | |
314 | ||
315 | # Force-disable the InstallInTrace RSP feature. | |
ff52c073 CS |
316 | gdb_test \ |
317 | "set remote install-in-trace-packet off" \ | |
318 | "Support for the 'InstallInTrace' packet on the current remote target is set to \"off\"." | |
4082afcc PA |
319 | |
320 | # Set a tracepoint while a trace experiment is ongoing. | |
321 | gdb_test "${trace_type} set_tracepoint" \ | |
322 | "racepoint .* at .* set_tracepoint.*" \ | |
323 | "set tracepoint on set_tracepoint" | |
324 | ||
325 | gdb_trace_setactions "set action for tracepoint" "" \ | |
326 | "collect \$$pcreg" "^$" | |
327 | ||
328 | # Make sure the tracepoint is _not_ installed on the target. | |
329 | gdb_test "info trace" \ | |
330 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
331 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*installed on target.*\<MULTIPLE\>.*4\.1.* in func4.*not installed on target.*4\.2.* in func4.*not installed on target.*" \ | |
332 | "tracepoint is not installed" | |
333 | ||
334 | gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ | |
335 | "continue to marker" | |
336 | ||
337 | gdb_test_no_output "tstop" | |
338 | ||
339 | # Nothing should have been collected. | |
340 | gdb_test "tfind" "Target failed to find requested trace frame\\..*" | |
341 | } | |
342 | } | |
343 | ||
1e4d1764 | 344 | tracepoint_change_loc_1 "trace" |
bfccc43c | 345 | tracepoint_change_loc_2 "trace" |
4082afcc | 346 | tracepoint_install_in_trace_disabled "trace" |
1e4d1764 YQ |
347 | |
348 | # Re-compile test case with IPA. | |
c0d4d1c0 | 349 | set libipa [get_in_proc_agent] |
d9019901 | 350 | gdb_load_shlib $libipa |
1e4d1764 YQ |
351 | |
352 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \ | |
353 | [list debug nowarnings shlib=$libipa shlib=$lib_sl1 shlib_load] ] != "" } { | |
5b362f04 | 354 | untested "failed to compile" |
1e4d1764 YQ |
355 | return -1 |
356 | } | |
357 | ||
358 | tracepoint_change_loc_1 "ftrace" | |
bfccc43c | 359 | tracepoint_change_loc_2 "ftrace" |
4082afcc | 360 | tracepoint_install_in_trace_disabled "ftrace" |