]>
Commit | Line | Data |
---|---|---|
c5a57081 | 1 | # Copyright 2011-2012 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 | ||
15 | load_lib "trace-support.exp"; | |
16 | ||
17 | if $tracelevel then { | |
18 | strace $tracelevel | |
19 | } | |
20 | ||
21 | if {[skip_shlib_tests]} { | |
22 | return 0 | |
23 | } | |
24 | ||
25 | set testfile "change-loc" | |
26 | set libfile1 "change-loc-1" | |
27 | set libfile2 "change-loc-2" | |
28 | set srcfile $testfile.c | |
29 | set executable $testfile | |
30 | set libsrc1 $srcdir/$subdir/$libfile1.c | |
31 | set libsrc2 $srcdir/$subdir/$libfile2.c | |
32 | set binfile $objdir/$subdir/$testfile | |
33 | set lib_sl1 $objdir/$subdir/$libfile1.sl | |
34 | set lib_sl2 $objdir/$subdir/$libfile2.sl | |
35 | ||
36 | set lib_opts debug | |
37 | ||
38 | if [get_compiler_info ${binfile}] { | |
39 | return -1 | |
40 | } | |
41 | ||
42 | # Some targets have leading underscores on assembly symbols. | |
43 | set additional_flags [list debug shlib=$lib_sl1 shlib_load [gdb_target_symbol_prefix_flags]] | |
44 | ||
45 | if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != "" | |
46 | || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != "" | |
47 | || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} { | |
48 | untested "Could not compile either $libsrc1 or $srcdir/$subdir/$srcfile." | |
49 | return -1 | |
50 | } | |
51 | ||
52 | clean_restart $executable | |
53 | ||
54 | gdb_load_shlibs $lib_sl1 | |
55 | gdb_load_shlibs $lib_sl2 | |
56 | ||
57 | if ![runto_main] { | |
58 | fail "Can't run to main to check for trace support" | |
59 | return -1 | |
60 | } | |
61 | ||
62 | if { ![gdb_target_supports_trace] } then { | |
63 | unsupported "Current target does not support trace" | |
64 | return -1; | |
65 | } | |
66 | ||
67 | if [is_amd64_regs_target] { | |
68 | set pcreg "rip" | |
69 | } elseif [is_x86_like_target] { | |
70 | set pcreg "eip" | |
71 | } else { | |
72 | set pcreg "pc" | |
73 | } | |
74 | ||
75 | ||
76 | # Set tracepoint during tracing experiment. | |
77 | ||
78 | proc tracepoint_change_loc_1 { trace_type } { | |
79 | global testfile | |
80 | global srcfile | |
81 | global pcreg | |
82 | global gdb_prompt | |
83 | global pf_prefix | |
84 | ||
85 | set old_pf_prefix $pf_prefix | |
86 | set pf_prefix "$pf_prefix 1 $trace_type:" | |
87 | ||
88 | clean_restart ${testfile} | |
89 | if ![runto_main] { | |
90 | fail "Can't run to main" | |
91 | set pf_prefix $old_pf_prefix | |
92 | return -1 | |
93 | } | |
94 | gdb_test_no_output "delete break 1" | |
95 | ||
96 | # Set a tracepoint we'll never meet. Just to avoid the complain after | |
97 | # type `tstart' later. | |
98 | gdb_test "next" ".*" | |
99 | gdb_test "trace main" "Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \ | |
100 | "set tracepoint on main" | |
101 | ||
102 | gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
103 | "breakpoint on marker" | |
104 | ||
105 | gdb_test_no_output "tstart" | |
106 | ||
107 | gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ | |
108 | "continue to marker 1" | |
109 | # Set a tracepoint during tracing. | |
110 | gdb_test "${trace_type} set_tracepoint" ".*" "set tracepoint on set_tracepoint" | |
111 | ||
112 | gdb_trace_setactions "set action for tracepoint" "" \ | |
113 | "collect \$$pcreg" "^$" | |
114 | ||
115 | # tracepoint has two locations after shlib change-loc-1 is loaded. | |
116 | gdb_test "info trace" \ | |
117 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
118 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*" \ | |
119 | "tracepoint with two locations" | |
120 | ||
bfccc43c YQ |
121 | gdb_test_multiple "continue" "continue to marker 2" { |
122 | -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { | |
123 | pass "continue to marker 2" | |
124 | } | |
125 | -re ".*$gdb_prompt $" { | |
126 | kfail "gdb/13392" "continue to marker 2" | |
127 | set pf_prefix $old_pf_prefix | |
128 | return | |
129 | } | |
130 | } | |
1e4d1764 YQ |
131 | # tracepoint has three locations after shlib change-loc-2 is loaded. |
132 | gdb_test "info trace" \ | |
133 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
134 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* in func4 .*" \ | |
135 | "tracepoint with three locations" | |
136 | ||
bfccc43c YQ |
137 | gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ |
138 | "continue to marker 3" | |
139 | ||
140 | # shlib is unloaded, there are still three locations, but one is pending. | |
141 | gdb_test "info trace" \ | |
142 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
143 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* \<PENDING\>\[\t \]+set_tracepoint.*" \ | |
144 | "tracepoint with two locations (unload)" | |
145 | ||
1e4d1764 YQ |
146 | gdb_test_no_output "tstop" |
147 | ||
1e4d1764 YQ |
148 | gdb_test "tfind" "Found trace frame 0, tracepoint 4.*" "tfind frame 0" |
149 | gdb_test "tfind" "Target failed to find requested trace frame\\..*" | |
150 | ||
151 | set pf_prefix $old_pf_prefix | |
152 | } | |
153 | ||
bfccc43c YQ |
154 | # Set pending tracepoint. |
155 | ||
156 | proc tracepoint_change_loc_2 { trace_type } { | |
157 | global srcdir | |
158 | global srcfile | |
159 | global subdir | |
160 | global pcreg | |
161 | global binfile | |
162 | global gdb_prompt | |
163 | global pf_prefix | |
164 | ||
165 | set old_pf_prefix $pf_prefix | |
166 | set pf_prefix "$pf_prefix 2 $trace_type:" | |
167 | ||
168 | gdb_exit | |
169 | gdb_start | |
170 | gdb_reinitialize_dir $srcdir/$subdir | |
171 | ||
172 | gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" { | |
173 | -re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" { | |
174 | gdb_test "y" "\(Fast t|T\)racepoint.*set_tracepoint.*pending." "set pending tracepoint" | |
175 | } | |
176 | } | |
177 | ||
178 | gdb_trace_setactions "set action for tracepoint" "" \ | |
179 | "collect \$$pcreg" "^$" | |
180 | ||
181 | # tracepoint has no location information now. | |
182 | gdb_test "info trace" \ | |
183 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
184 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*PENDING.*set_tracepoint.*" \ | |
185 | "single pending tracepoint info (without symbols)" | |
186 | ||
187 | gdb_load ${binfile} | |
188 | # tracepoint has one location after executable is loaded. | |
189 | gdb_test "info trace" \ | |
190 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
191 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*func4.*" \ | |
192 | "tracepoint with one location" | |
193 | ||
194 | set main_bp 0 | |
195 | gdb_test_multiple "break main" "set breakpoint on main" { | |
196 | -re "Breakpoint (\[0-9\]*) at .*, line.*$gdb_prompt $" { | |
197 | set main_bp $expect_out(1,string) | |
198 | } | |
199 | } | |
200 | gdb_run_cmd | |
201 | ||
202 | gdb_test "" \ | |
203 | ".*Breakpoint.*main.*at.*$srcfile.*" \ | |
204 | "run to main" | |
205 | gdb_test_no_output "delete break $main_bp" | |
206 | ||
207 | # tracepoint has two locations after shlib change-loc-1 is loaded. | |
208 | gdb_test "info trace" \ | |
209 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
210 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*" \ | |
211 | "tracepoint with two locations" | |
212 | ||
213 | gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
214 | "breakpoint on marker" | |
215 | ||
216 | # tracepoint with two locations will be downloaded and installed. | |
217 | gdb_test_no_output "tstart" | |
218 | ||
219 | gdb_test_multiple "continue" "continue to marker 1" { | |
220 | -re ".*Breakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { | |
221 | pass "continue to marker 1" | |
222 | } | |
223 | -re ".*$gdb_prompt $" { | |
224 | kfail "gdb/13392" "continue to marker 1" | |
225 | set pf_prefix $old_pf_prefix | |
226 | return | |
227 | } | |
228 | } | |
229 | ||
230 | gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ | |
231 | "continue to marker 2" | |
232 | ||
233 | # tracepoint has three locations after shlib change-loc-2 is loaded. | |
234 | gdb_test "info trace" \ | |
235 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
236 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* in func4 .*" \ | |
237 | "tracepoint with three locations" | |
238 | ||
239 | gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \ | |
240 | "continue to marker 3" | |
241 | ||
242 | # shlib is unloaded, there are still three locations, but one is pending. | |
243 | gdb_test "info trace" \ | |
244 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
245 | \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*1\.1.* in func4.*1\.2.* in func4.*1\.3.* \<PENDING\>\[\t \]+set_tracepoint.*" \ | |
246 | "tracepoint with two locations (unload)" | |
247 | ||
248 | gdb_test_no_output "tstop" | |
249 | ||
250 | gdb_test "tfind" "Found trace frame 0, tracepoint 1.*" "tfind frame 0" | |
251 | gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind frame 1" | |
252 | gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind frame 2" | |
253 | gdb_test "tfind" "Target failed to find requested trace frame\\..*" | |
254 | ||
255 | set pf_prefix $old_pf_prefix | |
256 | } | |
1e4d1764 YQ |
257 | |
258 | tracepoint_change_loc_1 "trace" | |
bfccc43c | 259 | tracepoint_change_loc_2 "trace" |
1e4d1764 YQ |
260 | |
261 | # Re-compile test case with IPA. | |
262 | set libipa $objdir/../gdbserver/libinproctrace.so | |
263 | gdb_load_shlibs $libipa | |
264 | ||
265 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \ | |
266 | [list debug nowarnings shlib=$libipa shlib=$lib_sl1 shlib_load] ] != "" } { | |
267 | untested change-loc.exp | |
268 | return -1 | |
269 | } | |
270 | ||
271 | tracepoint_change_loc_1 "ftrace" | |
bfccc43c | 272 | tracepoint_change_loc_2 "ftrace" |