[macruby-changes] [2564] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Sep 18 12:37:43 PDT 2009


Revision: 2564
          http://trac.macosforge.org/projects/ruby/changeset/2564
Author:   lsansonetti at apple.com
Date:     2009-09-18 12:37:40 -0700 (Fri, 18 Sep 2009)
Log Message:
-----------
more backtracing love

Modified Paths:
--------------
    MacRuby/trunk/eval.c
    MacRuby/trunk/vm.cpp
    MacRuby/trunk/vm.h

Modified: MacRuby/trunk/eval.c
===================================================================
--- MacRuby/trunk/eval.c	2009-09-18 08:30:41 UTC (rev 2563)
+++ MacRuby/trunk/eval.c	2009-09-18 19:37:40 UTC (rev 2564)
@@ -777,8 +777,8 @@
     rb_objc_define_module_function(rb_mKernel, "iterator?", rb_f_block_given_p, 0);
     rb_objc_define_module_function(rb_mKernel, "block_given?", rb_f_block_given_p, 0);
 
+    rb_objc_define_module_function(rb_mKernel, "fail", rb_f_raise, -1);
     rb_objc_define_module_function(rb_mKernel, "raise", rb_f_raise, -1);
-    rb_objc_define_module_function(rb_mKernel, "fail", rb_f_raise, -1);
 
     rb_objc_define_module_function(rb_mKernel, "global_variables", rb_f_global_variables, 0);	/* in variable.c */
     rb_objc_define_module_function(rb_mKernel, "local_variables", rb_f_local_variables, 0);

Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp	2009-09-18 08:30:41 UTC (rev 2563)
+++ MacRuby/trunk/vm.cpp	2009-09-18 19:37:40 UTC (rev 2564)
@@ -544,10 +544,23 @@
 }
 
 inline rb_vm_method_node_t *
-RoxorCore::method_node_get(IMP imp)
+RoxorCore::method_node_get(IMP imp, bool create)
 {
+    rb_vm_method_node_t *n;
     std::map<IMP, rb_vm_method_node_t *>::iterator iter = ruby_imps.find(imp);
-    return iter == ruby_imps.end() ? NULL : iter->second;
+    if (iter == ruby_imps.end()) {
+	if (create) {
+	    n = (rb_vm_method_node_t *)malloc(sizeof(rb_vm_method_node_t));
+	    ruby_imps[imp] = n;
+	}
+	else {
+	    n = NULL;
+	}
+    }
+    else {
+	n = iter->second;
+    }
+    return n;
 }
 
 inline rb_vm_method_node_t *
@@ -4559,7 +4572,14 @@
 	if (GET_CORE()->symbolize_call_address(callstack[i], NULL,
 		    path, sizeof path, &ln, name, sizeof name)) {
 	    char entry[PATH_MAX];
-	    snprintf(entry, sizeof entry, "%s:%ld:in `%s'", path, ln, name);
+	    if (ln == 0) {
+		snprintf(entry, sizeof entry, "%s:in `%s'",
+			path, name);
+	    }
+	    else {
+		snprintf(entry, sizeof entry, "%s:%ld:in `%s'",
+			path, ln, name);
+	    }
 	    rb_ary_push(ary, rb_str_new2(entry));
 	}
     }
@@ -4649,14 +4669,21 @@
 	std::terminate();
     }
 
-    static SEL sel_message = 0;
-    if (sel_message == 0) {
-	sel_message = sel_registerName("message");
+    VALUE message = rb_vm_call(exc, sel_registerName("message"), 0, NULL,
+	    false);
+    VALUE bt = rb_vm_call(exc, sel_registerName("backtrace"), 0, NULL,
+	    false);
+
+    for (long i = 0, count = RARRAY_LEN(bt); i < count; i++) {
+	const char *bte = RSTRING_PTR(RARRAY_AT(bt, i));
+	if (i == 0) {
+	    printf("%s: %s (%s)\n", bte, RSTRING_PTR(message),
+		    rb_class2name(*(VALUE *)exc));
+	}
+	else {
+	    printf("\t%s\n", bte);
+	}
     }
-
-    VALUE message = rb_vm_call(exc, sel_message, 0, NULL, false);
-
-    printf("%s (%s)\n", RSTRING_PTR(message), rb_class2name(*(VALUE *)exc));
 }
 
 extern "C"
@@ -4768,6 +4795,14 @@
     }
 #else
     IMP imp = GET_CORE()->compile(function);
+
+    // For symbolication.
+    rb_vm_method_node_t *mnode = GET_CORE()->method_node_get(imp, true);
+    mnode->arity = rb_vm_arity(2);
+    mnode->sel = sel_registerName("<main>");
+    mnode->objc_imp = mnode->ruby_imp = imp;
+    mnode->flags = 0;
+    
     return ((VALUE(*)(VALUE, SEL))imp)(vm->get_current_top_object(), 0);
 #endif
 }

Modified: MacRuby/trunk/vm.h
===================================================================
--- MacRuby/trunk/vm.h	2009-09-18 08:30:41 UTC (rev 2563)
+++ MacRuby/trunk/vm.h	2009-09-18 19:37:40 UTC (rev 2564)
@@ -674,7 +674,7 @@
 		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);
+	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);
 
 	rb_vm_method_source_t *method_source_get(Class klass, SEL sel);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090918/83e8179f/attachment.html>


More information about the macruby-changes mailing list