public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [RFC] Some Interesting one liner systemtap scripts
@ 2008-09-11  4:25 Srinivasa DS
  0 siblings, 0 replies; only message in thread
From: Srinivasa DS @ 2008-09-11  4:25 UTC (permalink / raw)
  To: Linux Kernel, systemtap, Ananth Mavinakayanahalli, Maneesh Soni

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-11  4:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-11  4:25 [RFC] Some Interesting one liner systemtap scripts Srinivasa DS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).