This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Matching function parameters and corresponding return value
- From: Martin Hunt <hunt at redhat dot com>
- To: Li Guanglei <guanglei at cn dot ibm dot com>
- Cc: Sylvain Fourmanoit <syfou at users dot sourceforge dot net>, systemtap at sourceware dot org
- Date: Wed, 14 Jun 2006 11:04:37 -0700
- Subject: Re: Matching function parameters and corresponding return value
- Organization: Red Hat Inc.
- References: <Pine.LNX.4.64.0606131800540.5501@sylvain> <448F4749.6020306@cn.ibm.com>
On Wed, 2006-06-14 at 07:16 +0800, Li Guanglei wrote:
> Sylvain Fourmanoit ??:
> > Hi all,
> >
> > I would like to watch calls to a preemptible function such as sys_open():
> > ideally, I would like to know both the tentatively accessed files and
> > the success (or not) of the various calls.
> >
> > But I don't see how to do this: of course, I can without problem
> > register a jprobe and a kretprobe on sys_open(), both how do I correlate
> > pairs of probe calls reliably? Or is it just the wrong approach?
> >
> > Any insight on how to do this, either with SystemTap or directly with
> > Kprobes would be really appreciated!
> >
> Although some syscalls are preemptible, but you can still correlate
> the pairs of entry/return of a syscall by tid(task->pid). e.g:
> TID(task->pid) Syscall
> 1122 sys_open.entry
> (preempted by foo()) 223 foo.entry
> ...
> 223 foo.return
> 1122 sys_open.return
> So what you can do is just to search the sys_open.return with the same
> tid and skip all the calls met during the search.
It sounds harder than it is. For the case of just sys_open, it is just
this:
---
global args
probe syscall.open {
args[tid()] = argstr
}
probe syscall.open.return {
printf("%s: %s(%s) = %s\n", execname(), name, args[tid()], retstr)
}
---
To extend that to multiple system calls, use "name" as a key:
args[name, tid()] = argstr
Martin