strace for mac

18 Jun 2015 08:55 | development | macOS

strace is really useful on Linux for figuring out why some program isn't doing
what it should.

Not sure how many people know this but you can do the same thing on darwin
using dtruss, it's just no quite so obvious.  Using this script:

with an alias that always run it as sudo:

alias strace="sudo strace"

you can then strace <binary> in exactly the same way that you can on linux.
One significant and mild annoyance is that it has to run as root, which is why
the script contains a bit of sudo hoop-jumping and exploit mitigation.  It's
very handy for watching the call stack when you need to though.