* Matching function parameters and corresponding return value
@ 2006-06-13 22:20 Sylvain Fourmanoit
2006-06-13 23:15 ` Li Guanglei
2006-06-14 14:25 ` Frank Ch. Eigler
0 siblings, 2 replies; 4+ messages in thread
From: Sylvain Fourmanoit @ 2006-06-13 22:20 UTC (permalink / raw)
To: systemtap
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!
--
Sylvain <syfou@users.sourceforge.net>
"Don't fear the pen. When in doubt, draw a pretty picture."
--Baker's Third Law of Design.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Matching function parameters and corresponding return value
2006-06-13 22:20 Matching function parameters and corresponding return value Sylvain Fourmanoit
@ 2006-06-13 23:15 ` Li Guanglei
2006-06-14 18:04 ` Martin Hunt
2006-06-14 14:25 ` Frank Ch. Eigler
1 sibling, 1 reply; 4+ messages in thread
From: Li Guanglei @ 2006-06-13 23:15 UTC (permalink / raw)
To: Sylvain Fourmanoit; +Cc: systemtap
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.
- Guanglei
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Matching function parameters and corresponding return value
2006-06-13 23:15 ` Li Guanglei
@ 2006-06-14 18:04 ` Martin Hunt
0 siblings, 0 replies; 4+ messages in thread
From: Martin Hunt @ 2006-06-14 18:04 UTC (permalink / raw)
To: Li Guanglei; +Cc: Sylvain Fourmanoit, systemtap
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Matching function parameters and corresponding return value
2006-06-13 22:20 Matching function parameters and corresponding return value Sylvain Fourmanoit
2006-06-13 23:15 ` Li Guanglei
@ 2006-06-14 14:25 ` Frank Ch. Eigler
1 sibling, 0 replies; 4+ messages in thread
From: Frank Ch. Eigler @ 2006-06-14 14:25 UTC (permalink / raw)
To: Sylvain Fourmanoit; +Cc: systemtap
Sylvain Fourmanoit <syfou@users.sourceforge.net> writes:
> 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.
This is to be addressed in systemtap bug #1382. When this feature is
implemented, it will allow one to write probes of the form:
probe kernel.function("foo").return {
print ("saved arg1=") print ($foo)
print (" arg2=") print ($bar)
print (" return value=") print ($return)
}
In particular, a copy of incoming parameters will be saved by an
implicit kprobe and will be accessable to the .return probe.
In the mean time, one can do the same work by hand - write an ordinary
function-entry probe, save the arguments in some auxiliary array
indexed by tid() (and other state such as nesting level if necessary),
then look up the values in the .return probe.
- FChE
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-06-14 18:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-13 22:20 Matching function parameters and corresponding return value Sylvain Fourmanoit
2006-06-13 23:15 ` Li Guanglei
2006-06-14 18:04 ` Martin Hunt
2006-06-14 14:25 ` Frank Ch. Eigler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).