summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--vm.c19
-rw-r--r--vm_core.h2
-rw-r--r--vm_eval.c5
4 files changed, 20 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 89b3995144..0d79cfb915 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
-Sun Aug 16 09:47:29 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Aug 16 10:38:23 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * vm_dump.c (bugreport_backtrace): rb_backtrace_iter_func now
- takes VALUE as file and method names.
+ * vm.c (vm_backtrace_each, vm_backtrace_push),
+ vm_eval.c (print_backtrace), vm_dump.c (bugreport_backtrace):
+ rb_backtrace_iter_func now takes VALUE as file and method names.
Sun Aug 16 03:06:59 2009 Koichi Sasada <ko1@atdot.net>
diff --git a/vm.c b/vm.c
index 8a9fb046a1..36a9776864 100644
--- a/vm.c
+++ b/vm.c
@@ -712,7 +712,7 @@ vm_backtrace_each(rb_thread_t *th, int lev, rb_backtrace_iter_func *iter, void *
{
const rb_control_frame_t *limit_cfp = th->cfp;
const rb_control_frame_t *cfp = (void *)(th->stack + th->stack_size);
- const char *file = "ruby";
+ VALUE file = Qnil;
int line_no = 0;
cfp -= 2;
@@ -722,19 +722,20 @@ vm_backtrace_each(rb_thread_t *th, int lev, rb_backtrace_iter_func *iter, void *
}
}
limit_cfp = RUBY_VM_NEXT_CONTROL_FRAME(limit_cfp);
- if (th->vm->progname) file = RSTRING_PTR(th->vm->progname);
+ if (th->vm->progname) file = th->vm->progname;
while (cfp > limit_cfp) {
if (cfp->iseq != 0) {
if (cfp->pc != 0) {
rb_iseq_t *iseq = cfp->iseq;
line_no = rb_vm_get_sourceline(cfp);
- file = RSTRING_PTR(iseq->filename);
- if ((*iter)(arg, file, line_no, RSTRING_PTR(iseq->name))) break;
+ file = iseq->filename;
+ if ((*iter)(arg, file, line_no, iseq->name)) break;
}
}
else if (RUBYVM_CFUNC_FRAME_P(cfp)) {
- if ((*iter)(arg, file, line_no, rb_id2name(cfp->me->original_id))) break;
+ if (NIL_P(file)) file = rb_str_new_cstr("ruby");
+ if ((*iter)(arg, file, line_no, rb_id2str(cfp->me->original_id))) break;
}
cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp);
}
@@ -742,13 +743,17 @@ vm_backtrace_each(rb_thread_t *th, int lev, rb_backtrace_iter_func *iter, void *
}
static int
-vm_backtrace_push(void *arg, const char *file, int line_no, const char *name)
+vm_backtrace_push(void *arg, VALUE file, int line_no, VALUE name)
{
VALUE *aryp = arg;
+ VALUE bt;
+
if (!*aryp) {
*aryp = rb_ary_new();
}
- rb_ary_push(*aryp, rb_sprintf("%s:%d:in `%s'", file, line_no, name));
+ bt = rb_enc_sprintf(rb_enc_compatible(file, name), "%s:%d:in `%s'",
+ RSTRING_PTR(file), line_no, RSTRING_PTR(name));
+ rb_ary_push(*aryp, bt);
return 0;
}
diff --git a/vm_core.h b/vm_core.h
index fe7bcacfa7..40b9933473 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -588,7 +588,7 @@ VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
int ruby_thread_has_gvl_p(void);
VALUE rb_make_backtrace(void);
-typedef int rb_backtrace_iter_func(void *, const char *, int, const char *);
+typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
VALUE rb_backtrace_each(rb_backtrace_iter_func *iter, void *arg);
rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
diff --git a/vm_eval.c b/vm_eval.c
index 6d7c84f7b9..8784b88d7b 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1345,9 +1345,10 @@ rb_f_caller(int argc, VALUE *argv)
}
static int
-print_backtrace(void *arg, const char *file, int line, const char *method)
+print_backtrace(void *arg, VALUE file, int line, VALUE method)
{
- fprintf((FILE *)arg, "\tfrom %s:%d:in `%s'\n", file, line, method);
+ fprintf((FILE *)arg, "\tfrom %s:%d:in `%s'\n",
+ RSTRING_PTR(file), line, RSTRING_PTR(method));
return Qfalse;
}