OLD | NEW |
(Empty) | |
| 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 standard_testfile |
| 22 set executable $testfile |
| 23 |
| 24 set libipa [get_in_proc_agent] |
| 25 |
| 26 set lib_opts debug |
| 27 |
| 28 if [get_compiler_info] { |
| 29 return -1 |
| 30 } |
| 31 |
| 32 set additional_flags [list quiet debug shlib=$libipa shlib_load \ |
| 33 "additional_flags=-lust -lurcu-bp" ] |
| 34 |
| 35 if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags
] != ""} { |
| 36 untested "UST library or headers are not installed" |
| 37 return -1 |
| 38 } |
| 39 |
| 40 proc strace_info_marker { } { with_test_prefix "info_marker" { |
| 41 global executable |
| 42 global gdb_prompt |
| 43 |
| 44 # Restart with a fresh gdb. |
| 45 clean_restart $executable |
| 46 if ![runto_main] { |
| 47 fail "Can't run to main" |
| 48 return -1 |
| 49 } |
| 50 |
| 51 # List the markers in program. They should be disabled. |
| 52 gdb_test "info static-tracepoint-markers" \ |
| 53 ".*ust/bar\[\t \]+n\[\t \]+.*ust/bar2\[\t \]+n\[\t \]+.*" |
| 54 |
| 55 # List all the thread. It is expected to get three threads without |
| 56 # any errors. |
| 57 gdb_test_multiple "info threads 3 2 1" "info threads" { |
| 58 -re "3\[ \t\]+Thread .*2\[ \t\]+Thread .*1\[ \t\]+Thread .*${gdb_prompt}
$" { |
| 59 pass "info threads" |
| 60 } |
| 61 } |
| 62 }} |
| 63 |
| 64 proc strace_probe_marker { } { with_test_prefix "probe_marker" { |
| 65 global executable |
| 66 global expect_out |
| 67 global gdb_prompt |
| 68 global hex |
| 69 |
| 70 # Restart with a fresh gdb. |
| 71 clean_restart $executable |
| 72 if ![runto_main] { |
| 73 fail "Can't run to main" |
| 74 return -1 |
| 75 } |
| 76 |
| 77 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*" |
| 78 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*" |
| 79 # Two trace markers should be enabled. |
| 80 gdb_test "info static-tracepoint-markers" \ |
| 81 "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\\..*" |
| 92 }} |
| 93 |
| 94 proc strace_trace_on_same_addr { type } { |
| 95 with_test_prefix "trace_same_addr $type" { |
| 96 global executable |
| 97 global expect_out |
| 98 global gdb_prompt |
| 99 global hex |
| 100 |
| 101 # Restart with a fresh gdb. |
| 102 clean_restart $executable |
| 103 if ![runto_main] { |
| 104 fail "Can't run to main" |
| 105 return -1 |
| 106 } |
| 107 |
| 108 set marker_bar_addr "" |
| 109 set marker_bar2_addr "" |
| 110 |
| 111 # List the markers in program. They should be disabled. |
| 112 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-m
arkers 1" { |
| 113 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" { |
| 114 set ignore "" |
| 115 |
| 116 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($
hex) " \ |
| 117 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr |
| 118 |
| 119 pass "info static-tracepoint-markers 1" |
| 120 } |
| 121 -re ".*${gdb_prompt} $" { |
| 122 fail "info static-tracepoint-markers 1" |
| 123 } |
| 124 } |
| 125 |
| 126 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*" |
| 127 gdb_test "strace -m ust/bar2" "Static tracepoint \[0-9\]+ at ${hex}: file.*" |
| 128 # Two trace markers should be enabled. |
| 129 gdb_test "info static-tracepoint-markers" \ |
| 130 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+y\[\t \]+$hex.*" \ |
| 131 "info static-tracepoint-markers 2" |
| 132 |
| 133 # Set breapoints or tracepoints. |
| 134 set test "${type} on marker bar" |
| 135 gdb_test_multiple "${type} *${marker_bar_addr}" $test { |
| 136 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*\r\n$gdb_
prompt $" { |
| 137 pass $test |
| 138 } |
| 139 -re ".*\r\n$gdb_prompt $" { |
| 140 if [string equal $type "ftrace"] { |
| 141 # The instruction may be not long enough to set a fast |
| 142 # tracepoint. Skip the rest of this test. |
| 143 return -1; |
| 144 } else { |
| 145 fail $test |
| 146 } |
| 147 } |
| 148 } |
| 149 set test "${type} on marker bar2" |
| 150 gdb_test_multiple "${type} *${marker_bar2_addr}" $test { |
| 151 -re "\(Fast trace|Trace|Break\)point \[0-9\]+ at ${hex}: file.*" { |
| 152 pass $test |
| 153 } |
| 154 -re ".*\r\n$gdb_prompt $" { |
| 155 if [string equal $type "ftrace"] { |
| 156 # The instruction may be not long enough to set a fast |
| 157 # tracepoint. Skip the rest of this test. |
| 158 return -1; |
| 159 } else { |
| 160 fail $test |
| 161 } |
| 162 } |
| 163 } |
| 164 |
| 165 gdb_test "break end" "Breakpoint \[0-9\]+ at.*" |
| 166 |
| 167 if [string equal $type "break"] { |
| 168 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ |
| 169 "continue to bar" |
| 170 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ |
| 171 "continue to bar2" |
| 172 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ |
| 173 "continue to end" |
| 174 } else { |
| 175 |
| 176 gdb_test_no_output "tstart" |
| 177 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" \ |
| 178 "continue to end" |
| 179 gdb_test_no_output "tstop" |
| 180 |
| 181 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" |
| 182 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1" |
| 183 gdb_test "tfind" "Found trace frame 2, tracepoint .*" "tfind frame 2" |
| 184 gdb_test "tfind" "Found trace frame 3, tracepoint .*" "tfind frame 3" |
| 185 gdb_test "tfind" "Target failed to find requested trace frame\\..*" |
| 186 } |
| 187 }} |
| 188 |
| 189 proc strace_trace_on_diff_addr { } { with_test_prefix "trace_diff_addr" { |
| 190 |
| 191 global executable |
| 192 global expect_out |
| 193 global gdb_prompt |
| 194 global hex |
| 195 |
| 196 # Restart with a fresh gdb. |
| 197 clean_restart $executable |
| 198 if ![runto_main] { |
| 199 fail "Can't run to main" |
| 200 return -1 |
| 201 } |
| 202 |
| 203 set marker_bar_addr "" |
| 204 set marker_bar2_addr "" |
| 205 |
| 206 # List the markers in program. They should be disabled. |
| 207 gdb_test_multiple "info static-tracepoint-markers" "info static-tracepoint-m
arkers 1" { |
| 208 -re ".*ust/bar\[\t \]+n.*${gdb_prompt} $" { |
| 209 set ignore "" |
| 210 |
| 211 regexp "ust/bar\[\t \]+n\[\t \]+($hex) .*ust/bar2\[\t \]+n\[\t \]+($
hex) " \ |
| 212 "$expect_out(0,string)" ignore marker_bar_addr marker_bar2_addr |
| 213 |
| 214 pass "info static-tracepoint-markers 1" |
| 215 } |
| 216 -re ".*${gdb_prompt} $" { |
| 217 fail "info static-tracepoint-markers 1" |
| 218 } |
| 219 } |
| 220 |
| 221 gdb_test "strace -m ust/bar" "Static tracepoint \[0-9\]+ at ${hex}: file.*" |
| 222 |
| 223 gdb_test "info static-tracepoint-markers" \ |
| 224 "ust/bar\[\t \]+y\[\t \]+$hex .*ust/bar2\[\t \]+n\[\t \]+$hex.*" \ |
| 225 "info static-tracepoint-markers 2" |
| 226 |
| 227 |
| 228 # Set common tracepoint. |
| 229 gdb_test "trace *${marker_bar2_addr}" \ |
| 230 "Tracepoint \[0-9\]+ at ${hex}: file.*" |
| 231 |
| 232 gdb_test "break end" "Breakpoint \[0-9\]+ at.*" |
| 233 |
| 234 gdb_test_no_output "tstart" |
| 235 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" |
| 236 gdb_test_no_output "tstop" |
| 237 |
| 238 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" |
| 239 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1" |
| 240 gdb_test "tfind" "Target failed to find requested trace frame\\..*" |
| 241 }} |
| 242 |
| 243 clean_restart $executable |
| 244 |
| 245 if ![runto_main] { |
| 246 fail "Can't run to main to check for trace support" |
| 247 return -1 |
| 248 } |
| 249 |
| 250 # Run it on native x86/x86_64 linux. |
| 251 if { ![is_remote target] |
| 252 && ([istarget "x86_64-*-linux*"] || [istarget "i\[34567\]86-*-linux*"]) } { |
| 253 strace_info_marker |
| 254 return |
| 255 } |
| 256 |
| 257 if { ![gdb_target_supports_trace] } then { |
| 258 unsupported "Current target does not support trace" |
| 259 return -1; |
| 260 } |
| 261 |
| 262 gdb_load_shlibs $libipa |
| 263 |
| 264 strace_info_marker |
| 265 strace_probe_marker |
| 266 |
| 267 strace_trace_on_same_addr "trace" |
| 268 strace_trace_on_same_addr "ftrace" |
| 269 strace_trace_on_same_addr "break" |
| 270 strace_trace_on_diff_addr |
OLD | NEW |