I am trying to get this example systemtap script running, but does'nt compile.
I've made modifications etc but can't figure out what's wrong with the syntax.
I know that systemtap is functioning as I can run a few other scripts, such as
Code:
stap -e 'probe kernel.function("sys_open") {log("hello world") exit()}'
My kernel is 2.6.38-8-generic #42-Ubuntu SMP and I have the debuginfo kernel installed.
This is where I found the script :
http://sources.redhat.com/systemtap/wiki/WSFileMonitor
I have made this modification as recommended :
Code:
Eugene: Using kernel 2.6.21-1.3194.fc7, I have to change the code slightly:
dev_nr = $file->f_path->dentry->d_inode->i_sb->s_dev
inode_nr = $file->f_path->dentry->d_inode->i_ino
Here are the errors when I run the script.
Code:
# stap wsfile.stp
parse error: command line argument index 1 out of range [1-0]
at: junk '$1' at wsfile.stp:9:18
source: if (dev_nr == ($1 << 20 | $2) # major/minor device
^
parse error: command line argument index 2 out of range [1-0]
at: junk '$2' at wsfile.stp:9:29
source: if (dev_nr == ($1 << 20 | $2) # major/minor device
^
parse error: command line argument index 3 out of range [1-0]
at: unknown token '$3' at wsfile.stp:10:22
source: && inode_nr == $3)
^
parse error: expected 'probe', 'global', 'function', or '%{'
saw: operator ')' at wsfile.stp:10:24
source: && inode_nr == $3)
^
4 parse error(s).
Pass 1: parse failed. Try again with another '--vp 1' option.
Here is the script :
Code:
#! /usr/bin/env stap
probe kernel.function ("vfs_write"),
kernel.function ("vfs_read")
{
dev_nr = $file->f_path->d_inode->i_sb->s_dev
inode_nr = $file->f_path->d_inode->i_ino
if (dev_nr == ($1 << 20 | $2) # major/minor device
&& inode_nr == $3)
printf ("%s(%d) %s 0x%x/%u\n",
execname(), pid(), probefunc(), dev_nr, inode_nr)
}