| 1 |
set test "callee" |
| 2 |
set testpath "$srcdir/$subdir" |
| 3 |
|
| 4 |
if {! [installtest_p]} { untested "$test"; return } |
| 5 |
if {! [uprobes_p]} { untested "$test"; return } |
| 6 |
if {! [callee_probes_p]} { untested "$test"; return } |
| 7 |
|
| 8 |
# The purpose of this testcase is to verify that .callee[s] probes |
| 9 |
# function properly in a variety of situations. |
| 10 |
|
| 11 |
# We move on to other subtests if a subtest fails, but within |
| 12 |
# subtests, we fail the whole subtest if a subsubtest fails. Hope that |
| 13 |
# makes sense. |
| 14 |
|
| 15 |
# Fails or succeeds a subsubtest and sets the failed flag. Zero res |
| 16 |
# means success, nonzero means failure. |
| 17 |
proc passfail { res } { |
| 18 |
global test subtest subsubtest failed |
| 19 |
if { $res } { |
| 20 |
fail "$test ($subtest - $subsubtest)" |
| 21 |
set failed 1 |
| 22 |
} else { |
| 23 |
pass "$test ($subtest - $subsubtest)" |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
# Compiles the related subtest C file. Returns 0 on success, 1 on |
| 28 |
# failure. The n variable is the number of source files to |
| 29 |
# compile. E.g. if n = 2, it will compile ${test}.${subtest}.c and |
| 30 |
# ${test}.${subtest}.2.c |
| 31 |
proc compile_subtest { arch_compile_idx {n 1} } { |
| 32 |
global test testpath subtest |
| 33 |
|
| 34 |
# Build source list |
| 35 |
set sources "" |
| 36 |
while {$n} { |
| 37 |
if {$n > 1} { |
| 38 |
lappend sources "${testpath}/${test}.${subtest}.$n.c" |
| 39 |
} else { |
| 40 |
lappend sources "${testpath}/${test}.${subtest}.c" |
| 41 |
} |
| 42 |
incr n -1 |
| 43 |
} |
| 44 |
|
| 45 |
set flags "compiler=gcc [arch_compile_flag $arch_compile_idx]" |
| 46 |
set flags "$flags additional_flags=-O additional_flags=-g" |
| 47 |
set res [target_compile [concat $sources] ${test} executable $flags] |
| 48 |
if { $res != "" } { return 1 } |
| 49 |
return 0 |
| 50 |
} |
| 51 |
|
| 52 |
# Builds a callee probe point for the given func and callee. If callee |
| 53 |
# is a number greater than 0, then callees(N) is used instead. If |
| 54 |
# callee is 0, then callees is used. Returns 0 on success, nonzero on |
| 55 |
# failure. The 'return_p' arg should be 1 if it is a .return probe, |
| 56 |
# otherwise (defaults to 0). The 'call_p' arg should be 1 if it is a |
| 57 |
# .call probe, otherwise (defaults to 0). |
| 58 |
proc build_probe { func callee {return_p 0} {call_p 0} } { |
| 59 |
global test |
| 60 |
|
| 61 |
set func "function(\"${func}\")" |
| 62 |
if {[string is integer $callee]} { |
| 63 |
if {$callee} { |
| 64 |
set callee "callees(${callee})" |
| 65 |
} else { |
| 66 |
set callee "callees" |
| 67 |
} |
| 68 |
} else { |
| 69 |
set callee "callee(\"${callee}\")" |
| 70 |
} |
| 71 |
|
| 72 |
if {$return_p} { return "process(\"./${test}\").${func}.${callee}.return" } |
| 73 |
|
| 74 |
if {$call_p} { return "process(\"./${test}\").${func}.${callee}.call" } |
| 75 |
|
| 76 |
return "process(\"./${test}\").${func}.${callee}" |
| 77 |
} |
| 78 |
|
| 79 |
# Runs stap -L against given func and callee and expects probes for |
| 80 |
# functions in expout list. The 'expout' param is a list of |
| 81 |
# caller/callee pairs expected to be printed out together. The |
| 82 |
# 'return_p' arg should be 1 if it is a .return probe, otherwise |
| 83 |
# (defaults to 0). The 'call_p' arg should be 1 if it is a .call |
| 84 |
# probe, otherwise (defaults to 0). |
| 85 |
proc expect_list { func callee expout {return_p 0} {call_p 0} } { |
| 86 |
global test testpath subtest |
| 87 |
|
| 88 |
# Build the stap command |
| 89 |
if {$return_p} { |
| 90 |
set cmd "stap -L [build_probe $func $callee 1]" |
| 91 |
} elseif {$call_p} { |
| 92 |
set cmd "stap -L [build_probe $func $callee 0 1]" |
| 93 |
} else { |
| 94 |
set cmd "stap -L [build_probe $func $callee]" |
| 95 |
} |
| 96 |
|
| 97 |
# Build the expect regex: pp1|pp2|pp3|... |
| 98 |
set n 0 |
| 99 |
set regexp "" |
| 100 |
foreach {expcaller expcallee} $expout { |
| 101 |
# process(path) |
| 102 |
set cregexp "^process\\\(\"[pwd]/${test}\"\\\)" |
| 103 |
# .function(func@/path/callee.subtest |
| 104 |
append cregexp "\\\.function\\\(\"$expcaller@\[^\"\]*${test}\\\.${subtest}" |
| 105 |
# fileno:lineno") |
| 106 |
append cregexp "\(\\\.\[0-9\]\)?\\\.c:\[0-9\]+\"\\\)" |
| 107 |
# .callee(expfunc@/path/callee.subtest |
| 108 |
append cregexp "\\\.callee\\\(\"$expcallee@\[^\"\]*${test}\\\.${subtest}" |
| 109 |
# fileno:lineno") __stuff__ \r\n |
| 110 |
append cregexp "\(\\\.\[0-9\]\)?\\\.c:\[0-9\]+\"\\\)" |
| 111 |
# .return |
| 112 |
if {$return_p} { |
| 113 |
append cregexp "\\\.return" |
| 114 |
} |
| 115 |
if {$call_p} { |
| 116 |
append cregexp "\\\.call" |
| 117 |
} |
| 118 |
# __stuff__ \r\n |
| 119 |
append cregexp "\[^\\r\\n\]*\\r\\n" |
| 120 |
if {[string length $regexp]} { |
| 121 |
append regexp | |
| 122 |
} |
| 123 |
append regexp $cregexp |
| 124 |
incr n |
| 125 |
} |
| 126 |
|
| 127 |
# Spawn stap -L |
| 128 |
eval spawn $cmd |
| 129 |
expect { |
| 130 |
-timeout 30 |
| 131 |
-re "$regexp" { |
| 132 |
# This actually *decrements* n |
| 133 |
incr n -1 |
| 134 |
exp_continue |
| 135 |
} |
| 136 |
timeout { |
| 137 |
kill -INT -[exp_pid] 2 |
| 138 |
} |
| 139 |
} |
| 140 |
catch {close}; catch {wait} |
| 141 |
|
| 142 |
return $n |
| 143 |
} |
| 144 |
|
| 145 |
# Runs stap against given func and callee and verifies that probes are |
| 146 |
# triggered. The 'expout' param is a list of caller/callee pairs |
| 147 |
# expected to be printed out together. The 'inlined' arg should be 1 |
| 148 |
# if callee is inlined, 0 otherwise (defaults to 0). The 'return_p' |
| 149 |
# arg should be 1 if it is a .return probe, otherwise (defaults to |
| 150 |
# 0). The 'call_p' arg should be 1 if it is a .call probe, otherwise |
| 151 |
# (defaults to 0). |
| 152 |
proc expect_probe { func callee expout {inlined 0} {return_p 0} |
| 153 |
{call_p 0} } { |
| 154 |
global test testpath subtest |
| 155 |
|
| 156 |
# If it's inlined or return, we use ustack(0) instead to get the 'caller' |
| 157 |
if {$inlined || $return_p || $call_p} { |
| 158 |
set caller usymname(ustack(0)) |
| 159 |
} else { |
| 160 |
set caller usymname(ustack(1)) |
| 161 |
} |
| 162 |
|
| 163 |
# Build the stap command |
| 164 |
set script " \ |
| 165 |
probe [build_probe $func $callee $return_p $call_p] { \ |
| 166 |
printf(\"caller %s callee %s\\n\", $caller, ppfunc()) \ |
| 167 |
}" |
| 168 |
|
| 169 |
# Build the expect regex: callee1caller1|callee2caller2|... |
| 170 |
set n 0 |
| 171 |
set regexp "" |
| 172 |
foreach {expcaller expcallee} $expout { |
| 173 |
set cregexp "^caller ${expcaller} callee ${expcallee}\[^\\r\\n\]*\\r\\n" |
| 174 |
if {[string length $regexp]} { |
| 175 |
append regexp | |
| 176 |
} |
| 177 |
append regexp $cregexp |
| 178 |
incr n |
| 179 |
} |
| 180 |
verbose -log "expecting $n line(s): '$regexp'" |
| 181 |
|
| 182 |
# Spawn stap |
| 183 |
spawn stap --ldd -e "$script" -c "./$test ; true" |
| 184 |
expect { |
| 185 |
-timeout 30 |
| 186 |
-re "$regexp" { |
| 187 |
# This actually *decrements* n |
| 188 |
incr n -1 |
| 189 |
exp_continue |
| 190 |
} |
| 191 |
timeout { |
| 192 |
kill -INT -[exp_pid] 2 |
| 193 |
} |
| 194 |
} |
| 195 |
catch {close}; catch {wait} |
| 196 |
|
| 197 |
return $n |
| 198 |
} |
| 199 |
|
| 200 |
for {set i 0} {$i < [arch_compile_flags]} {incr i} { |
| 201 |
# testcase callee.simple.c |
| 202 |
# allows testing of: |
| 203 |
# - basic probing of non-inlined callee |
| 204 |
# - recursive (.callees(N)) probing of non-inlined callees |
| 205 |
# - return callees |
| 206 |
set bits [arch_compile_flag_bits $i] |
| 207 |
set subtest "simple" |
| 208 |
set failed 0 |
| 209 |
|
| 210 |
set subsubtest "compilation - $bits-bit" |
| 211 |
if {!$failed} { |
| 212 |
passfail [compile_subtest $i] |
| 213 |
} |
| 214 |
|
| 215 |
set subsubtest "listing .callee(foo) - $bits-bit" |
| 216 |
if {!$failed} { |
| 217 |
set expout [list main level1] |
| 218 |
passfail [expect_list main level1 $expout] |
| 219 |
} |
| 220 |
|
| 221 |
set subsubtest "listing .callee(*) - $bits-bit" |
| 222 |
if {!$failed} { |
| 223 |
set expout [list main level1] |
| 224 |
passfail [expect_list main * $expout] |
| 225 |
} |
| 226 |
|
| 227 |
set subsubtest "listing .callee(foo).return - $bits-bit" |
| 228 |
if {!$failed} { |
| 229 |
set expout [list main level1] |
| 230 |
passfail [expect_list main level1 $expout 1] |
| 231 |
} |
| 232 |
|
| 233 |
set subsubtest "listing .callees - $bits-bit" |
| 234 |
if {!$failed} { |
| 235 |
set expout [list main level1] |
| 236 |
passfail [expect_list main 0 $expout] |
| 237 |
} |
| 238 |
|
| 239 |
set subsubtest "listing .callees(1) - $bits-bit" |
| 240 |
if {!$failed} { |
| 241 |
set expout [list main level1] |
| 242 |
passfail [expect_list main 1 $expout] |
| 243 |
} |
| 244 |
|
| 245 |
set subsubtest "listing .callees(2) - $bits-bit" |
| 246 |
if {!$failed} { |
| 247 |
set expout [list main level1 level1 level2] |
| 248 |
passfail [expect_list main 2 $expout] |
| 249 |
} |
| 250 |
|
| 251 |
set subsubtest "listing .callees(3) - $bits-bit" |
| 252 |
if {!$failed} { |
| 253 |
set expout [list main level1 level1 level2 level2 level3] |
| 254 |
passfail [expect_list main 3 $expout] |
| 255 |
} |
| 256 |
|
| 257 |
set subsubtest "probing .callee(foo) - $bits-bit" |
| 258 |
if {![installtest_p]} { |
| 259 |
untested "$test ($subtest - $subsubtest)" |
| 260 |
} elseif {!$failed} { |
| 261 |
set expout [list main level1] |
| 262 |
passfail [expect_probe main level1 $expout] |
| 263 |
} |
| 264 |
|
| 265 |
set subsubtest "probing .callee(foo).return - $bits-bit" |
| 266 |
if {![installtest_p]} { |
| 267 |
untested "$test ($subtest - $subsubtest)" |
| 268 |
} elseif {!$failed} { |
| 269 |
set expout [list main level1] |
| 270 |
passfail [expect_probe main level1 $expout 0 1] |
| 271 |
} |
| 272 |
|
| 273 |
set subsubtest "probing .callees - $bits-bit" |
| 274 |
if {![installtest_p]} { |
| 275 |
untested "$test ($subtest - $subsubtest)" |
| 276 |
} elseif {!$failed} { |
| 277 |
set expout [list main level1] |
| 278 |
passfail [expect_probe main 0 $expout] |
| 279 |
} |
| 280 |
|
| 281 |
set subsubtest "probing .callees(1) - $bits-bit" |
| 282 |
if {![installtest_p]} { |
| 283 |
untested "$test ($subtest - $subsubtest)" |
| 284 |
} elseif {!$failed} { |
| 285 |
set expout [list main level1] |
| 286 |
passfail [expect_probe main 1 $expout] |
| 287 |
} |
| 288 |
|
| 289 |
set subsubtest "probing .callees(2) - $bits-bit" |
| 290 |
if {![installtest_p]} { |
| 291 |
untested "$test ($subtest - $subsubtest)" |
| 292 |
} elseif {!$failed} { |
| 293 |
set expout [list main level1 level1 level2] |
| 294 |
passfail [expect_probe main 2 $expout] |
| 295 |
} |
| 296 |
|
| 297 |
set subsubtest "probing .callees(3) - $bits-bit" |
| 298 |
if {![installtest_p]} { |
| 299 |
untested "$test ($subtest - $subsubtest)" |
| 300 |
} elseif {!$failed} { |
| 301 |
set expout [list main level1 level1 level2 level2 level3] |
| 302 |
passfail [expect_probe main 3 $expout] |
| 303 |
} |
| 304 |
|
| 305 |
if {[file exists "$test"]} { file delete "$test" } |
| 306 |
|
| 307 |
# testcase callee.multicalls.c |
| 308 |
# allows testing of: |
| 309 |
# - probing of multiple different callees in the same caller |
| 310 |
# - probing of the same callee at different spots in the caller |
| 311 |
# - probing of the same callee from different callers is only |
| 312 |
# triggered for caller of interest |
| 313 |
# - recursive probing accounts for whole callstack, not just |
| 314 |
# immediate caller |
| 315 |
set subtest "multicalls" |
| 316 |
set failed 0 |
| 317 |
|
| 318 |
set subsubtest "compilation - $bits-bit" |
| 319 |
if {!$failed} { |
| 320 |
passfail [compile_subtest $i] |
| 321 |
} |
| 322 |
|
| 323 |
set subsubtest "listing main .callees - $bits-bit" |
| 324 |
if {!$failed} { |
| 325 |
set expout [list main foo main bar] |
| 326 |
passfail [expect_list main 0 $expout] |
| 327 |
} |
| 328 |
|
| 329 |
set subsubtest "listing bar .callees - $bits-bit" |
| 330 |
if {!$failed} { |
| 331 |
set expout [list bar foo] |
| 332 |
passfail [expect_list bar 0 $expout] |
| 333 |
} |
| 334 |
|
| 335 |
set subsubtest "probing main .callees - $bits-bit" |
| 336 |
if {![installtest_p]} { |
| 337 |
untested "$test ($subtest - $subsubtest)" |
| 338 |
} elseif {!$failed} { |
| 339 |
set expout [list main foo main bar main foo] |
| 340 |
passfail [expect_probe main 0 $expout] |
| 341 |
} |
| 342 |
|
| 343 |
set subsubtest "probing bar .callees - $bits-bit" |
| 344 |
if {![installtest_p]} { |
| 345 |
untested "$test ($subtest - $subsubtest)" |
| 346 |
} elseif {!$failed} { |
| 347 |
set expout [list bar foo] |
| 348 |
passfail [expect_probe bar 0 $expout] |
| 349 |
} |
| 350 |
|
| 351 |
# This is where we test that the whole stack is truly being |
| 352 |
# examined and not just the immediate caller. If all it checked |
| 353 |
# was the immediate caller, we would also have output from when |
| 354 |
# baz is called from stack foo->bar->main (which would be wrong |
| 355 |
# since it's more than depth 2 away from main). |
| 356 |
set subsubtest "probing main .callees(2) - $bits-bit" |
| 357 |
if {![installtest_p]} { |
| 358 |
untested "$test ($subtest - $subsubtest)" |
| 359 |
} elseif {!$failed} { |
| 360 |
set expout [list main foo foo baz main bar bar foo main foo foo baz ] |
| 361 |
passfail [expect_probe main 2 $expout] |
| 362 |
} |
| 363 |
|
| 364 |
if {[file exists "$test"]} { file delete "$test" } |
| 365 |
|
| 366 |
# testcase callee.inlined.c |
| 367 |
# allows testing of: |
| 368 |
# - probing inlined callees |
| 369 |
# - probing .call callees |
| 370 |
# - probing nested inlined callees |
| 371 |
# - recursive (.callees(N)) probing of inlined callees |
| 372 |
# - probing of the same (inlined) callee from different callers is |
| 373 |
# only triggered for caller of interest |
| 374 |
# - recursive probing accounts for whole callstack, not just |
| 375 |
# immediate caller, even when there are inlined instances |
| 376 |
# in-between |
| 377 |
set subtest "inlined" |
| 378 |
set failed 0 |
| 379 |
|
| 380 |
set subsubtest "compilation - $bits-bit" |
| 381 |
if {!$failed} { |
| 382 |
passfail [compile_subtest $i] |
| 383 |
} |
| 384 |
|
| 385 |
set subsubtest "listing main .callees - $bits-bit" |
| 386 |
if {!$failed} { |
| 387 |
set expout [list main foo main bar] |
| 388 |
passfail [expect_list main 0 $expout] |
| 389 |
} |
| 390 |
|
| 391 |
set subsubtest "listing bar .callees - $bits-bit" |
| 392 |
if {!$failed} { |
| 393 |
set expout [list bar foo] |
| 394 |
passfail [expect_list bar 0 $expout] |
| 395 |
} |
| 396 |
|
| 397 |
set subsubtest "listing .callee(foo).call - $bits-bit" |
| 398 |
if {!$failed} { |
| 399 |
set expout [list main foo] |
| 400 |
passfail [expect_list main foo $expout 0 1] |
| 401 |
} |
| 402 |
|
| 403 |
set subsubtest "probing .callee(foo).call - $bits-bit" |
| 404 |
if {![installtest_p]} { |
| 405 |
untested "$test ($subtest - $subsubtest)" |
| 406 |
} elseif {!$failed} { |
| 407 |
set expout [list main foo main foo] |
| 408 |
passfail [expect_probe main foo $expout 0 0 1] |
| 409 |
} |
| 410 |
|
| 411 |
set subsubtest "probing main .callees - $bits-bit" |
| 412 |
if {![installtest_p]} { |
| 413 |
untested "$test ($subtest - $subsubtest)" |
| 414 |
} elseif {!$failed} { |
| 415 |
set expout [list main foo main bar main foo] |
| 416 |
passfail [expect_probe main 0 $expout 1] |
| 417 |
} |
| 418 |
|
| 419 |
set subsubtest "probing bar .callees - $bits-bit" |
| 420 |
if {![installtest_p]} { |
| 421 |
untested "$test ($subtest - $subsubtest)" |
| 422 |
} elseif {!$failed} { |
| 423 |
set expout [list main foo] |
| 424 |
passfail [expect_probe bar 0 $expout 1] |
| 425 |
} |
| 426 |
|
| 427 |
# Similarly to the last subsubtest of multicalls, here we test |
| 428 |
# that the whole stack is truly being examined. |
| 429 |
set subsubtest "probing main .callees(2) - $bits-bit" |
| 430 |
if {![installtest_p]} { |
| 431 |
untested "$test ($subtest - $subsubtest)" |
| 432 |
} elseif {!$failed} { |
| 433 |
set expout [list main foo main baz main bar main foo main foo main baz] |
| 434 |
passfail [expect_probe main 2 $expout 1] |
| 435 |
} |
| 436 |
|
| 437 |
if {[file exists "$test"]} { file delete "$test" } |
| 438 |
|
| 439 |
# testcase callee.extern.c |
| 440 |
# allows testing of: |
| 441 |
# - probing of callees located in a different CU |
| 442 |
set subtest "extern" |
| 443 |
set failed 0 |
| 444 |
|
| 445 |
set subsubtest "compilation - $bits-bit" |
| 446 |
if {!$failed} { |
| 447 |
passfail [compile_subtest $i 2] |
| 448 |
} |
| 449 |
|
| 450 |
set subsubtest "listing main .callees - $bits-bit" |
| 451 |
if {!$failed} { |
| 452 |
set expout [list main foo] |
| 453 |
passfail [expect_list main 0 $expout] |
| 454 |
} |
| 455 |
|
| 456 |
set subsubtest "listing foo .callees - $bits-bit" |
| 457 |
if {!$failed} { |
| 458 |
set expout [list foo bar] |
| 459 |
passfail [expect_list foo 0 $expout] |
| 460 |
} |
| 461 |
|
| 462 |
set subsubtest "probing main .callees - $bits-bit" |
| 463 |
if {![installtest_p]} { |
| 464 |
untested "$test ($subtest - $subsubtest)" |
| 465 |
} elseif {!$failed} { |
| 466 |
set expout [list main foo] |
| 467 |
passfail [expect_probe main 0 $expout] |
| 468 |
} |
| 469 |
|
| 470 |
set subsubtest "probing foo .callees - $bits-bit" |
| 471 |
if {![installtest_p]} { |
| 472 |
untested "$test ($subtest - $subsubtest)" |
| 473 |
} elseif {!$failed} { |
| 474 |
set expout [list foo bar] |
| 475 |
passfail [expect_probe foo 0 $expout] |
| 476 |
} |
| 477 |
|
| 478 |
if {[file exists "$test"]} { file delete "$test" } |
| 479 |
|
| 480 |
# testcase callee.reloc.c |
| 481 |
# allows testing of: |
| 482 |
# - proper relocation of caller addr |
| 483 |
|
| 484 |
# In this test, we will compile our very own shared lib as well as |
| 485 |
# a sample executable that uses the shared lib to verify that |
| 486 |
# relocation works properly. So as expected, it's a bit more |
| 487 |
# involved than the previous tests and we can't really use the |
| 488 |
# nice procs we have in place. Everything has to be done 'by |
| 489 |
# hand'. |
| 490 |
|
| 491 |
set subtest "reloc" |
| 492 |
set failed 0 |
| 493 |
|
| 494 |
# We first compile the shared lib |
| 495 |
set subsubtest "shlib compilation - $bits-bit" |
| 496 |
if {!$failed} { |
| 497 |
set libso "lib$subtest.so" |
| 498 |
set flags "compiler=gcc [arch_compile_flag $i]" |
| 499 |
set flags "$flags additional_flags=-O additional_flags=-g" |
| 500 |
set flags "$flags additional_flags=-shared additional_flags=-fPIC" |
| 501 |
set res [target_compile "${testpath}/${test}.${subtest}.lib.c" \ |
| 502 |
$libso executable $flags] |
| 503 |
if {$res == "" && [file exists $libso]} { |
| 504 |
pass "$test ($subtest - $subsubtest)" |
| 505 |
} else { |
| 506 |
fail "$test ($subtest - $subsubtest)" |
| 507 |
set failed 1 |
| 508 |
} |
| 509 |
} |
| 510 |
|
| 511 |
# Compile executable |
| 512 |
set subsubtest "exe compilation - $bits-bit" |
| 513 |
if {!$failed} { |
| 514 |
set flags "compiler=gcc [arch_compile_flag $i]" |
| 515 |
set flags "$flags additional_flags=-O additional_flags=-g" |
| 516 |
set flags "$flags additional_flags=-Wl,-rpath,[pwd]" |
| 517 |
set flags "$flags additional_flags=-L[pwd]" |
| 518 |
set flags "$flags additional_flags=-l$subtest" |
| 519 |
set res [target_compile "${testpath}/${test}.${subtest}.c" \ |
| 520 |
$subtest executable $flags] |
| 521 |
|
| 522 |
if {$res == "" && [file exists "$subtest"]} { |
| 523 |
pass "$test ($subtest - $subsubtest)" |
| 524 |
} else { |
| 525 |
fail "$test ($subtest - $subsubtest)" |
| 526 |
set failed 1 |
| 527 |
} |
| 528 |
} |
| 529 |
|
| 530 |
# List probes in shared lib |
| 531 |
set subsubtest "listing shlib foo .callees - $bits-bit" |
| 532 |
if {!$failed} { |
| 533 |
|
| 534 |
set probe process("./$subtest").library("$libso").function("foo").callees |
| 535 |
|
| 536 |
# process(/path/$libso).function(foo@ |
| 537 |
set regexp "^process\\\(\"\[^\"\]*/$libso\"\\\)\\\.function\\\(\"foo@" |
| 538 |
# /path/callee.reloc.lib.c.:<lineno>) |
| 539 |
append regexp "\[^\"\]*/${test}\\\.${subtest}\\\.lib\\\.c:\[0-9\]+\"\\\)" |
| 540 |
# .callee(bar@ |
| 541 |
set regexp "\\\.callee\\\(\"bar@" |
| 542 |
# /path/callee.reloc.lib.c.:<lineno>) |
| 543 |
append regexp "\[^\"\]*/${test}\\\.${subtest}\\\.lib\\\.c:\[0-9\]+\"\\\)" |
| 544 |
# <line end> |
| 545 |
append regexp "\[^\\r\\n\]*\\r\\n$" |
| 546 |
|
| 547 |
set failed 1 |
| 548 |
eval spawn stap -L {$probe} |
| 549 |
expect { |
| 550 |
-timeout 30 |
| 551 |
-re "$regexp" { set failed 0 } |
| 552 |
timeout { |
| 553 |
kill -INT -[exp_pid] 2 |
| 554 |
} |
| 555 |
} |
| 556 |
catch {close}; catch {wait} |
| 557 |
|
| 558 |
if {!$failed} { |
| 559 |
pass "$test ($subtest - $subsubtest)" |
| 560 |
} else { |
| 561 |
fail "$test ($subtest - $subsubtest)" |
| 562 |
} |
| 563 |
} |
| 564 |
|
| 565 |
# Actually probe it |
| 566 |
set subsubtest "probing shlib foo .callees - $bits-bit" |
| 567 |
if {![installtest_p]} { |
| 568 |
untested "$test ($subtest - $subsubtest)" |
| 569 |
} elseif {!$failed} { |
| 570 |
|
| 571 |
set script " \ |
| 572 |
probe process(\"./$subtest\").library(\"$libso\") \ |
| 573 |
.function(\"foo\").callees { \ |
| 574 |
printf(\"caller %s callee %s\\n\", usymname(ustack(1)), \ |
| 575 |
ppfunc()) \ |
| 576 |
} \ |
| 577 |
" |
| 578 |
|
| 579 |
# Spawn stap |
| 580 |
spawn stap --ldd -e "$script" -c "./$subtest ; true" |
| 581 |
set failed 1 |
| 582 |
expect { |
| 583 |
-timeout 30 |
| 584 |
{caller foo callee bar} { set failed 0 } |
| 585 |
timeout { kill -INT -[exp_pid] 2 } |
| 586 |
eof { } |
| 587 |
} |
| 588 |
catch {close}; catch {wait} |
| 589 |
|
| 590 |
if {!$failed} { |
| 591 |
pass "$test ($subtest - $subsubtest)" |
| 592 |
} else { |
| 593 |
fail "$test ($subtest - $subsubtest)" |
| 594 |
} |
| 595 |
} |
| 596 |
|
| 597 |
# Cleanup files |
| 598 |
if {[file exists "$libso"]} { file delete "$libso" } |
| 599 |
if {[file exists "$subtest"]} { file delete "$subtest" } |
| 600 |
} |