summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-25 18:28:21 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-25 18:28:21 +0000
commitca050a8d57a771d24de2cdf3e3d56e5ff6bc278c (patch)
tree622e3cffb084e4574e83d35aeb64afc6d319ace2 /vm_insnhelper.c
parent5fd508805288d9f9f5f3a8025e76200698420c89 (diff)
merge revision(s) 44411: [Backport #9295]
* 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/branches/ruby_2_1@44431 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);
}