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