user mode backtrace
Stone, Joshua I
joshua.i.stone@intel.com
Fri Oct 20 02:13:00 GMT 2006
On Thursday, October 19, 2006 5:10 PM, Frank Ch. Eigler wrote:
> "Stone, Joshua I" <joshua.i.stone@intel.com> writes:
>
>> [...] Deadlock issues aside, there's not really a way for you to
>> invoke a process (like pstack) from within a SystemTap script. [...]
>
> It turns out that quite some time ago, Martin implemented a clone of
> the dtrace system() function for systemtap, which enqueues a string
> for execution by the userspace staprun daemon. (There is no
> synchronization or data exchange though.)
I forgot we had that. Take two... :)
-----------------------------------------------
global args
probe syscall.open {
t = tid()
if (target() != t) next;
args[t] = argstr
}
probe syscall.open.return {
t = tid()
if (target() != t) next;
send_stop() // do this on return to avoid EINTR
printf("\n%d %s open(%s) = %s\n", t, execname(), args[t], retstr)
system(sprintf("pstack %d && kill -CONT %d", t, t))
delete args[t]
}
function send_stop() %{
send_sig(SIGSTOP, current, 1);
%}
-----------------------------------------------
... and this one actually works! Mostly... when I SIGSTOP an app
started from an interactive shell, the shell seems to take back control,
and I can't get SIGCONT to work nicely. But, I tried targeting a gvim
process, which is detached, and it worked just fine!
Of course, it's VERY slow -- probably orders of magnitude slower than
other options like recording the stack frame for post-processing.
It's still a fun exercise though. :)
Josh
More information about the Systemtap
mailing list