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]

Better handling of arguments/literals from the command-line?


I was experimenting with Systemtap script that is "a better strace"
(i.e., one that doesn't perturb the targetted process quite so much),
via a script like this:

probe syscall.* {
	if (pid() == $1) {
		t = gettimeofday_ms();
		printf("%d:%03d:%s(%s)\n", t/1000, t%1000, name, argstr)
	}
}

probe syscall.*.return {
	if (pid() == $1) {
		t = gettimeofday_ms();
		printf("%d:%03d;%s returns %s\n", t/1000,t%1000, name, retstr)
	}
}

I discovered to my dismay that this script took a full 45 seconds before
it started, and consumed 100% of one CPU while it was compiling it.  I
further found that each time I gave this script a new pid on the command
line, it took another 45 seconds.  If I gave it a pid that it had seen
before, it only took 10 seconds.  Leaving aside why it took a full 10
seconds (which still seems too long) even when the scripts for a
particular pid was cached, it seems rather unfortunate that literals
such as $1 appear to be substituted in early in the compilation process
instead of being passed in when the module is loaded, as arguments to
the module.   

If the argument were passed into the kernel, then it would be posible to
cache the compiled "strace.stp" script once, instead of having to
re-evaluate it for every single process ID.  Is there a good reason it
isn't handle this way currently?

Thanks, regards,

						- Ted


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