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]} {
22 set srcfile $testfile.c
23 set binfile $objdir/$subdir/$testfile
24 set executable $testfile
26 set libipa $objdir/../gdbserver/libinproctrace.so
30 if [get_compiler_info ${binfile}] {
34 set additional_flags [list debug shlib=$libipa shlib_load "additional_flags=-lust -lurcu-bp" ]
36 if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} {
37 untested "UST library or headers are not installed"
41 clean_restart $executable
44 fail "Can't run to main to check for trace support"
48 if { ![gdb_target_supports_trace] } then {
49 unsupported "Current target does not support trace"
53 gdb_load_shlibs $libipa
55 proc strace_info_marker { } {
59 set old_pf_prefix $pf_prefix
60 lappend pf_prefix "info_marker"
62 # Restart with a fresh gdb.
63 clean_restart $executable
65 fail "Can't run to main"
66 set pf_prefix $old_pf_prefix
70 # List the markers in program. They should be disabled.
71 gdb_test "info static-tracepoint-markers" \
72 ".*ust/bar\[\t \]+n\[\t \]+.*ust/bar2\[\t \]+n\[\t \]+.*"
74 set pf_prefix $old_pf_prefix
77 proc strace_probe_marker { } {
84 set old_pf_prefix $pf_prefix
85 lappend pf_prefix "probe_marker"
87 # Restart with a fresh gdb.
88 clean_restart $executable
90 fail "Can't run to main"
91 set pf_prefix $old_pf_prefix
95 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
96 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
97 # Two trace markers should be enabled.
98 gdb_test "info static-tracepoint-markers" "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*"
100 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
102 gdb_test_no_output "tstart"
103 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
104 gdb_test_no_output "tstop"
106 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
107 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
108 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
110 set pf_prefix $old_pf_prefix
113 proc strace_trace_on_same_addr { type } {
120 set old_pf_prefix $pf_prefix
121 lappend pf_prefix "trace_same_addr" "$type"
123 # Restart with a fresh gdb.
124 clean_restart $executable
126 fail "Can't run to main"
127 set pf_prefix $old_pf_prefix
131 set marker_bar_addr ""
132 set marker_bar2_addr ""
134 # List the markers in program. They should be disabled.
135 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" {
136 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" {
139 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \
140 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr
142 pass "info static-tracepoint-markers 1"
144 -re ".*${gdb_prompt} $" {
145 fail "info static-tracepoint-markers 1"
149 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
150 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
151 # Two trace markers should be enabled.
152 gdb_test "info static-tracepoint-markers" \
153 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" \
154 "info static-tracepoint-markers 2"
156 # Set breapoints or tracepoints.
157 set test "${type} on marker bar"
158 gdb_test_multiple "${type} *${marker_bar_addr}" $test {
159 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*\r\n$gdb_prompt $" {
162 -re ".*\r\n$gdb_prompt $" {
163 if [string equal $type "ftrace"] {
164 # The instruction may be not long enough to set a fast tracepoint.
165 # Skip the rest of this test.
172 set test "${type} on marker bar2"
173 gdb_test_multiple "${type} *${marker_bar2_addr}" $test {
174 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*" {
177 -re ".*\r\n$gdb_prompt $" {
178 if [string equal $type "ftrace"] {
179 # The instruction may be not long enough to set a fast tracepoint.
180 # Skip the rest of this test.
188 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
190 if [string equal $type "break"] {
191 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to bar"
192 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to bar2"
193 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
196 gdb_test_no_output "tstart"
197 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
198 gdb_test_no_output "tstop"
200 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
201 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
202 gdb_test "tfind" "Found trace frame 2, tracepoint .*" "tfind frame 2"
203 gdb_test "tfind" "Found trace frame 3, tracepoint .*" "tfind frame 3"
204 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
206 set pf_prefix $old_pf_prefix
209 proc strace_trace_on_diff_addr { } {
216 set old_pf_prefix $pf_prefix
217 lappend pf_prefix "trace_diff_addr"
219 # Restart with a fresh gdb.
220 clean_restart $executable
222 fail "Can't run to main"
223 set pf_prefix $old_pf_prefix
227 set marker_bar_addr ""
228 set marker_bar2_addr ""
230 # List the markers in program. They should be disabled.
231 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" {
232 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" {
235 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \
236 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr
238 pass "info static-tracepoint-markers 1"
240 -re ".*${gdb_prompt} $" {
241 fail "info static-tracepoint-markers 1"
245 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
247 gdb_test "info static-tracepoint-markers" \
248 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+n\[\t \]+$hex.*" \
249 "info static-tracepoint-markers 2"
252 # Set common tracepoint.
253 gdb_test "trace *${marker_bar2_addr}" "Tracepoint \[0-9\]+ at ${hex}: file.*"
255 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
257 gdb_test_no_output "tstart"
258 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
259 gdb_test_no_output "tstop"
261 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
262 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
263 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
265 set pf_prefix $old_pf_prefix
271 strace_trace_on_same_addr "trace"
272 strace_trace_on_same_addr "ftrace"
273 strace_trace_on_same_addr "break"
274 strace_trace_on_diff_addr