[macruby-changes] [2770] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Oct 8 20:17:35 PDT 2009


Revision: 2770
          http://trac.macosforge.org/projects/ruby/changeset/2770
Author:   lsansonetti at apple.com
Date:     2009-10-08 20:17:34 -0700 (Thu, 08 Oct 2009)
Log Message:
-----------
added raise dtrace probe

Modified Paths:
--------------
    MacRuby/trunk/dispatcher.cpp
    MacRuby/trunk/vm.cpp
    MacRuby/trunk/vm.h

Modified: MacRuby/trunk/dispatcher.cpp
===================================================================
--- MacRuby/trunk/dispatcher.cpp	2009-10-09 01:57:40 UTC (rev 2769)
+++ MacRuby/trunk/dispatcher.cpp	2009-10-09 03:17:34 UTC (rev 2770)
@@ -500,20 +500,6 @@
     return true;
 }
 
-static force_inline void
-symbolize(int delta, char *path, size_t pathlen, unsigned long *line)
-{
-    void *callstack[10];
-    const  int callstack_n = backtrace(callstack, 10);
-
-    if (callstack_n < delta
-	|| !GET_CORE()->symbolize_call_address(callstack[delta], NULL,
-	    path, pathlen, line, NULL, 0)) {
-	strncpy(path, "core", pathlen);
-	*line = 0;
-    }
-}
-
 static force_inline VALUE
 __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE self, Class klass,
 	SEL sel, rb_vm_block_t *block, unsigned char opt, int argc,
@@ -710,7 +696,8 @@
 	    char *method_name = (char *)sel_getName(sel);
 	    char file[PATH_MAX];
 	    unsigned long line = 0;
-	    symbolize(1, file, sizeof file, &line);
+	    GET_CORE()->symbolize_backtrace_entry(1, NULL, file, sizeof file,
+		    &line, NULL, 0);
 	    MACRUBY_METHOD_ENTRY(class_name, method_name, file, line);
 	}
 
@@ -723,7 +710,8 @@
 	    char *method_name = (char *)sel_getName(sel);
 	    char file[PATH_MAX];
 	    unsigned long line = 0;
-	    symbolize(1, file, sizeof file, &line);
+	    GET_CORE()->symbolize_backtrace_entry(1, NULL, file, sizeof file,
+		    &line, NULL, 0);
 	    MACRUBY_METHOD_RETURN(class_name, method_name, file, line);
 	}
 

Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp	2009-10-09 01:57:40 UTC (rev 2769)
+++ MacRuby/trunk/vm.cpp	2009-10-09 03:17:34 UTC (rev 2770)
@@ -37,6 +37,7 @@
 #include "vm.h"
 #include "compiler.h"
 #include "objc.h"
+#include "dtrace.h"
 
 #include <objc/objc-exception.h>
 
@@ -495,6 +496,27 @@
     return true;
 }
 
+void
+RoxorCore::symbolize_backtrace_entry(int index, void **startp, char *path,
+	size_t path_len, unsigned long *ln, char *name, size_t name_len)
+{
+    void *callstack[10];
+    const int callstack_n = backtrace(callstack, 10);
+
+    index++; // count us!
+
+    if (callstack_n < index
+	|| !GET_CORE()->symbolize_call_address(callstack[index], startp,
+		path, path_len, ln, name, name_len)) {
+	if (path != NULL) {
+	    strncpy(path, "core", path_len);
+	}
+	if (ln != NULL) {
+	    *ln = 0;
+	}
+    }
+}
+
 struct ccache *
 RoxorCore::constant_cache_get(ID path)
 {
@@ -2786,9 +2808,19 @@
 static inline void
 __vm_raise(void)
 {
+    VALUE rb_exc = GET_VM()->current_exception();
+    // DTrace probe: raise
+    if (MACRUBY_RAISE_ENABLED()) {
+	char *classname = (char *)rb_class2name(CLASS_OF(rb_exc));
+	char file[PATH_MAX];
+	unsigned long line = 0;
+	GET_CORE()->symbolize_backtrace_entry(2, NULL, file, sizeof file,
+		&line, NULL, 0);
+	MACRUBY_RAISE(classname, file, line);
+    } 
 #if __LP64__
     // In 64-bit, an Objective-C exception is a C++ exception.
-    id exc = rb_rb2oc_exception(GET_VM()->current_exception());
+    id exc = rb_rb2oc_exception(rb_exc);
     objc_exception_throw(exc);
 #else
     void *exc = __cxa_allocate_exception(0);

Modified: MacRuby/trunk/vm.h
===================================================================
--- MacRuby/trunk/vm.h	2009-10-09 01:57:40 UTC (rev 2769)
+++ MacRuby/trunk/vm.h	2009-10-09 03:17:34 UTC (rev 2770)
@@ -675,6 +675,10 @@
 		char *path, size_t path_len, unsigned long *ln,
 		char *name, size_t name_len);
 
+	void symbolize_backtrace_entry(int index, void **startp,
+		char *path, size_t path_len, unsigned long *ln,
+		char *name, size_t name_len);
+
 	struct mcache *method_cache_get(SEL sel, bool super);
 	rb_vm_method_node_t *method_node_get(IMP imp, bool create=false);
 	rb_vm_method_node_t *method_node_get(Method m, bool create=false);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091008/eb7286db/attachment-0001.html>


More information about the macruby-changes mailing list