How to trace system calls of a program in Mac OS X?

Michaël Le Barbier picture Michaël Le Barbier · Jun 25, 2015 · Viewed 56.3k times · Source

I wanted to trace the system calls made by the find command to debug some performance issues however I could not figure out how to do this on Mac OS X Yosemite. How can I trace system calls for an arbitrary program similarly to what strace does on FreeBSD? I am especially interested in tracing file-system related calls.

Answer

jspcal picture jspcal · Jun 25, 2015

You can use dtruss like in

sudo dtruss find ~/repo -depth 2 -type d -name '.git'

The manual page of that utility will help you to tailor the use of the tool to your needs.