LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-21-2011, 01:31 PM   #1
dazdaz
Member
 
Registered: Aug 2003
Location: Europe
Distribution: RHEL, CentOS, Ubuntu
Posts: 333

Rep: Reputation: 17
WSFileMonitor systemtap script


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)
}

Last edited by dazdaz; 05-21-2011 at 02:08 PM.
 
Old 05-22-2011, 05:45 PM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by dazdaz View Post
Code:
if (dev_nr == ($1 << 20 | $2) # major/minor device
      && inode_nr == $3)
What are $1, $2, and $3 supposed to be? Are you sure you don't mean @1, @2, and @3, respectively?

I recommend you take a look at the sizeof.stp systemtap example.
 
Old 05-23-2011, 02:22 PM   #3
dazdaz
Member
 
Registered: Aug 2003
Location: Europe
Distribution: RHEL, CentOS, Ubuntu
Posts: 333

Original Poster
Rep: Reputation: 17
systemtap complains when I change the $ to an @. I know it should be run like this, but for me it does'nt seem to work.

Code:
script.stp arg1 arg2 arg3.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
systemtap returntimeofday_s and some questions wakatana Programming 0 03-26-2011 05:47 AM
LXer: Linux introspection and SystemTap LXer Syndicated Linux News 0 11-11-2009 03:50 AM
Error message concerning systemtap file kaplan71 Fedora 1 02-25-2009 07:14 PM
SystemTap translator/driver - do I really need it?! robertjinx Linux - Server 0 10-11-2007 09:02 AM
SystemTap gloridel Linux - Software 0 04-17-2007 04:21 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration