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 [get_in_proc_agent]
30 if [get_compiler_info] {
34 set additional_flags [list quiet debug shlib=$libipa shlib_load \
35 "additional_flags=-lust -lurcu-bp" ]
37 if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} {
38 untested "UST library or headers are not installed"
42 proc strace_info_marker { } { with_test_prefix "info_marker" {
46 # Restart with a fresh gdb.
47 clean_restart $executable
49 fail "Can't run to main"
53 # List the markers in program. They should be disabled.
54 gdb_test "info static-tracepoint-markers" \
55 ".*ust/bar\[\t \]+n\[\t \]+.*ust/bar2\[\t \]+n\[\t \]+.*"
57 # List all the thread. It is expected to get three threads without
59 gdb_test_multiple "info threads 3 2 1" "info threads" {
60 -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt} $" {
66 proc strace_probe_marker { } { with_test_prefix "probe_marker" {
72 # Restart with a fresh gdb.
73 clean_restart $executable
75 fail "Can't run to main"
79 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
80 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
81 # Two trace markers should be enabled.
82 gdb_test "info static-tracepoint-markers" \
83 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*"
85 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
87 gdb_test_no_output "tstart"
88 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
89 gdb_test_no_output "tstop"
91 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
92 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
93 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
96 proc strace_trace_on_same_addr { type } {
97 with_test_prefix "trace_same_addr $type" {
103 # Restart with a fresh gdb.
104 clean_restart $executable
106 fail "Can't run to main"
110 set marker_bar_addr ""
111 set marker_bar2_addr ""
113 # List the markers in program. They should be disabled.
114 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" {
115 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" {
118 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \
119 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr
121 pass "info static-tracepoint-markers 1"
123 -re ".*${gdb_prompt} $" {
124 fail "info static-tracepoint-markers 1"
128 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
129 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
130 # Two trace markers should be enabled.
131 gdb_test "info static-tracepoint-markers" \
132 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" \
133 "info static-tracepoint-markers 2"
135 # Set breapoints or tracepoints.
136 set test "${type} on marker bar"
137 gdb_test_multiple "${type} *${marker_bar_addr}" $test {
138 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*\r\n$gdb_prompt $" {
141 -re ".*\r\n$gdb_prompt $" {
142 if [string equal $type "ftrace"] {
143 # The instruction may be not long enough to set a fast
144 # tracepoint. Skip the rest of this test.
151 set test "${type} on marker bar2"
152 gdb_test_multiple "${type} *${marker_bar2_addr}" $test {
153 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*" {
156 -re ".*\r\n$gdb_prompt $" {
157 if [string equal $type "ftrace"] {
158 # The instruction may be not long enough to set a fast
159 # tracepoint. Skip the rest of this test.
167 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
169 if [string equal $type "break"] {
170 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \
172 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \
174 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \
178 gdb_test_no_output "tstart"
179 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \
181 gdb_test_no_output "tstop"
183 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
184 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
185 gdb_test "tfind" "Found trace frame 2, tracepoint .*" "tfind frame 2"
186 gdb_test "tfind" "Found trace frame 3, tracepoint .*" "tfind frame 3"
187 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
191 proc strace_trace_on_diff_addr { } { with_test_prefix "trace_diff_addr" {
198 # Restart with a fresh gdb.
199 clean_restart $executable
201 fail "Can't run to main"
205 set marker_bar_addr ""
206 set marker_bar2_addr ""
208 # List the markers in program. They should be disabled.
209 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-markers 1" {
210 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" {
213 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($hex) " \
214 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr
216 pass "info static-tracepoint-markers 1"
218 -re ".*${gdb_prompt} $" {
219 fail "info static-tracepoint-markers 1"
223 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
225 gdb_test "info static-tracepoint-markers" \
226 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+n\[\t \]+$hex.*" \
227 "info static-tracepoint-markers 2"
230 # Set common tracepoint.
231 gdb_test "trace *${marker_bar2_addr}" \
232 "Tracepoint \[0-9\]+ at ${hex}: file.*"
234 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
236 gdb_test_no_output "tstart"
237 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
238 gdb_test_no_output "tstop"
240 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
241 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
242 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
245 clean_restart $executable
248 fail "Can't run to main to check for trace support"
252 # Run it on native x86/x86_64 linux.
253 if { ![is_remote target]
254 && ([istarget "x86_64-*-linux*"] || [istarget "i\[34567\]86-*-linux*"]) } {
259 if { ![gdb_target_supports_trace] } then {
260 unsupported "Current target does not support trace"
264 gdb_load_shlibs $libipa
269 strace_trace_on_same_addr "trace"
270 strace_trace_on_same_addr "ftrace"
271 strace_trace_on_same_addr "break"
272 strace_trace_on_diff_addr