Missing strace on Darwin
From Ben's Writing
I've been switching between three OS on a daily basis for a number of years now, and my mind seems increasingly less capable of remembering all the different commands that give roughly the same functionality. One of the Linux tools I've found to be very helpful is strace, but, go figure, it is not available on OS X. Fortunately, there are a number of options. Some are far more advanced and flexible, like dtrace, others like ktrace are too primitive. There is one tool, however, that does provide a nice in-between tool: dtruss.
There are a number of ways to use dtruss, here are a few simple strace likes ones:
- Run and examine the df -h command
dtruss df -h
- Examine proces 1871 and follow any of its children
dtruss -p 1871 -f
- Examine all processes called "tar"
dtruss -n tar
- Print stack backtrace for a broken program
dtruss -s segfaulter
Sadly, it seems running dtruss requires super user access, so you'll need to prefix the above commands with sudo. Alternatively, you can change the file's group to staff and update the file's permissions:
sudo chmod 2555 `which dtruss` sudo chgrp staff `which truss`
UPDATE: Well, that seems like it should have worked, so I must be missing something simple about OS X security. Good thing though, it is probably not a good idea to give a program like such a high level of unrestricted security access anyway, as a clever user could use it to abuse your system.