Copyright year update in most files of the GDB Project.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / strace.exp
CommitLineData
c5a57081 1# Copyright 2011-2012 Free Software Foundation, Inc.
1576bd00
YQ
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.
6#
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.
11#
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/>.
14
15load_lib "trace-support.exp";
16
17if $tracelevel then {
18 strace $tracelevel
19}
20
21if {[skip_shlib_tests]} {
22 return 0
23}
24
25set testfile "strace"
26set srcfile $testfile.c
27set binfile $objdir/$subdir/$testfile
28set executable $testfile
29
30set libipa $objdir/../gdbserver/libinproctrace.so
31
32set lib_opts debug
33
34if [get_compiler_info ${binfile}] {
35 return -1
36}
37
38set additional_flags [list debug shlib=$libipa shlib_load "additional_flags=-lust -lurcu-bp" ]
39
40if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} {
41 untested "UST library or headers are not installed"
42 return -1
43}
44
45clean_restart $executable
46
47if ![runto_main] {
48 fail "Can't run to main to check for trace support"
49 return -1
50}
51
52if { ![gdb_target_supports_trace] } then {
53 unsupported "Current target does not support trace"
54 return -1;
55}
56
57gdb_load_shlibs $libipa
58
59proc strace_info_marker { } {
60 global executable
61 global pf_prefix
62
63 set old_pf_prefix $pf_prefix
64 lappend pf_prefix "info_marker"
65
66 # Restart with a fresh gdb.
67 clean_restart $executable
68 if ![runto_main] {
69 fail "Can't run to main"
70 set pf_prefix $old_pf_prefix
71 return -1
72 }
73
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 \]+.*"
77
78 set pf_prefix $old_pf_prefix
79}
80
81proc strace_probe_marker { } {
82 global executable
83 global pf_prefix
84 global expect_out
85 global gdb_prompt
86 global hex
87
88 set old_pf_prefix $pf_prefix
89 lappend pf_prefix "probe_marker"
90
91 # Restart with a fresh gdb.
92 clean_restart $executable
93 if ![runto_main] {
94 fail "Can't run to main"
95 set pf_prefix $old_pf_prefix
96 return -1
97 }
98
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.*"
103
104 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
105
106 gdb_test_no_output "tstart"
107 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
108 gdb_test_no_output "tstop"
109
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\\..*"
113
114 set pf_prefix $old_pf_prefix
115}
116
3c2d6aff
YQ
117proc strace_trace_on_same_addr { type } {
118 global executable
119 global pf_prefix
120 global expect_out
121 global gdb_prompt
122 global hex
123
124 set old_pf_prefix $pf_prefix
125 lappend pf_prefix "trace_same_addr" "$type"
126
127 # Restart with a fresh gdb.
128 clean_restart $executable
129 if ![runto_main] {
130 fail "Can't run to main"
131 set pf_prefix $old_pf_prefix
132 return -1
133 }
134
135 set marker_bar_addr ""
136 set marker_bar2_addr ""
137
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} $" {
141 set ignore ""
142
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
145
146 pass "info static-tracepoint-markers 1"
147 }
148 -re ".*${gdb_prompt} $" {
149 fail "info static-tracepoint-markers 1"
150 }
151 }
152
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"
159
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 $" {
164 pass $test
165 }
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.
170 return -1;
171 } else {
172 fail $test
173 }
174 }
175 }
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.*" {
179 pass $test
180 }
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.
185 return -1;
186 } else {
187 fail $test
188 }
189 }
190 }
191
192 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
193
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"
198 } else {
199
200 gdb_test_no_output "tstart"
201 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
202 gdb_test_no_output "tstop"
203
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\\..*"
209 }
210 set pf_prefix $old_pf_prefix
211}
212
213proc strace_trace_on_diff_addr { } {
214 global executable
215 global pf_prefix
216 global expect_out
217 global gdb_prompt
218 global hex
219
220 set old_pf_prefix $pf_prefix
221 lappend pf_prefix "trace_diff_addr"
222
223 # Restart with a fresh gdb.
224 clean_restart $executable
225 if ![runto_main] {
226 fail "Can't run to main"
227 set pf_prefix $old_pf_prefix
228 return -1
229 }
230
231 set marker_bar_addr ""
232 set marker_bar2_addr ""
233
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} $" {
237 set ignore ""
238
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
241
242 pass "info static-tracepoint-markers 1"
243 }
244 -re ".*${gdb_prompt} $" {
245 fail "info static-tracepoint-markers 1"
246 }
247 }
248
249 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
250
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"
254
255
256 # Set common tracepoint.
257 gdb_test "trace *${marker_bar2_addr}" "Tracepoint \[0-9\]+ at ${hex}: file.*"
258
259 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
260
261 gdb_test_no_output "tstart"
262 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
263 gdb_test_no_output "tstop"
264
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\\..*"
268
269 set pf_prefix $old_pf_prefix
270}
271
1576bd00
YQ
272strace_info_marker
273strace_probe_marker
3c2d6aff
YQ
274
275strace_trace_on_same_addr "trace"
276strace_trace_on_same_addr "ftrace"
277strace_trace_on_same_addr "break"
278strace_trace_on_diff_addr
This page took 0.039199 seconds and 4 git commands to generate.