This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: here's an example tap file for RHEL 4 update 2
- From: Martin Hunt <hunt at redhat dot com>
- To: bruno at rocksclusters dot org
- Cc: "systemtap at sources dot redhat dot com" <systemtap at sources dot redhat dot com>
- Date: Fri, 09 Dec 2005 16:02:23 -0800
- Subject: Re: here's an example tap file for RHEL 4 update 2
- Organization: Red Hat Inc
- References: <e572dbf60512091351n4f0a50dhd497da3f32e8330@mail.gmail.com>
Thanks for sharing your script. It is useful for us developers to see
how people are using systemtap and what problems they are having. You
found some impressive workarounds for systemtap's limitations.
Systemtap is rapidly evolving, so there are some things you might be
able to do better if you can build a more recent systemtap. One thing I
can't think of is a simple way to support a list of executables to
monitor. Perhaps its time to add a way to pass arguments to systemtap
scripts.
If you are only interested in tracing one executable at a time, you can
use the "-c" or "-x" options to stap. You can also run multiple
systemtap scripts at once.
The syscall tapset is almost finished for i386 and is in the current
build tree. I don't know what it's state was in the systemtap shipped
with RHEL4U2. Using that helps keep things cleaner. So you might do
something like:
---
probe kernel.syscall.read {
if(pid() == target())
printf("read: %s\tfd: %d\tcount: %d\n", execname(), fd, count)
}
probe kernel.syscall.write {
if(pid() == target())
printf("write: %s\tfd: %d\tcount: %d\n", execname(), fd, count)
}
probe kernel.syscall.open {
if(pid() == target())
printf("open: %s\tfile: %s\tflags: %x\n", execname(),
user_string(filename_uaddr), flags)
}
probe kernel.syscall.open.return {
if(pid() == target())
printf("open: %s\treturned fd: %d\n", execname(), retval())
---
Then when you use "-c" or "-x" with stap, target() returns the pid.
So you can use the above script and do
> stap -c foobar sys.stp OR
> stap -x 1234 sys.stp
Martin