Created
June 3, 2016 01:07
-
-
Save cuviper/de7584062319204b9cf0969b3392aa12 to your computer and use it in GitHub Desktop.
SystemTap script for tracing dyninst #50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Run this like: | |
* stap -v dyninst-issue50.stp -d /lib64/libc.so.6 -d /path/to/libdyninstAPI_RT.so | |
* | |
* If you get truncated backtraces, add another -d for that library. | |
* | |
* Then run the dyninst test in another terminal like this: | |
* ./test_driver -test test4_2 -v | |
*/ | |
private active | |
function trace(msg) { | |
time = local_clock_ns(); | |
printf("%d.%09d %15s %5d: %s", | |
time / 1000000000, time % 1000000000, | |
execname(), tid(), msg); | |
} | |
function filter(name) { | |
return name == "test_driver" | |
|| name == "memcheck-amd64-" | |
|| name == "test4_2.dyn_g++" | |
} | |
probe trace_call { | |
if (filter(execname())) { | |
if (active) | |
println("..."); | |
trace(sprintf("%s (%s) = ", name, argstr)); | |
active = tid(); | |
} | |
} | |
probe trace_return { | |
if (filter(execname())) { | |
if (active != tid()) { | |
if (active) | |
printf("\n"); | |
trace(sprintf("... %s = ", name)); | |
} | |
println(retstr) | |
delete active | |
} | |
} | |
probe trace_call = syscall.ptrace { } | |
probe trace_return = syscall.ptrace.return { | |
if (geteventmsg_data) | |
retstr = sprintf("%s (%#x %d)", retstr, geteventmsg_data, geteventmsg_data); | |
if (arch_prctl_addr) | |
retstr = sprintf("%s (%p)", retstr, arch_prctl_addr); | |
} | |
probe trace_call = syscall.wait4 { } | |
probe trace_return = syscall.wait4.return { | |
if ($return > 0) | |
retstr = sprintf("%s (%s)", retstr, status_str); | |
} | |
probe trace_call = syscall.{process_vm_readv,process_vm_writev} { } | |
probe trace_return = syscall.{process_vm_readv,process_vm_writev}.return { } | |
probe trace_call = syscall.futex { } | |
probe trace_return = syscall.futex.return { } | |
/* | |
probe process("/lib64/libpthread.so.0").mark("cond*") { | |
if (filter(execname())) { | |
if (active) | |
println("..."); | |
delete active; | |
trace(sprintf("%s (%s)\n", $$name, $$parms)); | |
} | |
} | |
*/ | |
/* | |
probe process("/lib64/libc.so.6").mark("memory_*") { | |
if (filter(execname())) { | |
if (active) | |
println("..."); | |
delete active; | |
trace(sprintf("%s (%s)\n", $$name, $$parms)); | |
} | |
} | |
*/ | |
probe signal.handle { | |
if (filter(execname())) { | |
if (active) | |
println("..."); | |
delete active; | |
trace(sprintf("%s %d (%s)\n", pn(), sig, sig_name)); | |
} | |
} | |
probe signal.send { | |
if (filter(pid_name)) { | |
if (active) | |
println("..."); | |
delete active; | |
trace(sprintf("%s %d (%s) to %d\n", pn(), sig, sig_name, sig_pid)); | |
} | |
} | |
probe scheduler.cpu* { | |
if (filter(execname())) { | |
if (active) | |
println("..."); | |
delete active; | |
trace(sprintf("%s %d\n", pn(), cpu())); | |
if (name=="cpu_off" && execname()=="test4_2.dyn_g++") | |
print_ubacktrace() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment