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 proc strace_info_marker { } { with_test_prefix "info_marker" {
45 # Restart with a fresh gdb.
46 clean_restart $executable
48 fail "Can't run to main"
52 # List the markers in program. They should be disabled.
53 gdb_test "info static-tracepoint-markers" \
54 ".*ust/bar\[\t \]+n\[\t \]+.*ust/bar2\[\t \]+n\[\t \]+.*"
56 # List all the thread. It is expected to get three threads without
58 gdb_test_multiple "info threads 3 2 1" "info threads" {
59 -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt} $" {
65 proc strace_probe_marker { } { with_test_prefix "probe_marker" {
71 # Restart with a fresh gdb.
72 clean_restart $executable
74 fail "Can't run to main"
78 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
79 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
80 # Two trace markers should be enabled.
81 gdb_test "info static-tracepoint-markers" "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*"
83 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
85 gdb_test_no_output "tstart"
86 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
87 gdb_test_no_output "tstop"
89 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
90 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
91 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
94 proc strace_trace_on_same_addr { type } { with_test_prefix "trace_same_addr $type" {
100 # Restart with a fresh gdb.
101 clean_restart $executable
103 fail "Can't run to main"
107 set marker_bar_addr ""
108 set marker_bar2_addr ""
110 # List the markers in program. They should be disabled.
111 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" {
112 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" {
115 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \
116 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr
118 pass "info static-tracepoint-markers 1"
120 -re ".*${gdb_prompt} $" {
121 fail "info static-tracepoint-markers 1"
125 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
126 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
127 # Two trace markers should be enabled.
128 gdb_test "info static-tracepoint-markers" \
129 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" \
130 "info static-tracepoint-markers 2"
132 # Set breapoints or tracepoints.
133 set test "${type} on marker bar"
134 gdb_test_multiple "${type} *${marker_bar_addr}" $test {
135 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*\r\n$gdb_prompt $" {
138 -re ".*\r\n$gdb_prompt $" {
139 if [string equal $type "ftrace"] {
140 # The instruction may be not long enough to set a fast tracepoint.
141 # Skip the rest of this test.
148 set test "${type} on marker bar2"
149 gdb_test_multiple "${type} *${marker_bar2_addr}" $test {
150 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*" {
153 -re ".*\r\n$gdb_prompt $" {
154 if [string equal $type "ftrace"] {
155 # The instruction may be not long enough to set a fast tracepoint.
156 # Skip the rest of this test.
164 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
166 if [string equal $type "break"] {
167 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to bar"
168 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to bar2"
169 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
172 gdb_test_no_output "tstart"
173 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
174 gdb_test_no_output "tstop"
176 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
177 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
178 gdb_test "tfind" "Found trace frame 2, tracepoint .*" "tfind frame 2"
179 gdb_test "tfind" "Found trace frame 3, tracepoint .*" "tfind frame 3"
180 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
184 proc strace_trace_on_diff_addr { } { with_test_prefix "trace_diff_addr" {
191 # Restart with a fresh gdb.
192 clean_restart $executable
194 fail "Can't run to main"
198 set marker_bar_addr ""
199 set marker_bar2_addr ""
201 # List the markers in program. They should be disabled.
202 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" {
203 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" {
206 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \
207 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr
209 pass "info static-tracepoint-markers 1"
211 -re ".*${gdb_prompt} $" {
212 fail "info static-tracepoint-markers 1"
216 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
218 gdb_test "info static-tracepoint-markers" \
219 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+n\[\t \]+$hex.*" \
220 "info static-tracepoint-markers 2"
223 # Set common tracepoint.
224 gdb_test "trace *${marker_bar2_addr}" "Tracepoint \[0-9\]+ at ${hex}: file.*"
226 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
228 gdb_test_no_output "tstart"
229 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
230 gdb_test_no_output "tstop"
232 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
233 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
234 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
237 clean_restart $executable
240 fail "Can't run to main to check for trace support"
244 # Run it on native x86/x86_64 linux.
245 if { ![is_remote target]
246 && ([istarget "x86_64-*-linux*"] || [istarget "i\[34567\]86-*-linux*"]) } {
251 if { ![gdb_target_supports_trace] } then {
252 unsupported "Current target does not support trace"
256 gdb_load_shlibs $libipa
261 strace_trace_on_same_addr "trace"
262 strace_trace_on_same_addr "ftrace"
263 strace_trace_on_same_addr "break"
264 strace_trace_on_diff_addr