From: Srinivasa DS <srinivasa@in.ibm.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>,
systemtap <systemtap@sources.redhat.com>,
Ananth Mavinakayanahalli <ananth@in.ibm.com>,
Maneesh Soni <maneesh@linux.vnet.ibm.com>
Subject: [RFC] Some Interesting one liner systemtap scripts
Date: Thu, 11 Sep 2008 09:54:29 +0530 [thread overview]
Message-ID: <48C89D7D.3070105@in.ibm.com> (raw)
I am listing out some interesting one line systemtap scripts which can be
of handy use for kernel developers. These scripts can be reused to probe other
functions by modifying the function name.
If you have ideas/suggestions to improve these or create more such one
liner scripts, please let me know.
1) Script to display the backtrace from a given kernel function.
stap -e 'probe kernel.function("generic_make_request") { print_backtrace() }'
Output looks like:
0xffffffff8030a614 : generic_make_request+0x1/0x345 [kernel]
0xffffffff8030bc0e : submit_bio+0xc8/0xcf [kernel]
0xffffffff802ace12 : submit_bh+0xdc/0xfc [kernel] )
0xffffffff802ae7ea : __block_write_full_page+0x1c2/0x2b6 [kernel]
0xffffffff802b209d : blkdev_get_block+0x0/0x46 [kernel]
......................................................
2) Script to display the backtrace from a given kernel function, without the help of debug information.
stap --kmap=/proc/kallsyms -e 'probe kernel.function("generic_make_request") { print_backtrace() }'
Output looks like:
0xffffffff8030a614 : generic_make_request+0x1/0x345 [kernel]
0xffffffff8030bc0e : submit_bio+0xc8/0xcf [kernel]
0xffffffff802ace12 : submit_bh+0xdc/0xfc [kernel] )
0xffffffff802ae7ea : __block_write_full_page+0x1c2/0x2b6 [kernel]
0xffffffff802b209d : blkdev_get_block+0x0/0x46 [kernel]
......................................................
3) Script to display parameters and local variables of a given kernel function
stap -e 'probe kernel.function("vfs_read") { printf("%s \n", $$vars)}'
Output looks like:
file=0xffff81003b570300 buf=0x41afc0e0 count=0x20000 pos=0xffff810068095f50 ret=?
file=0xffff81003b570300 buf=0x41afc0e0 count=0x20000 pos=0xffff810068095f50 ret=?
4) Script to display return value of a given kernel function
stap -e 'probe kernel.function("vfs_read").return { printf("ret=%x \n",$return ) }'
Output looks like:
ret=189
ret=10
ret=8
5) Script to display local variable of given function at a given line number
stap -e 'probe kernel.statement("__dentry_open@fs/open.c:772") { printf("%s \n",$$locals) }'
Output looks like:
inode=0xffff81007e0ff118 error=0x0
inode=0xffff81007e0f3d18 error=0x0
inode=0xffff81007e0f3d18 error=0x0
inode=0xffff81007dc5ba18 error=0x0
inode=0xffff81007d575418 error=0x0
6) Script to view how values of local variables varies in a given function
stap -e 'probe kernel.statement("copy_strings@fs/exec.c:*") { printf("%s %s \n",$$locals, pp()) }'
Output Looks like:
kmapped_page=0xffffe200005faec0 kaddr=0xffff81001b568000 kpos=0x7fffffffe000 ret=? kernel.statement("copy_strings@fs/exec.c:412")
kmapped_page=0xffffe200005faec0 kaddr=0xffff81001b568000 kpos=0x7fffffffe000 ret=? kernel.statement("copy_strings@fs/exec.c:418")
kmapped_page=0xffffe200005faec0 kaddr=0xffff81001b568000 kpos=0x7fffffffe000 ret=? kernel.statement("copy_strings@fs/exec.c:419")
kmapped_page=0xffffe200005faec0 kaddr=0xffff81001b568000 kpos=0x7fffffffe000 ret=? kernel.statement("copy_strings@fs/exec.c:420")
kmapped_page=0xffffe200005faec0 kaddr=0xffff81001b568000 kpos=0x7fffffffe000 ret=? kernel.statement("copy_strings@fs/exec.c:422")
Thanks
Srinivasa DS
reply other threads:[~2008-09-11 4:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48C89D7D.3070105@in.ibm.com \
--to=srinivasa@in.ibm.com \
--cc=ananth@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maneesh@linux.vnet.ibm.com \
--cc=systemtap@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox