This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
RE: user mode backtrace
- From: "Stone, Joshua I" <joshua dot i dot stone at intel dot com>
- To: "Frank Ch. Eigler" <fche at redhat dot com>
- Cc: <david_list at boreham dot org>, "SystemTap" <systemtap at sources dot redhat dot com>
- Date: Thu, 19 Oct 2006 19:13:21 -0700
- Subject: RE: user mode backtrace
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