#!/usr/sbin/dtrace -s #pragma D option quiet /* Usage: sudo ./trace_msg_send -p PID ClassNamePartial * * E.g. messages send to Xcode classes that start with `DVTiPhoneSimulator`: * * $ sudo ./trace_msg_send -p $(pgrep '^Xcode$') DVTiPhoneSimulator */ /* From: http://stackoverflow.com/questions/16238845/show-objective-c-class-in-dtrace-output/16242756#16242756 */ unsigned long long indention; int indentation_amount; BEGIN { indentation_amount = 4; } objc$target:$1::entry { method = (string)&probefunc[1]; type = probefunc[0]; class = probemod; printf("%*s%s %c[%s %s]\n", indention * indentation_amount, "", "->", type, class, method); indention++; } objc$target:$1::return { indention--; method = (string)&probefunc[1]; type = probefunc[0]; class = probemod; printf("%*s%s %c[%s %s]\n", indention * indentation_amount, "", "<-", type, class, method); }