1 # Copyright 2011-2012 Free Software Foundation, Inc.
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.
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.
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/>.
15 load_lib "trace-support.exp";
17 if {[skip_shlib_tests]} {
21 set testfile "change-loc"
22 set libfile1 "change-loc-1"
23 set libfile2 "change-loc-2"
24 set srcfile $testfile.c
25 set executable $testfile
26 set libsrc1 $srcdir/$subdir/$libfile1.c
27 set libsrc2 $srcdir/$subdir/$libfile2.c
28 set binfile $objdir/$subdir/$testfile
29 set lib_sl1 $objdir/$subdir/$libfile1.sl
30 set lib_sl2 $objdir/$subdir/$libfile2.sl
34 if [get_compiler_info ${binfile}] {
38 # Some targets have leading underscores on assembly symbols.
39 set additional_flags [list debug shlib=$lib_sl1 shlib_load [gdb_target_symbol_prefix_flags]]
41 if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
42 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""
43 || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} {
44 untested "Could not compile either $libsrc1 or $srcdir/$subdir/$srcfile."
48 clean_restart $executable
50 gdb_load_shlibs $lib_sl1
51 gdb_load_shlibs $lib_sl2
54 fail "Can't run to main to check for trace support"
58 if { ![gdb_target_supports_trace] } then {
59 unsupported "Current target does not support trace"
63 if [is_amd64_regs_target] {
65 } elseif [is_x86_like_target] {
72 # Set tracepoint during tracing experiment.
74 proc tracepoint_change_loc_1 { trace_type } {
81 set old_pf_prefix $pf_prefix
82 set pf_prefix "$pf_prefix 1 $trace_type:"
84 clean_restart ${testfile}
86 fail "Can't run to main"
87 set pf_prefix $old_pf_prefix
90 gdb_test_no_output "delete break 1"
92 # Set a tracepoint we'll never meet. Just to avoid the complain after
93 # type `tstart' later.
95 gdb_test "trace main" "Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \
96 "set tracepoint on main"
98 gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
99 "breakpoint on marker"
101 gdb_test_no_output "tstart"
103 gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
104 "continue to marker 1"
105 # Set a tracepoint during tracing.
106 gdb_test "${trace_type} set_tracepoint" ".*" "set tracepoint on set_tracepoint"
108 gdb_trace_setactions "set action for tracepoint" "" \
109 "collect \$$pcreg" "^$"
111 # tracepoint has two locations after shlib change-loc-1 is loaded.
112 gdb_test "info trace" \
113 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
114 \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*" \
115 "tracepoint with two locations"
117 gdb_test_multiple "continue" "continue to marker 2" {
118 -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
119 pass "continue to marker 2"
121 -re ".*$gdb_prompt $" {
122 kfail "gdb/13392" "continue to marker 2"
123 set pf_prefix $old_pf_prefix
127 # tracepoint has three locations after shlib change-loc-2 is loaded.
128 gdb_test "info trace" \
129 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
130 \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* in func4 .*" \
131 "tracepoint with three locations"
133 gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
134 "continue to marker 3"
136 # shlib is unloaded, there are still three locations, but one is pending.
137 gdb_test "info trace" \
138 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
139 \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* \<PENDING\>\[\t \]+set_tracepoint.*" \
140 "tracepoint with two locations (unload)"
142 gdb_test_no_output "tstop"
144 gdb_test "tfind" "Found trace frame 0, tracepoint 4.*" "tfind frame 0"
145 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
147 set pf_prefix $old_pf_prefix
150 # Set pending tracepoint.
152 proc tracepoint_change_loc_2 { trace_type } {
161 set old_pf_prefix $pf_prefix
162 set pf_prefix "$pf_prefix 2 $trace_type:"
166 gdb_reinitialize_dir $srcdir/$subdir
168 gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" {
169 -re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" {
170 gdb_test "y" "\(Fast t|T\)racepoint.*set_tracepoint.*pending." "set pending tracepoint"
174 gdb_trace_setactions "set action for tracepoint" "" \
175 "collect \$$pcreg" "^$"
177 # tracepoint has no location information now.
178 gdb_test "info trace" \
179 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
180 \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*PENDING.*set_tracepoint.*" \
181 "single pending tracepoint info (without symbols)"
184 # tracepoint has one location after executable is loaded.
185 gdb_test "info trace" \
186 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
187 \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*func4.*" \
188 "tracepoint with one location"
191 gdb_test_multiple "break main" "set breakpoint on main" {
192 -re "Breakpoint (\[0-9\]*) at .*, line.*$gdb_prompt $" {
193 set main_bp $expect_out(1,string)
199 ".*Breakpoint.*main.*at.*$srcfile.*" \
201 gdb_test_no_output "delete break $main_bp"
203 # tracepoint has two locations after shlib change-loc-1 is loaded.
204 gdb_test "info trace" \
205 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
206 \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*" \
207 "tracepoint with two locations"
209 gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
210 "breakpoint on marker"
212 # tracepoint with two locations will be downloaded and installed.
213 gdb_test_no_output "tstart"
215 gdb_test_multiple "continue" "continue to marker 1" {
216 -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" {
217 pass "continue to marker 1"
219 -re ".*$gdb_prompt $" {
220 kfail "gdb/13392" "continue to marker 1"
221 set pf_prefix $old_pf_prefix
226 gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
227 "continue to marker 2"
229 # tracepoint has three locations after shlib change-loc-2 is loaded.
230 gdb_test "info trace" \
231 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
232 \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* in func4 .*" \
233 "tracepoint with three locations"
235 gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
236 "continue to marker 3"
238 # shlib is unloaded, there are still three locations, but one is pending.
239 gdb_test "info trace" \
240 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
241 \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* \<PENDING\>\[\t \]+set_tracepoint.*" \
242 "tracepoint with two locations (unload)"
244 gdb_test_no_output "tstop"
246 gdb_test "tfind" "Found trace frame 0, tracepoint 1.*" "tfind frame 0"
247 gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind frame 1"
248 gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind frame 2"
249 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
251 set pf_prefix $old_pf_prefix
254 tracepoint_change_loc_1 "trace"
255 tracepoint_change_loc_2 "trace"
257 # Re-compile test case with IPA.
258 set libipa $objdir/../gdbserver/libinproctrace.so
259 gdb_load_shlibs $libipa
261 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \
262 [list debug nowarnings shlib=$libipa shlib=$lib_sl1 shlib_load] ] != "" } {
263 untested change-loc.exp
267 tracepoint_change_loc_1 "ftrace"
268 tracepoint_change_loc_2 "ftrace"