A example erlang port driver repo
$ git clone https://github.com/ruanpienaar/erlang_interopt_tutorial
$ make
$ ./start-dev.sh
erl> complex1:start(code:priv_dir(erlang_interopt_tutorial)++"/extprg1").
erl> complex1:foo(1).
$ sudo dtrace -F -s extprg1_trace.d
erl> complex1:foo(1).
$ sudo dtrace -F -s dtrace_extprg1_pid.d `ps aux | grep extprg1 | grep -v grep | awk '{print $2 }'`
erl> complex1:foo(1).
$ ./start-dev.sh
erl> complex2:start(code:priv_dir(erlang_interopt_tutorial)++"/extprg2").
erl> complex2:foo(3).
$ sudo dtrace -F -s extprg2_trace.d
erl> complex2:foo(3).
$ sudo dtrace -F -s dtrace_extprg2_pid.d `ps aux | grep extprg2 | grep -v grep | awk '{print $2 }'`
erl> complex2:foo(3).
$ ./start-dev.sh
erl> complex5:start("example_drv").
erl> complex5:foo(3).
$ sudo dtrace -n 'pid$target:beam.smp:*driver*:entry { trace(execname) }' -p `ps aux | grep beam.smp | grep erlang_interopt_tutorial | awk '{ print $2 }'`
OR
$ PID=`ps aux | grep beam.smp | grep erlang_interopt_tutorial | awk '{ print $2 }'` && sudo dtrace -x ustackframes=100 -n 'pid$target:beam.smp:*driver*:entry /pid== '"${PID}"'/ { ustack(); }' -p $PID
$ ./priv/cserver 3456
$ ./start-dev.sh
erl> complex3:foo(3).
$ sudo dtrace -F -s dtrace_cserver.d
$ ./priv/cserver2 3456
$ ./start-dev.sh
erl> complex3:foo(3).
$ ./priv/cserver 3456
$ sudo dtrace -F -s dtrace_cserver_pid.d -p `ps aux | grep cserver | grep -v grep | awk '{print $2 }'`
$ ./start-dev.sh
erl> complex3:foo(3).
$ ./priv/cserver2 3456
$ ./start-dev.sh
erl> complex4:foo(3).
$ sudo dtrace -F -s dtrace_cserver2.d
$ ./priv/cserver2 3456
$ ./start-dev.sh
erl> complex4:foo(3).
( TODO: not working at the mo... )
$ ./priv/cserver2 3456
$ sudo dtrace -F -s dtrace_cserver2_pid.d -p `ps aux | grep cserver2 | grep -v grep | awk '{print $2 }'`
$ ./start-dev.sh
erl> complex4:foo(3).
$ ./start-sname-cnode.sh
$ ./priv/cclient
erl> complex3:foo(3).
$ sudo dtrace -F -s dtrace_cclient.d
$ ./start-sname-cnode.sh
$ ./priv/cclient
( TODO: also not working at the mo... )
$ ./start-sname-cnode.sh
$ ./priv/cclient
$ sudo dtrace -F -s dtrace_cclient_pid.d -p `ps aux | grep cclient | grep -v grep | awk '{print $2 }'`
$ ./start-dev.sh
erl> complex6:foo(2).
( TODO: trace driver and nif, it seems the NIF uses some driver stuff )
$ ./start-dev.sh
$ PID=`ps aux | grep beam.smp | grep erlang_interopt_tutorial | awk '{ print $2 }'` && sudo dtrace -x ustackframes=100 -n 'pid$target:beam.smp:*nif*:entry /pid== '"${PID}"'/ { ustack(); }' -p $PID
erl> complex6:foo(2).