function boundary tracing in OSX w/ DTrace
<p>I'm having an awfully hard time trying to trace all functions with dtrace (or dapptrace) in OSX 10.11.3.</p>

<p>From <a href="https://docs.oracle.com/cd/E18752_01/html/819-5488/gcgkk.html#gcglh" rel="nofollow">this page</a> on dtrace (dated 2006), it looks like this simple script should be useful for tracing function entry and exit:</p>

<pre><code>pid$1::$2:entry
{
    self-&gt;trace = 1;
}

pid$1::$2:return
/self-&gt;trace/
{
    self-&gt;trace = 0;
}

pid$1:::entry,
pid$1:::return
/self-&gt;trace/
{
}
</code></pre>

<p>How can I run this against a short lived program, like hello world to start?  I would have guessed:</p>

<pre><code>➜ sudo dtrace -s userfunc.d

dtrace: failed to compile script userfunc.d: line 1: invalid probe description "pid$1::$2:entry": Undefined macro variable in probe description
➜ sudo dtrace -s userfunc.d -c a.out

dtrace: failed to execute a.out: file is set-id or unreadable [Note: the '-c' option requires a full pathname to the file]

➜ sudo dtrace -s userfunc.d -c `pwd`/a.out

dtrace: failed to compile script userfunc.d: line 1: invalid probe description "pid$1::$2:entry": Undefined macro variable in probe description
➜ sudo dtrace -s userfunc.d -c `pwd`/a.out execute

dtrace: failed to compile script userfunc.d: line 1: invalid probe description "pid$1::$2:entry": Undefined macro variable in probe description
</code></pre>

<p>The second example tracing libc works if I change the reference to libc.so to libsystem_c.dylib.</p>

<p>It appears that dapptrace fails as well.</p>

<pre><code>➜ sudo dapptrace ./a.out
dtrace: invalid probe specifier
...
: probe description pid16290:a.out::entry does not match any probes
</code></pre>

<p>Adding <code>-U</code> prints a whole lot of garbage, not sure if it's even useful (didn't see my call to puts, or any fprintf or write).</p>

<p>Now I know that DTrace and in particular dtruss are definitely not broken in OSX.  What am I doing wrong?</p>