This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: here's an example tap file for RHEL 4 update 2


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]