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: rethinking syscall tapset


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.


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