Sunday, December 6, 2009

dtrace rocks!

Starting from Leopard, Apple brought DTrace into OS X and replaced the old STrace. It runs in kernel space and is super powerful. Here is a good tutorial.

Some notes,
1. To use strace style Dtrace, run 'dtruss'
2. An example to debug mount problem (from here)
dtrace -n 'syscall::mount:entry { printf("%s %s %s", copyinstr(arg0), copyinstr(arg1), copyinstr(arg3)) } syscall::mount:return { printf("%s %d %d", execname, (int) arg1, errno) }'