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