save lastpc on exception and use it in mruby stack trace

This commit is contained in:
Yukihiro Matz Matsumoto
2012-12-12 18:23:20 +09:00
parent f63d5c2905
commit fd12f87712
3 changed files with 31 additions and 10 deletions
+5 -2
View File
@@ -920,8 +920,9 @@ mrb_obj_public_methods(mrb_state *mrb, mrb_value self)
mrb_value
mrb_f_raise(mrb_state *mrb, mrb_value self)
{
mrb_value a[2];
mrb_value a[2], exc;
int argc;
argc = mrb_get_args(mrb, "|oo", &a[0], &a[1]);
switch (argc) {
@@ -936,7 +937,9 @@ mrb_f_raise(mrb_state *mrb, mrb_value self)
}
/* fall through */
default:
mrb_exc_raise(mrb, mrb_make_exception(mrb, argc, a));
exc = mrb_make_exception(mrb, argc, a);
mrb_obj_iv_set(mrb, mrb_obj_ptr(exc), mrb_intern(mrb, "lastpc"), mrb_voidp_value(mrb->ci->pc));
mrb_exc_raise(mrb, exc);
}
return mrb_nil_value(); /* not reached */
}
+1
View File
@@ -1151,6 +1151,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
int eidx;
L_RAISE:
mrb_obj_iv_ifnone(mrb, mrb->exc, mrb_intern(mrb, "lastpc"), mrb_voidp_value(pc));
ci = mrb->ci;
eidx = mrb->ci->eidx;
if (ci == mrb->cibase) goto L_STOP;