Commit | Line | Data |
---|---|---|
c5a57081 | 1 | # Copyright 2011-2012 Free Software Foundation, Inc. |
bfccc43c 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 | ||
bfccc43c YQ |
17 | if {[skip_shlib_tests]} { |
18 | return 0 | |
19 | } | |
20 | ||
21 | set testfile "pending" | |
22 | set libfile1 "pendshr1" | |
23 | set libfile2 "pendshr2" | |
24 | set executable $testfile | |
25 | set srcfile $testfile.c | |
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 [gdb_target_symbol_prefix_flags] | |
33 | ||
34 | if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != "" | |
35 | || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} { | |
36 | untested "Could not compile either $libsrc1 or $libsrc2" | |
37 | return -1 | |
38 | } | |
39 | ||
40 | set exec_opts [list debug shlib=$lib_sl1 shlib_load] | |
41 | if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } { | |
42 | untested "Failed to compile $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] { | |
57 | unsupported "Current target does not support trace" | |
58 | return -1; | |
59 | } | |
60 | ||
61 | # Verify pending tracepoint is resolved to running to main. | |
62 | ||
0f4d39d5 | 63 | proc pending_tracepoint_resolved { trace_type } { with_test_prefix "$trace_type resolved" { |
bfccc43c YQ |
64 | global srcdir |
65 | global subdir | |
66 | global binfile | |
67 | global srcfile | |
68 | global lib_sl1 | |
bfccc43c YQ |
69 | |
70 | # Start with a fresh gdb. | |
71 | gdb_exit | |
72 | gdb_start | |
73 | gdb_reinitialize_dir $srcdir/$subdir | |
74 | ||
75 | gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" { | |
76 | -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { | |
77 | gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." \ | |
78 | "set pending tracepoint (without symbols)" | |
79 | } | |
80 | } | |
81 | ||
82 | gdb_test "info trace" \ | |
83 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
84 | \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point1.*" \ | |
85 | "single pending tracepoint info (without symbols)" | |
86 | ||
87 | gdb_load ${binfile} | |
88 | ||
89 | gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
90 | "breakpoint function" | |
91 | ||
92 | gdb_run_cmd | |
93 | gdb_test "" "Breakpoint 2, main.*" | |
94 | ||
95 | # Run to main which should resolve a pending tracepoint | |
96 | gdb_test "info trace" \ | |
97 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
98 | \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc.*" \ | |
99 | "single tracepoint info" | |
6a5870ce | 100 | }} |
bfccc43c YQ |
101 | |
102 | # Verify pending tracepoint is resolved and works as expected. | |
103 | ||
0f4d39d5 | 104 | proc pending_tracepoint_works { trace_type } { with_test_prefix "$trace_type works" { |
bfccc43c YQ |
105 | global executable |
106 | global srcfile | |
107 | global lib_sl1 | |
bfccc43c YQ |
108 | global gdb_prompt |
109 | ||
bfccc43c YQ |
110 | # Restart with a fresh gdb. |
111 | clean_restart $executable | |
112 | ||
113 | # Test setting and querying pending tracepoints | |
114 | ||
115 | gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" { | |
116 | -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { | |
117 | gdb_test "y" "\(Fast t|T\)racepoint.*set_point1.*pending." "set pending tracepoint" | |
118 | } | |
119 | } | |
120 | ||
121 | gdb_test "info trace" \ | |
122 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
123 | \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point1.*" \ | |
124 | "single pending tracepoint info" | |
125 | ||
126 | # Run to main which should resolve a pending tracepoint | |
127 | gdb_test "break main" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
128 | "breakpoint function" | |
129 | gdb_run_cmd | |
130 | gdb_test "" "Breakpoint 2, main.*" | |
131 | ||
132 | gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
133 | "breakpoint on marker" | |
134 | ||
135 | gdb_test_no_output "tstart" "start trace experiment" | |
136 | ||
137 | gdb_test_multiple "continue" "continue to marker" { | |
138 | -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { | |
139 | pass "continue to marker" | |
140 | } | |
141 | -re ".*$gdb_prompt $" { | |
142 | kfail "gdb/13392" "continue to marker" | |
bfccc43c YQ |
143 | return |
144 | } | |
145 | } | |
146 | ||
147 | gdb_test "tstop" "\[\r\n\]+" "stop trace experiment" | |
148 | ||
149 | gdb_test "tfind start" "#0 .*" "tfind test frame 0" | |
150 | gdb_test "tfind" "Found trace frame 1, tracepoint 1.*" "tfind test frame 1" | |
151 | gdb_test "tfind" "Found trace frame 2, tracepoint 1.*" "tfind test frame 2" | |
152 | gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame" | |
6a5870ce | 153 | }} |
bfccc43c YQ |
154 | |
155 | # Verify pending tracepoint is resolved during trace. | |
156 | ||
6a5870ce | 157 | proc pending_tracepoint_resolved_during_trace { trace_type } \ |
0f4d39d5 | 158 | { with_test_prefix "$trace_type resolved_in_trace" \ |
6a5870ce | 159 | { |
bfccc43c YQ |
160 | global executable |
161 | global srcfile | |
162 | global gdb_prompt | |
163 | global lib_sl1 | |
bfccc43c YQ |
164 | |
165 | # Start with a fresh gdb. | |
166 | clean_restart $executable | |
167 | if ![runto_main] { | |
168 | fail "Can't run to main" | |
bfccc43c YQ |
169 | return -1 |
170 | } | |
171 | ||
172 | gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" { | |
173 | -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { | |
174 | gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \ | |
175 | "set pending tracepoint (without symbols)" | |
176 | } | |
177 | } | |
178 | ||
179 | gdb_test "info trace" \ | |
180 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
181 | \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point2.*" \ | |
182 | "single pending tracepoint on set_point2" | |
183 | ||
184 | gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
185 | "breakpoint on marker" | |
186 | ||
187 | gdb_test_no_output "tstart" "start trace experiment" | |
188 | ||
189 | gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \ | |
190 | "continue to marker 1" | |
191 | ||
192 | gdb_test_multiple "continue" "continue to marker 2" { | |
193 | -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { | |
194 | pass "continue to marker 2" | |
195 | } | |
196 | -re ".*$gdb_prompt $" { | |
197 | kfail "gdb/13392" "continue to marker 2" | |
bfccc43c YQ |
198 | return |
199 | } | |
200 | } | |
201 | ||
202 | gdb_test "tstop" "\[\r\n\]+" "stop trace experiment" | |
203 | ||
204 | # tracepoint should be resolved. | |
205 | gdb_test "info trace" \ | |
206 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
207 | \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \ | |
208 | "tracepoint is resolved" | |
209 | ||
210 | gdb_test "tfind start" "#0 .*" "tfind test frame 0" | |
211 | gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame" | |
6a5870ce | 212 | }} |
bfccc43c YQ |
213 | |
214 | # Verify pending tracepoint is resolved and installed during trace. | |
215 | ||
6a5870ce | 216 | proc pending_tracepoint_installed_during_trace { trace_type } \ |
0f4d39d5 | 217 | { with_test_prefix "$trace_type installed_in_trace" \ |
6a5870ce | 218 | { |
bfccc43c YQ |
219 | global executable |
220 | global srcfile | |
221 | global lib_sl1 | |
222 | global gdb_prompt | |
bfccc43c YQ |
223 | global hex |
224 | ||
bfccc43c YQ |
225 | # Start with a fresh gdb. |
226 | clean_restart $executable | |
227 | if ![runto_main] { | |
228 | fail "Can't run to main" | |
bfccc43c YQ |
229 | return -1 |
230 | } | |
231 | ||
232 | gdb_test "next" ".*" | |
233 | gdb_test "trace main" "Tracepoint \[0-9\] at .*" "set tracepoint on main" | |
234 | ||
235 | gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
236 | "breakpoint on marker" | |
237 | ||
238 | gdb_test_no_output "tstart" "start trace experiment" | |
239 | ||
240 | gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*${srcfile}.*" \ | |
241 | "continue to marker 1" | |
242 | ||
243 | # Set a pending tracepoint during a tracing experiment. | |
244 | gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" { | |
245 | -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { | |
246 | gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \ | |
247 | "set pending tracepoint" | |
248 | } | |
249 | } | |
250 | ||
251 | gdb_test "info trace" \ | |
252 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
253 | \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \t\]+keep y.*PENDING.*set_point2.*" \ | |
254 | "single pending tracepoint on set_point2" | |
255 | ||
256 | gdb_test_multiple "continue" "continue to marker 2" { | |
257 | -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { | |
258 | pass "continue to marker 2" | |
259 | } | |
260 | -re ".*$gdb_prompt $" { | |
261 | kfail "gdb/13392" "continue to marker 2" | |
bfccc43c YQ |
262 | return |
263 | } | |
264 | } | |
265 | ||
266 | gdb_test "tstop" "\[\r\n\]+" "stop trace experiment" | |
267 | ||
268 | # tracepoint should be resolved. | |
269 | gdb_test "info trace" \ | |
270 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
271 | \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \ | |
272 | "tracepoint is resolved" | |
273 | ||
274 | gdb_test "tfind start" "#0 $hex in pendfunc2 .*" "tfind test frame 0" | |
275 | gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame" | |
6a5870ce | 276 | }} |
bfccc43c YQ |
277 | |
278 | ||
279 | # Verify pending tracepoint will no longer work if we disconnect during tracing. | |
280 | ||
6a5870ce | 281 | proc pending_tracepoint_disconnect_during_trace { trace_type } \ |
0f4d39d5 | 282 | { with_test_prefix "$trace_type disconn" \ |
6a5870ce | 283 | { |
bfccc43c YQ |
284 | global executable |
285 | global srcfile | |
286 | global lib_sl1 | |
bfccc43c YQ |
287 | global gdb_prompt |
288 | ||
bfccc43c YQ |
289 | # Start with a fresh gdb. |
290 | clean_restart $executable | |
291 | if ![runto_main] { | |
292 | fail "Can't run to main" | |
bfccc43c YQ |
293 | return -1 |
294 | } | |
295 | ||
296 | gdb_test_multiple "trace pendfunc3" "set pending tracepoint on set_point2" { | |
297 | -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { | |
298 | gdb_test "y" "\(Fast t|T\)racepoint.*pendfunc3.*pending." \ | |
299 | "set pending tracepoint on pendfun3" | |
300 | } | |
301 | } | |
302 | ||
303 | gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
304 | "breakpoint on marker" | |
305 | ||
306 | gdb_test_no_output "tstart" "start trace experiment" | |
307 | ||
308 | gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \ | |
309 | "continue to marker" | |
310 | ||
311 | set test "disconnect with pending tracepoint" | |
312 | gdb_test_multiple "disconnect" $test { | |
313 | -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { | |
314 | pass $test | |
315 | ||
316 | set test "disconnected" | |
317 | gdb_test_multiple "y" $test { | |
318 | -re "$gdb_prompt $" { | |
319 | pass "$test" | |
320 | } | |
321 | } | |
322 | } | |
323 | } | |
6a5870ce | 324 | }} |
bfccc43c YQ |
325 | |
326 | ||
327 | # Verify disconnect after pending tracepoint has been resolved. | |
328 | ||
6a5870ce | 329 | proc pending_tracepoint_disconnect_after_resolved { trace_type } \ |
0f4d39d5 | 330 | { with_test_prefix "$trace_type disconn_resolved" \ |
6a5870ce | 331 | { |
bfccc43c YQ |
332 | global executable |
333 | global srcfile | |
334 | global lib_sl1 | |
335 | global gdb_prompt | |
bfccc43c YQ |
336 | |
337 | # Start with a fresh gdb. | |
338 | clean_restart $executable | |
339 | if ![runto_main] { | |
340 | fail "Can't run to main" | |
bfccc43c YQ |
341 | return -1 |
342 | } | |
343 | ||
344 | gdb_test_multiple "trace set_point2" "set pending tracepoint on set_point2" { | |
345 | -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { | |
346 | gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \ | |
347 | "set pending tracepoint on pendfun2" | |
348 | } | |
349 | } | |
350 | ||
351 | gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
352 | "breakpoint on marker" | |
353 | ||
354 | gdb_test_no_output "tstart" "start trace experiment" | |
355 | ||
356 | gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \ | |
357 | "continue to marker 1" | |
358 | gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \ | |
359 | "continue to marker 2" | |
360 | ||
361 | # There should be no pending tracepoint, so no warning should be emitted. | |
362 | set test "disconnect with resolved tracepoint" | |
363 | gdb_test_multiple "disconnect" $test { | |
364 | -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { | |
365 | fail $test | |
366 | } | |
367 | -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { | |
368 | pass $test | |
369 | } | |
370 | } | |
371 | set test "disconnected" | |
372 | gdb_test_multiple "y" $test { | |
373 | -re "$gdb_prompt $" { | |
374 | pass "$test" | |
375 | } | |
376 | } | |
6a5870ce | 377 | }} |
bfccc43c YQ |
378 | |
379 | # Verify action works properly in resolved tracepoint. | |
380 | ||
6a5870ce | 381 | proc pending_tracepoint_with_action_resolved { trace_type } \ |
0f4d39d5 | 382 | { with_test_prefix "$trace_type action_resolved" \ |
6a5870ce | 383 | { |
bfccc43c YQ |
384 | global executable |
385 | global srcfile | |
386 | global lib_sl1 | |
387 | global gdb_prompt | |
bfccc43c YQ |
388 | |
389 | # Start with a fresh gdb. | |
390 | clean_restart $executable | |
391 | if ![runto_main] { | |
392 | fail "Can't run to main" | |
bfccc43c YQ |
393 | return -1 |
394 | } | |
395 | ||
396 | gdb_test_multiple "$trace_type set_point2" "set pending tracepoint on set_point2" { | |
397 | -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" { | |
398 | gdb_test "y" "\(Fast t|T\)racepoint.*set_point2.*pending." \ | |
399 | "set pending tracepoint (without symbols)" | |
400 | } | |
401 | } | |
402 | ||
403 | set pcreg "pc" | |
404 | if [is_amd64_regs_target] { | |
405 | set pcreg "rip" | |
406 | } elseif [is_x86_like_target] { | |
407 | set pcreg "eip" | |
408 | } | |
409 | ||
410 | gdb_trace_setactions "set action for pending tracepoint" "" \ | |
411 | "collect \$$pcreg" "^$" | |
412 | ||
413 | gdb_test "info trace" \ | |
414 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
415 | \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*PENDING.*set_point2.*" \ | |
416 | "single pending tracepoint on set_point2" | |
417 | ||
418 | gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
419 | "breakpoint on marker" | |
420 | ||
421 | gdb_test_no_output "tstart" "start trace experiment" | |
422 | ||
423 | gdb_test "continue" "Continuing.\r\n\r\nBreakpoint.*marker.*at.*pending.c.*" \ | |
424 | "continue to marker 1" | |
425 | ||
426 | gdb_test_multiple "continue" "continue to marker 2" { | |
427 | -re "Continuing.\r\n\r\nBreakpoint.*marker.*at.*$srcfile.*$gdb_prompt $" { | |
428 | pass "continue to marker 2" | |
429 | } | |
430 | -re ".*$gdb_prompt $" { | |
431 | kfail "gdb/13392" "continue to marker 2" | |
bfccc43c YQ |
432 | return |
433 | } | |
434 | } | |
435 | ||
436 | gdb_test "tstop" "\[\r\n\]+" "stop trace experiment" | |
437 | ||
438 | # tracepoint should be resolved. | |
439 | gdb_test "info trace" \ | |
440 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
441 | \[0-9\]+\[\t \]+\(fast |\)tracepoint\[ \]+keep y.*pendfunc2.*" \ | |
442 | "tracepoint is resolved" | |
443 | ||
444 | gdb_test "tfind start" "#0 .*" "tfind test frame 0" | |
445 | gdb_test "tdump" "Data collected at tracepoint .*, trace frame \[0-9\]:.*\\$${pcreg} = .*" | |
446 | gdb_test "tfind" "Target failed to find requested trace frame..*" "tfind test frame" | |
6a5870ce | 447 | }} |
bfccc43c YQ |
448 | |
449 | pending_tracepoint_resolved "trace" | |
450 | ||
451 | pending_tracepoint_works "trace" | |
452 | ||
453 | pending_tracepoint_resolved_during_trace "trace" | |
454 | ||
455 | pending_tracepoint_disconnect_during_trace "trace" | |
456 | ||
457 | pending_tracepoint_disconnect_after_resolved "trace" | |
458 | ||
459 | pending_tracepoint_with_action_resolved "trace" | |
460 | ||
461 | pending_tracepoint_installed_during_trace "trace" | |
462 | ||
463 | # Re-compile test case with IPA. | |
464 | set libipa $objdir/../gdbserver/libinproctrace.so | |
465 | gdb_load_shlibs $libipa | |
466 | ||
467 | lappend exec_opts "shlib=$libipa" | |
468 | ||
469 | if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } { | |
470 | untested "Failed to compile $srcfile" | |
471 | return -1 | |
472 | } | |
473 | ||
474 | pending_tracepoint_resolved "ftrace" | |
475 | pending_tracepoint_works "ftrace" | |
476 | pending_tracepoint_resolved_during_trace "ftrace" | |
477 | pending_tracepoint_disconnect_during_trace "ftrace" | |
478 | pending_tracepoint_disconnect_after_resolved "ftrace" | |
479 | pending_tracepoint_with_action_resolved "ftrace" | |
480 | pending_tracepoint_installed_during_trace "ftrace" |