static void set_backtrace(VALUE info, VALUE bt) { ID set_backtrace = rb_intern("set_backtrace"); if (rb_backtrace_p(bt)) { if (rb_method_basic_definition_p(CLASS_OF(info), set_backtrace)) { rb_exc_set_backtrace(info, bt); return; } else { bt = rb_backtrace_to_str_ary(bt); } } rb_check_funcall(info, set_backtrace, 1, &bt); }
static void raise_argument_error(rb_thread_t *th, const rb_iseq_t *iseq, const VALUE exc) { VALUE at; if (iseq) { vm_push_frame(th, iseq, VM_FRAME_MAGIC_DUMMY, Qnil /* self */, VM_ENVVAL_BLOCK_PTR(0) /* specval*/, Qfalse /* me or cref */, iseq->body->iseq_encoded, th->cfp->sp, 1 /* local_size (cref/me) */, 0 /* stack_max */); at = rb_vm_backtrace_object(); vm_pop_frame(th); } else { at = rb_vm_backtrace_object(); } rb_ivar_set(exc, idBt_locations, at); rb_exc_set_backtrace(exc, at); rb_exc_raise(exc); }