* lib/gdb.exp (skip_altivec_tests, skip_vsx_tests)
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / strace.exp
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.
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
15 load_lib "trace-support.exp";
16
17 if {[skip_shlib_tests]} {
18 return 0
19 }
20
21 set testfile "strace"
22 set srcfile $testfile.c
23 set binfile $objdir/$subdir/$testfile
24 set executable $testfile
25
26 set libipa [get_in_proc_agent]
27
28 set lib_opts debug
29
30 if [get_compiler_info] {
31 return -1
32 }
33
34 set additional_flags [list quiet debug shlib=$libipa shlib_load \
35 "additional_flags=-lust -lurcu-bp" ]
36
37 if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} {
38 untested "UST library or headers are not installed"
39 return -1
40 }
41
42 proc strace_info_marker { } { with_test_prefix "info_marker" {
43 global executable
44 global gdb_prompt
45
46 # Restart with a fresh gdb.
47 clean_restart $executable
48 if ![runto_main] {
49 fail "Can't run to main"
50 return -1
51 }
52
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 \]+.*"
56
57 # List all the thread. It is expected to get three threads without
58 # any errors.
59 gdb_test_multiple "info threads 3 2 1" "info threads" {
60 -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt} $" {
61 pass "info threads"
62 }
63 }
64 }}
65
66 proc strace_probe_marker { } { with_test_prefix "probe_marker" {
67 global executable
68 global expect_out
69 global gdb_prompt
70 global hex
71
72 # Restart with a fresh gdb.
73 clean_restart $executable
74 if ![runto_main] {
75 fail "Can't run to main"
76 return -1
77 }
78
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.*"
84
85 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
86
87 gdb_test_no_output "tstart"
88 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
89 gdb_test_no_output "tstop"
90
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\\..*"
94 }}
95
96 proc strace_trace_on_same_addr { type } {
97 with_test_prefix "trace_same_addr $type" {
98 global executable
99 global expect_out
100 global gdb_prompt
101 global hex
102
103 # Restart with a fresh gdb.
104 clean_restart $executable
105 if ![runto_main] {
106 fail "Can't run to main"
107 return -1
108 }
109
110 set marker_bar_addr ""
111 set marker_bar2_addr ""
112
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} $" {
116 set ignore ""
117
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
120
121 pass "info static-tracepoint-markers 1"
122 }
123 -re ".*${gdb_prompt} $" {
124 fail "info static-tracepoint-markers 1"
125 }
126 }
127
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"
134
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 $" {
139 pass $test
140 }
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.
145 return -1;
146 } else {
147 fail $test
148 }
149 }
150 }
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.*" {
154 pass $test
155 }
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.
160 return -1;
161 } else {
162 fail $test
163 }
164 }
165 }
166
167 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
168
169 if [string equal $type "break"] {
170 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \
171 "continue to bar"
172 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \
173 "continue to bar2"
174 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \
175 "continue to end"
176 } else {
177
178 gdb_test_no_output "tstart"
179 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \
180 "continue to end"
181 gdb_test_no_output "tstop"
182
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\\..*"
188 }
189 }}
190
191 proc strace_trace_on_diff_addr { } { with_test_prefix "trace_diff_addr" {
192
193 global executable
194 global expect_out
195 global gdb_prompt
196 global hex
197
198 # Restart with a fresh gdb.
199 clean_restart $executable
200 if ![runto_main] {
201 fail "Can't run to main"
202 return -1
203 }
204
205 set marker_bar_addr ""
206 set marker_bar2_addr ""
207
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} $" {
211 set ignore ""
212
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
215
216 pass "info static-tracepoint-markers 1"
217 }
218 -re ".*${gdb_prompt} $" {
219 fail "info static-tracepoint-markers 1"
220 }
221 }
222
223 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*"
224
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"
228
229
230 # Set common tracepoint.
231 gdb_test "trace *${marker_bar2_addr}" \
232 "Tracepoint \[0-9\]+ at ${hex}: file.*"
233
234 gdb_test "break end" "Breakpoint \[0-9\]+ at.*"
235
236 gdb_test_no_output "tstart"
237 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end"
238 gdb_test_no_output "tstop"
239
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\\..*"
243 }}
244
245 clean_restart $executable
246
247 if ![runto_main] {
248 fail "Can't run to main to check for trace support"
249 return -1
250 }
251
252 # Run it on native x86/x86_64 linux.
253 if { ![is_remote target]
254 && ([istarget "x86_64-*-linux*"] || [istarget "i\[34567\]86-*-linux*"]) } {
255 strace_info_marker
256 return
257 }
258
259 if { ![gdb_target_supports_trace] } then {
260 unsupported "Current target does not support trace"
261 return -1;
262 }
263
264 gdb_load_shlibs $libipa
265
266 strace_info_marker
267 strace_probe_marker
268
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
This page took 0.042242 seconds and 5 git commands to generate.