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";
21 if {[skip_shlib_tests]} {
26 set srcfile $testfile.c
27 set binfile $objdir/$subdir/$testfile
28 set executable $testfile
30 set libipa $objdir/../gdbserver/libinproctrace.so
34 if [get_compiler_info ${binfile}] {
38 set additional_flags [list debug shlib=$libipa shlib_load "additional_flags=-lust -lurcu-bp" ]
40 if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} {
41 untested "UST library or headers are not installed"
45 clean_restart $executable
48 fail "Can't run to main to check for trace support"
52 if { ![gdb_target_supports_trace] } then {
53 unsupported "Current target does not support trace"
57 gdb_load_shlibs $libipa
59 proc strace_info_marker { } {
63 set old_pf_prefix $pf_prefix
64 lappend pf_prefix "info_marker"
66 # Restart with a fresh gdb.
67 clean_restart $executable
69 fail "Can't run to main"
70 set pf_prefix $old_pf_prefix
74 # List the markers in program. They should be disabled.
75 gdb_test "info static-tracepoint-markers" \
76 ".*ust/bar\[\t \]+n\[\t \]+.*ust/bar2\[\t \]+n\[\t \]+.*"
78 set pf_prefix $old_pf_prefix
81 proc strace_probe_marker { } {
88 set old_pf_prefix $pf_prefix
89 lappend pf_prefix "probe_marker"
91 # Restart with a fresh gdb.
92 clean_restart $executable
94 fail "Can't run to main"
95 set pf_prefix $old_pf_prefix
99 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
100 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
101 # Two trace markers should be enabled.
102 gdb_test "info static-tracepoint-markers" "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*"
104 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
106 gdb_test_no_output "tstart"
107 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
108 gdb_test_no_output "tstop"
110 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
111 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
112 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
114 set pf_prefix $old_pf_prefix
117 proc strace_trace_on_same_addr { type } {
124 set old_pf_prefix $pf_prefix
125 lappend pf_prefix "trace_same_addr" "$type"
127 # Restart with a fresh gdb.
128 clean_restart $executable
130 fail "Can't run to main"
131 set pf_prefix $old_pf_prefix
135 set marker_bar_addr ""
136 set marker_bar2_addr ""
138 # List the markers in program. They should be disabled.
139 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" {
140 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" {
143 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \
144 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr
146 pass "info static-tracepoint-markers 1"
148 -re ".*${gdb_prompt} $" {
149 fail "info static-tracepoint-markers 1"
153 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
154 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
155 # Two trace markers should be enabled.
156 gdb_test "info static-tracepoint-markers" \
157 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" \
158 "info static-tracepoint-markers 2"
160 # Set breapoints or tracepoints.
161 set test "${type} on marker bar"
162 gdb_test_multiple "${type} *${marker_bar_addr}" $test {
163 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*\r\n$gdb_prompt $" {
166 -re ".*\r\n$gdb_prompt $" {
167 if [string equal $type "ftrace"] {
168 # The instruction may be not long enough to set a fast tracepoint.
169 # Skip the rest of this test.
176 set test "${type} on marker bar2"
177 gdb_test_multiple "${type} *${marker_bar2_addr}" $test {
178 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*" {
181 -re ".*\r\n$gdb_prompt $" {
182 if [string equal $type "ftrace"] {
183 # The instruction may be not long enough to set a fast tracepoint.
184 # Skip the rest of this test.
192 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
194 if [string equal $type "break"] {
195 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to bar"
196 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to bar2"
197 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
200 gdb_test_no_output "tstart"
201 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
202 gdb_test_no_output "tstop"
204 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
205 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
206 gdb_test "tfind" "Found trace frame 2, tracepoint .*" "tfind frame 2"
207 gdb_test "tfind" "Found trace frame 3, tracepoint .*" "tfind frame 3"
208 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
210 set pf_prefix $old_pf_prefix
213 proc strace_trace_on_diff_addr { } {
220 set old_pf_prefix $pf_prefix
221 lappend pf_prefix "trace_diff_addr"
223 # Restart with a fresh gdb.
224 clean_restart $executable
226 fail "Can't run to main"
227 set pf_prefix $old_pf_prefix
231 set marker_bar_addr ""
232 set marker_bar2_addr ""
234 # List the markers in program. They should be disabled.
235 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" {
236 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" {
239 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \
240 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr
242 pass "info static-tracepoint-markers 1"
244 -re ".*${gdb_prompt} $" {
245 fail "info static-tracepoint-markers 1"
249 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
251 gdb_test "info static-tracepoint-markers" \
252 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+n\[\t \]+$hex.*" \
253 "info static-tracepoint-markers 2"
256 # Set common tracepoint.
257 gdb_test "trace *${marker_bar2_addr}" "Tracepoint \[0-9\]+ at ${hex}: file.*"
259 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
261 gdb_test_no_output "tstart"
262 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
263 gdb_test_no_output "tstop"
265 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
266 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
267 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
269 set pf_prefix $old_pf_prefix
275 strace_trace_on_same_addr "trace"
276 strace_trace_on_same_addr "ftrace"
277 strace_trace_on_same_addr "break"
278 strace_trace_on_diff_addr