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 { } { with_test_prefix "info_marker" {
59 # Restart with a fresh gdb.
60 clean_restart $executable
62 fail "Can't run to main"
66 # List the markers in program. They should be disabled.
67 gdb_test "info static-tracepoint-markers" \
68 ".*ust/bar\[\t \]+n\[\t \]+.*ust/bar2\[\t \]+n\[\t \]+.*"
70 # List all the thread. It is expected to get three threads without
72 gdb_test_multiple "info threads 3 2 1" "info threads" {
73 -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt} $" {
79 proc strace_probe_marker { } { with_test_prefix "probe_marker" {
85 # Restart with a fresh gdb.
86 clean_restart $executable
88 fail "Can't run to main"
92 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
93 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
94 # Two trace markers should be enabled.
95 gdb_test "info static-tracepoint-markers" "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*"
97 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
99 gdb_test_no_output "tstart"
100 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
101 gdb_test_no_output "tstop"
103 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
104 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
105 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
108 proc strace_trace_on_same_addr { type } { with_test_prefix "trace_same_addr $type" {
114 # Restart with a fresh gdb.
115 clean_restart $executable
117 fail "Can't run to main"
121 set marker_bar_addr ""
122 set marker_bar2_addr ""
124 # List the markers in program. They should be disabled.
125 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" {
126 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" {
129 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \
130 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr
132 pass "info static-tracepoint-markers 1"
134 -re ".*${gdb_prompt} $" {
135 fail "info static-tracepoint-markers 1"
139 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
140 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
141 # Two trace markers should be enabled.
142 gdb_test "info static-tracepoint-markers" \
143 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" \
144 "info static-tracepoint-markers 2"
146 # Set breapoints or tracepoints.
147 set test "${type} on marker bar"
148 gdb_test_multiple "${type} *${marker_bar_addr}" $test {
149 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*\r\n$gdb_prompt $" {
152 -re ".*\r\n$gdb_prompt $" {
153 if [string equal $type "ftrace"] {
154 # The instruction may be not long enough to set a fast tracepoint.
155 # Skip the rest of this test.
162 set test "${type} on marker bar2"
163 gdb_test_multiple "${type} *${marker_bar2_addr}" $test {
164 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*" {
167 -re ".*\r\n$gdb_prompt $" {
168 if [string equal $type "ftrace"] {
169 # The instruction may be not long enough to set a fast tracepoint.
170 # Skip the rest of this test.
178 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
180 if [string equal $type "break"] {
181 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to bar"
182 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to bar2"
183 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
186 gdb_test_no_output "tstart"
187 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
188 gdb_test_no_output "tstop"
190 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
191 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
192 gdb_test "tfind" "Found trace frame 2, tracepoint .*" "tfind frame 2"
193 gdb_test "tfind" "Found trace frame 3, tracepoint .*" "tfind frame 3"
194 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
198 proc strace_trace_on_diff_addr { } { with_test_prefix "trace_diff_addr" {
205 # Restart with a fresh gdb.
206 clean_restart $executable
208 fail "Can't run to main"
212 set marker_bar_addr ""
213 set marker_bar2_addr ""
215 # List the markers in program. They should be disabled.
216 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" {
217 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" {
220 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \
221 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr
223 pass "info static-tracepoint-markers 1"
225 -re ".*${gdb_prompt} $" {
226 fail "info static-tracepoint-markers 1"
230 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
232 gdb_test "info static-tracepoint-markers" \
233 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+n\[\t \]+$hex.*" \
234 "info static-tracepoint-markers 2"
237 # Set common tracepoint.
238 gdb_test "trace *${marker_bar2_addr}" "Tracepoint \[0-9\]+ at ${hex}: file.*"
240 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
242 gdb_test_no_output "tstart"
243 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
244 gdb_test_no_output "tstop"
246 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
247 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
248 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
254 strace_trace_on_same_addr "trace"
255 strace_trace_on_same_addr "ftrace"
256 strace_trace_on_same_addr "break"
257 strace_trace_on_diff_addr