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: Sockets tapset and script


Martin Hunt wrote:
On Fri, 2006-11-17 at 14:26 -0800, Mike Mason wrote:
Attached is a sockets tapset and a script that uses the tapset.

Very nice!


It seems like tokenize() and str2long() (perhaps renamed simply strtol)
would be good candidates to put in the string tapset so others could use
them.

Since yesterday, we can now access parameters in return probes (BZ
1382). This could simplify some of your script because yo no longer need
to cache parameters on entry probes and then lookup their values in the
return probe.

In print_activity, you can simply do this:
	foreach ([pid, prot, fam] in sk_pid- limit max) { ... }
Then you don't need "if (!--max) break"
This is a bit cleaer and generates faster code.

Mapping functions are something I think script writers need, not just for sockets, but in a lot of other areas. Some of these functions using mapping arrays. What do people think of this approach?

It is simple and elegant. However, in time-critical code (which your example is probably not) it may be better to write them in C. A complicated example would be what I did in errno.stp. Of course that example doesn't include the reverse map.

Mike,


One thing you might want to think about is instead of initializing your mapping arrays on first use would be to put their initialization in a begin probe. You'd pay more up front cost but if your probe code was time-critical (which your use might not be) you wouldn't be slowed down by mapping array initialization in the probe itself. The optimizer will optimize out the array and array initialization if the array isn't actually used anywhere.

This would be similar to what happens when you do "global xyz = 1" - a begin probe is generated that sets up the initial value of xyz. Hmm, perhaps we need a bugzilla asking to support array initialization, perhaps like this:
global xyz = { 1, 5, 10, 15 }
global abc = { "zero", "one", "two", "three", "four" }


--
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)


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