Macs, Modularity and More

Using DTrace to find out callstack

Mac OSX has supported dtrace since 10.5, and it's pretty powerful stuff (as long as you're not running iTunes or QuickTime). You need to be root in order to be able to run it, but there's plenty of sample scripts in /usr/bin which end in .d that you can look at.

As part of trying to add Spotlight support to ZFS, I needed to check whether the add_fsevent was being called for ZFS mounted. Fortunately, it's part of the kernel and exported by the fbt provider, so we can find out when and where it's running. This gives us the opportunity to use the stack() primitive to generate the stack of what's being called: