Revision
647
Author
lsansonetti@apple.com
Date
2008-10-06 19:04:06 -0700 (Mon, 06 Oct 2008)

Log Message

adding another dtrace example

Added Paths

Diff

Added: MacRuby/trunk/sample-macruby/DTrace/collected_objects.d (0 => 647)


--- MacRuby/trunk/sample-macruby/DTrace/collected_objects.d	                        (rev 0)
+++ MacRuby/trunk/sample-macruby/DTrace/collected_objects.d	2008-10-07 02:04:06 UTC (rev 647)
@@ -0,0 +1,28 @@
+#!/usr/sbin/dtrace -s
+
+#pragma D option quiet
+
+BEGIN
+{
+    printf("Target pid: %d\n\n", $target);
+}
+
+objc$target::-finalize:entry
+{
+    /* Thanks http://www.friday.com/bbum/2008/01/26/objective-c-printing-class-name-from-dtrace/ 
+     * TODO does not work in 64-bit
+     */
+    isaptr = *(uint32_t *)copyin(arg0, 4);
+    classnameptr = *(uint32_t *)copyin(isaptr + 8, 4);
+    classname = copyinstr(classnameptr);
+
+    @[classname] = count();
+}
+
+END
+{
+    printf("\n");
+    printf("%50s       %-10s\n", "CLASS", "COUNT");
+    printf("--------------------------------------------------------------------------------\n");
+    printa("%50s       %-10@d\n", @);
+}