[macruby-changes] [647] MacRuby/trunk/sample-macruby/DTrace/collected_objects.d
source_changes at macosforge.org
source_changes at macosforge.org
Mon Oct 6 19:04:06 PDT 2008
Revision: 647
http://trac.macosforge.org/projects/ruby/changeset/647
Author: lsansonetti at apple.com
Date: 2008-10-06 19:04:06 -0700 (Mon, 06 Oct 2008)
Log Message:
-----------
adding another dtrace example
Added Paths:
-----------
MacRuby/trunk/sample-macruby/DTrace/collected_objects.d
Added: MacRuby/trunk/sample-macruby/DTrace/collected_objects.d
===================================================================
--- 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 at d\n", @);
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20081006/a325d6a3/attachment.html
More information about the macruby-changes
mailing list