summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-04-10 08:29:30 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-04-10 08:29:30 +0000
commit93df5a0a906587244feff91e2bc1eecb11e31d28 (patch)
tree8dbd35dbd1dedfce694f8d3da38cfb0cf6c28913 /vm.c
parent9a968078bc028c40159a9ee8b4683d9112e5d9b2 (diff)
* vm.c (vm_exec): check other events when RETURN is thrown.
[Bug #10724] * test/ruby/test_settracefunc.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/vm.c b/vm.c
index 15ec572..216d2b1 100644
--- a/vm.c
+++ b/vm.c
@@ -1317,6 +1317,30 @@ vm_frametype_name(const rb_control_frame_t *cfp)
}
#endif
+static void
+hook_before_rewind(rb_thread_t *th, rb_control_frame_t *cfp)
+{
+ switch (VM_FRAME_TYPE(th->cfp)) {
+ case VM_FRAME_MAGIC_METHOD:
+ RUBY_DTRACE_METHOD_RETURN_HOOK(th, 0, 0);
+ EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0, Qnil);
+ break;
+ case VM_FRAME_MAGIC_BLOCK:
+ case VM_FRAME_MAGIC_LAMBDA:
+ if (VM_FRAME_TYPE_BMETHOD_P(th->cfp)) {
+ EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
+ EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, th->cfp->me->called_id, th->cfp->me->klass, Qnil);
+ }
+ else {
+ EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
+ }
+ break;
+ case VM_FRAME_MAGIC_CLASS:
+ EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_END, th->cfp->self, 0, 0, Qnil);
+ break;
+ }
+}
+
/* evaluator body */
/* finish
@@ -1415,7 +1439,6 @@ vm_frametype_name(const rb_control_frame_t *cfp)
};
*/
-
static VALUE
vm_exec(rb_thread_t *th)
{
@@ -1486,15 +1509,9 @@ vm_exec(rb_thread_t *th)
}
}
if (!catch_iseqval) {
- result = THROW_DATA_VAL(err);
th->errinfo = Qnil;
-
- switch (VM_FRAME_TYPE(cfp)) {
- case VM_FRAME_MAGIC_LAMBDA:
- EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
- break;
- }
-
+ result = THROW_DATA_VAL(err);
+ hook_before_rewind(th, th->cfp);
vm_pop_frame(th);
goto finish_vme;
}
@@ -1638,26 +1655,7 @@ vm_exec(rb_thread_t *th)
}
else {
/* skip frame */
-
- switch (VM_FRAME_TYPE(th->cfp)) {
- case VM_FRAME_MAGIC_METHOD:
- RUBY_DTRACE_METHOD_RETURN_HOOK(th, 0, 0);
- EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0, Qnil);
- break;
- case VM_FRAME_MAGIC_BLOCK:
- case VM_FRAME_MAGIC_LAMBDA:
- if (VM_FRAME_TYPE_BMETHOD_P(th->cfp)) {
- EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
- EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, th->cfp->me->called_id, th->cfp->me->klass, Qnil);
- }
- else {
- EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil);
- }
- break;
- case VM_FRAME_MAGIC_CLASS:
- EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_END, th->cfp->self, 0, 0, Qnil);
- break;
- }
+ hook_before_rewind(th, th->cfp);
if (VM_FRAME_TYPE_FINISH_P(th->cfp)) {
vm_pop_frame(th);