This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: rethinking syscall tapset
- From: Martin Hunt <hunt at redhat dot com>
- To: "Daniel P. Berrange" <berrange at redhat dot com>
- Cc: Hien Nguyen <hien at us dot ibm dot com>, "systemtap at sources dot redhat dot com" <systemtap at sources dot redhat dot com>
- Date: Tue, 31 Jan 2006 11:43:08 -0800
- Subject: Re: rethinking syscall tapset
- Organization: Red Hat Inc
- References: <1138689272.3948.17.camel@monkey2> <20060131184357.GB19557@redhat.com>
On Tue, 2006-01-31 at 18:43 +0000, Daniel P. Berrange wrote:
> > I've created another variable all return probes set called "returnp".
>
> I'm not clear on the intended use of this, besides enabling both the
> call & return to be written in one block, using a conditional ?
Basically that's it. It's not a big deal.
> Is there anyway to create the syscall tapset such that a user dosn't have
> to explicitly attach to both the call & return probes ?
I don't see how. What would that save you?
Looking at your example below, the new syscall tapset would make it much
simpler.
probe syscall.* {
logtimetrack[pid(),name] = gettimeofday_ms()
logdatatrack[pid(),name] = argstr
}
probe syscall.*.return {
time = gettimeofday_ms()
printf("%d: [%d] %s(%s) = %d (+ %d ms)", time - starttime,
pid(), name, logdatatrack[pid(),name], retval(),
time - logtimetrack[pid(),name])
}
> As an example I'm
> trying to write a systemwide strace()-alike in systemtap, which requires
> saving the data from the call probe in a map & then in the return probe
> fishing it out again to print alongisde the return value.
>
> If it helps, a simplified version of my curent probe is:
>
> global logdatatrack
> global logtimetrack
>
> probe begin {
> starttime = gettimeofday_ms()
> log("startup");
> }
>
> probe end {
> log("shutdown");
> }
>
> function logcall(call, data) {
> if (execname() != "stpd") {
> key = string(pid()) . ":" . call
> logtimetrack[key] = gettimeofday_ms()
> logdatatrack[key] = string(logtimetrack[key]- starttime) . " pid " . string(pid()) . " (" . execname() . ") " . call . " " . data
> }
> }
>
> function logreturn(call, data) {
> if (execname() != "stpd") {
> key = string(pid()) . ":" . call
> if (logdatatrack[key] != "") {
> duration = gettimeofday_ms() - logtimetrack[key]
> log(logdatatrack[key] . " = " . data . " (+" . string(duration) . ")")
> delete logdatatrack[key]
> delete logtimetrack[key]
> }
> }
> }
>
> probe kernel.syscall.stat {
> logcall("stat", user_string(filename_uaddr))
> }
>
> probe kernel.syscall.stat.return {
> logreturn("stat", string(retval()))
> }
>
> probe kernel.syscall.stat64 {
> logcall("stat", user_string(filename_uaddr))
> }
>
> probe kernel.syscall.stat64.return {
> logreturn("stat", string(retval()))
> }
>
>
> Regards,
> Dan.