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