Commit | Line | Data |
---|---|---|
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 | ||
15 | load_lib "trace-support.exp"; | |
16 | ||
1576bd00 YQ |
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 $objdir/../gdbserver/libinproctrace.so | |
27 | ||
28 | set lib_opts debug | |
29 | ||
30 | if [get_compiler_info ${binfile}] { | |
31 | return -1 | |
32 | } | |
33 | ||
34 | set additional_flags [list debug shlib=$libipa shlib_load "additional_flags=-lust -lurcu-bp" ] | |
35 | ||
36 | if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} { | |
37 | untested "UST library or headers are not installed" | |
38 | return -1 | |
39 | } | |
40 | ||
0f4d39d5 | 41 | proc strace_info_marker { } { with_test_prefix "info_marker" { |
1576bd00 | 42 | global executable |
9e507076 | 43 | global gdb_prompt |
1576bd00 | 44 | |
1576bd00 YQ |
45 | # Restart with a fresh gdb. |
46 | clean_restart $executable | |
47 | if ![runto_main] { | |
48 | fail "Can't run to main" | |
1576bd00 YQ |
49 | return -1 |
50 | } | |
51 | ||
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 \]+.*" | |
55 | ||
9e507076 YQ |
56 | # List all the thread. It is expected to get three threads without |
57 | # any errors. | |
58 | gdb_test_multiple "info threads 3 2 1" "info threads" { | |
59 | -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt} $" { | |
60 | pass "info threads" | |
61 | } | |
62 | } | |
6a5870ce | 63 | }} |
1576bd00 | 64 | |
0f4d39d5 | 65 | proc strace_probe_marker { } { with_test_prefix "probe_marker" { |
1576bd00 | 66 | global executable |
1576bd00 YQ |
67 | global expect_out |
68 | global gdb_prompt | |
69 | global hex | |
70 | ||
1576bd00 YQ |
71 | # Restart with a fresh gdb. |
72 | clean_restart $executable | |
73 | if ![runto_main] { | |
74 | fail "Can't run to main" | |
1576bd00 YQ |
75 | return -1 |
76 | } | |
77 | ||
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.*" | |
82 | ||
83 | gdb_test "break end" "Breakpoint \[0-9\]+ at.*" | |
84 | ||
85 | gdb_test_no_output "tstart" | |
86 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" | |
87 | gdb_test_no_output "tstop" | |
88 | ||
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\\..*" | |
6a5870ce | 92 | }} |
1576bd00 | 93 | |
0f4d39d5 | 94 | proc strace_trace_on_same_addr { type } { with_test_prefix "trace_same_addr $type" { |
3c2d6aff | 95 | global executable |
3c2d6aff YQ |
96 | global expect_out |
97 | global gdb_prompt | |
98 | global hex | |
99 | ||
3c2d6aff YQ |
100 | # Restart with a fresh gdb. |
101 | clean_restart $executable | |
102 | if ![runto_main] { | |
103 | fail "Can't run to main" | |
3c2d6aff YQ |
104 | return -1 |
105 | } | |
106 | ||
107 | set marker_bar_addr "" | |
108 | set marker_bar2_addr "" | |
109 | ||
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} $" { | |
113 | set ignore "" | |
114 | ||
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 | |
117 | ||
118 | pass "info static-tracepoint-markers 1" | |
119 | } | |
120 | -re ".*${gdb_prompt} $" { | |
121 | fail "info static-tracepoint-markers 1" | |
122 | } | |
123 | } | |
124 | ||
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" | |
131 | ||
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 $" { | |
136 | pass $test | |
137 | } | |
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. | |
142 | return -1; | |
143 | } else { | |
144 | fail $test | |
145 | } | |
146 | } | |
147 | } | |
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.*" { | |
151 | pass $test | |
152 | } | |
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. | |
157 | return -1; | |
158 | } else { | |
159 | fail $test | |
160 | } | |
161 | } | |
162 | } | |
163 | ||
164 | gdb_test "break end" "Breakpoint \[0-9\]+ at.*" | |
165 | ||
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" | |
170 | } else { | |
171 | ||
172 | gdb_test_no_output "tstart" | |
173 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" | |
174 | gdb_test_no_output "tstop" | |
175 | ||
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\\..*" | |
181 | } | |
6a5870ce PA |
182 | }} |
183 | ||
0f4d39d5 | 184 | proc strace_trace_on_diff_addr { } { with_test_prefix "trace_diff_addr" { |
3c2d6aff | 185 | |
3c2d6aff | 186 | global executable |
3c2d6aff YQ |
187 | global expect_out |
188 | global gdb_prompt | |
189 | global hex | |
190 | ||
3c2d6aff YQ |
191 | # Restart with a fresh gdb. |
192 | clean_restart $executable | |
193 | if ![runto_main] { | |
194 | fail "Can't run to main" | |
3c2d6aff YQ |
195 | return -1 |
196 | } | |
197 | ||
198 | set marker_bar_addr "" | |
199 | set marker_bar2_addr "" | |
200 | ||
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} $" { | |
204 | set ignore "" | |
205 | ||
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 | |
208 | ||
209 | pass "info static-tracepoint-markers 1" | |
210 | } | |
211 | -re ".*${gdb_prompt} $" { | |
212 | fail "info static-tracepoint-markers 1" | |
213 | } | |
214 | } | |
215 | ||
216 | gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*" | |
217 | ||
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" | |
221 | ||
222 | ||
223 | # Set common tracepoint. | |
224 | gdb_test "trace *${marker_bar2_addr}" "Tracepoint \[0-9\]+ at ${hex}: file.*" | |
225 | ||
226 | gdb_test "break end" "Breakpoint \[0-9\]+ at.*" | |
227 | ||
228 | gdb_test_no_output "tstart" | |
229 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" | |
230 | gdb_test_no_output "tstop" | |
231 | ||
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\\..*" | |
6a5870ce | 235 | }} |
3c2d6aff | 236 | |
5808517f YQ |
237 | clean_restart $executable |
238 | ||
239 | if ![runto_main] { | |
240 | fail "Can't run to main to check for trace support" | |
241 | return -1 | |
242 | } | |
243 | ||
244 | # Run it on native x86/x86_64 linux. | |
245 | if { ![is_remote target] | |
246 | && ([istarget "x86_64-*-linux*"] || [istarget "i\[34567\]86-*-linux*"]) } { | |
247 | strace_info_marker | |
248 | return | |
249 | } | |
250 | ||
251 | if { ![gdb_target_supports_trace] } then { | |
252 | unsupported "Current target does not support trace" | |
253 | return -1; | |
254 | } | |
255 | ||
256 | gdb_load_shlibs $libipa | |
257 | ||
1576bd00 YQ |
258 | strace_info_marker |
259 | strace_probe_marker | |
3c2d6aff YQ |
260 | |
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 |