mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
* 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
This commit is contained in:
parent
9a968078bc
commit
93df5a0a90
3 changed files with 54 additions and 29 deletions
56
vm.c
56
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue