aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-25 09:35:03 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-25 09:35:03 +0000
commit485e6ebed846fd77e273177e07348a72786c1d97 (patch)
tree4c262d85ee69ed336c9446b830287a86d684f2bf /vm_insnhelper.c
parent053b5d0f9ce1f8e062459e4841412d3c550e5413 (diff)
downloadruby-485e6ebed846fd77e273177e07348a72786c1d97.tar.gz
* vm_insnhelper.c (argument_error): insert dummy frame to make
a backtrace object intead of modify backtrace string array. [Bug #9295] * test/ruby/test_backtrace.rb: add a test for this patch. fix test to compare a result of Exception#backtrace with a result of Exception#backtrace_locations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 99b0c75645..c8cbaa07bf 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -126,20 +126,22 @@ NORETURN(static void argument_error(const rb_iseq_t *iseq, int miss_argc, int mi
static void
argument_error(const rb_iseq_t *iseq, int miss_argc, int min_argc, int max_argc)
{
+ rb_thread_t *th = GET_THREAD();
VALUE exc = rb_arg_error_new(miss_argc, min_argc, max_argc);
- VALUE bt = rb_make_backtrace();
- VALUE err_line = 0;
+ VALUE at;
if (iseq) {
- int line_no = FIX2INT(rb_iseq_first_lineno(iseq->self));
-
- err_line = rb_sprintf("%s:%d:in `%s'",
- RSTRING_PTR(iseq->location.path),
- line_no, RSTRING_PTR(iseq->location.label));
- rb_funcall(bt, rb_intern("unshift"), 1, err_line);
+ vm_push_frame(th, iseq, VM_FRAME_MAGIC_METHOD, Qnil /* self */, Qnil /* klass */, Qnil /* specval*/,
+ iseq->iseq_encoded, th->cfp->sp, 0 /* local_size */, 0 /* me */, 0 /* stack_max */);
+ at = rb_vm_backtrace_object();
+ vm_pop_frame(th);
+ }
+ else {
+ at = rb_vm_backtrace_object();
}
- rb_funcall(exc, rb_intern("set_backtrace"), 1, bt);
+ rb_iv_set(exc, "bt_locations", at);
+ rb_funcall(exc, rb_intern("set_backtrace"), 1, at);
rb_exc_raise(exc);
}