From eceab0132acc277b4b8fbb05049aa2610417a468 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 3 Dec 2019 16:39:54 -0800 Subject: [PATCH] Allow tracing attr_reader/attr_reader method calls These methods are implemented in C, so this uses :c_call and :c_return instead of :call and :return. Fixes [Bug #16383] --- vm_insnhelper.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 1c54de6375..c6708a9837 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2542,19 +2542,27 @@ static VALUE vm_call_ivar(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd) { struct rb_call_cache *cc = &cd->cc; + VALUE ret; RB_DEBUG_COUNTER_INC(ccf_ivar); cfp->sp -= 1; - return vm_getivar(calling->recv, cc->me->def->body.attr.id, NULL, cc, TRUE); + EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_CALL, calling->recv, cc->me->def->body.attr.id, cd->ci.mid, cc->me->owner, Qundef); + ret = vm_getivar(calling->recv, cc->me->def->body.attr.id, NULL, cc, TRUE); + EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_RETURN, calling->recv, cc->me->def->body.attr.id, cd->ci.mid, cc->me->owner, ret); + return ret; } static VALUE vm_call_attrset(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, struct rb_call_data *cd) { struct rb_call_cache *cc = &cd->cc; + VALUE ret; RB_DEBUG_COUNTER_INC(ccf_attrset); VALUE val = *(cfp->sp - 1); cfp->sp -= 2; - return vm_setivar(calling->recv, cc->me->def->body.attr.id, val, NULL, cc, 1); + EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_CALL, calling->recv, cc->me->def->body.attr.id, cd->ci.mid, cc->me->owner, Qundef); + ret = vm_setivar(calling->recv, cc->me->def->body.attr.id, val, NULL, cc, 1); + EXEC_EVENT_HOOK(ec, RUBY_EVENT_C_RETURN, calling->recv, cc->me->def->body.attr.id, cd->ci.mid, cc->me->owner, ret); + return ret; } static inline VALUE -- 2.23.0