This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Eliminating duplicate code in tapset files
- From: Mike Mason <mmlnx at us dot ibm dot com>
- To: systemtap at sourceware dot org
- Date: Tue, 10 Jul 2007 14:13:20 -0700
- Subject: Eliminating duplicate code in tapset files
Suppose I have a tapset with many probes and most of the variables exposed by these probes are the same. Rather than duplicating the same code over and over, I'd like to define the variables once and reference that definition in each probe, similar to a macro. I envision something like below (details TBD). Is there some way to accomplish this now in SystemTap? If not, how do others feel about adding this capability?
Mike
macro VFS_COMMON
{
file = $file
count = $count
pos = $pos
buf = $buf
dev = __file_dev($file)
devname = __find_bdevname(dev, __file_bdev($file))
ino = __file_ino($file)
filename = __file_filename($file)
}
probe vfs.read = kernel.function ("vfs_read")
{
%VFS_COMMON
size = count
}
probe vfs.read.return = kernel.function ("vfs_read").return
{
%VFS_COMMON
size = $return
}
probe vfs.write = kernel.function ("vfs_write")
{
%VFS_COMMON
size = count
}
probe vfs.write.return = kernel.function ("vfs_write").return
{
%VFS_COMMON
size = $return
}