ruby-changes:44520
From: ktsj <ko1@a...>
Date: Sat, 5 Nov 2016 22:15:33 +0900 (JST)
Subject: [ruby-changes:44520] ktsj:r56593 (trunk): * vm_trace.c (tracepoint_attr_callee_id, rb_tracearg_callee_id):
ktsj 2016-11-05 22:15:27 +0900 (Sat, 05 Nov 2016) New Revision: 56593 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56593 Log: * vm_trace.c (tracepoint_attr_callee_id, rb_tracearg_callee_id): add TracePoint#callee_id. [ruby-core:77241] [Feature #12747] * cont.c, eval.c, gc.c, include/ruby/intern.h, insns.def, thread.c, vm.c, vm_backtrace.c, vm_core.h, vm_eval.c, vm_insnhelper.c, vm_trace.c: ditto. * test/ruby/test_settracefunc.rb: tests for above. Modified files: trunk/ChangeLog trunk/NEWS trunk/cont.c trunk/eval.c trunk/gc.c trunk/include/ruby/intern.h trunk/insns.def trunk/test/ruby/test_settracefunc.rb trunk/thread.c trunk/vm.c trunk/vm_backtrace.c trunk/vm_core.h trunk/vm_eval.c trunk/vm_insnhelper.c trunk/vm_trace.c Index: vm_backtrace.c =================================================================== --- vm_backtrace.c (revision 56592) +++ vm_backtrace.c (revision 56593) @@ -1088,7 +1088,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L1088 get_klass(const rb_control_frame_t *cfp) { VALUE klass; - if (rb_vm_control_frame_id_and_class(cfp, 0, &klass)) { + if (rb_vm_control_frame_id_and_class(cfp, 0, 0, &klass)) { if (RB_TYPE_P(klass, T_ICLASS)) { return RBASIC(klass)->klass; } Index: eval.c =================================================================== --- eval.c (revision 56592) +++ eval.c (revision 56593) @@ -563,7 +563,7 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L563 if (tag != TAG_FATAL) { RUBY_DTRACE_HOOK(RAISE, rb_obj_classname(th->errinfo)); - EXEC_EVENT_HOOK(th, RUBY_EVENT_RAISE, th->cfp->self, 0, 0, mesg); + EXEC_EVENT_HOOK(th, RUBY_EVENT_RAISE, th->cfp->self, 0, 0, 0, mesg); } } @@ -749,7 +749,7 @@ rb_raise_jump(VALUE mesg, VALUE cause) https://github.com/ruby/ruby/blob/trunk/eval.c#L749 ID mid = me->called_id; rb_vm_pop_frame(th); - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, self, me->def->original_id, klass, Qnil); + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, self, me->def->original_id, mid, klass, Qnil); setup_exception(th, TAG_RAISE, mesg, cause); Index: cont.c =================================================================== --- cont.c (revision 56592) +++ cont.c (revision 56593) @@ -1284,7 +1284,7 @@ rb_fiber_start(void) https://github.com/ruby/ruby/blob/trunk/cont.c#L1284 th->root_svar = Qfalse; fib->status = RUNNING; - EXEC_EVENT_HOOK(th, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, Qnil); + EXEC_EVENT_HOOK(th, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil); cont->value = rb_vm_invoke_proc(th, proc, argc, argv, VM_BLOCK_HANDLER_NONE); } TH_POP_TAG(); @@ -1474,7 +1474,7 @@ fiber_switch(rb_fiber_t *fib, int argc, https://github.com/ruby/ruby/blob/trunk/cont.c#L1474 value = fiber_store(fib, th); RUBY_VM_CHECK_INTS(th); - EXEC_EVENT_HOOK(th, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, Qnil); + EXEC_EVENT_HOOK(th, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil); return value; } Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 56592) +++ vm_insnhelper.c (revision 56593) @@ -1739,7 +1739,7 @@ vm_call_cfunc_with_frame(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1739 int argc = calling->argc; RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, me->def->original_id); - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->def->original_id, me->owner, Qundef); + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->def->original_id, ci->mid, me->owner, Qundef); vm_push_frame(th, NULL, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv, block_handler, (VALUE)me, @@ -1757,7 +1757,7 @@ vm_call_cfunc_with_frame(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1757 rb_vm_pop_frame(th); - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->def->original_id, me->owner, val); + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->def->original_id, ci->mid, me->owner, val); RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->def->original_id); return val; Index: gc.c =================================================================== --- gc.c (revision 56592) +++ gc.c (revision 56593) @@ -1755,7 +1755,7 @@ rb_objspace_set_event_hook(const rb_even https://github.com/ruby/ruby/blob/trunk/gc.c#L1755 static void gc_event_hook_body(rb_thread_t *th, rb_objspace_t *objspace, const rb_event_flag_t event, VALUE data) { - EXEC_EVENT_HOOK(th, event, th->cfp->self, 0, 0, data); + EXEC_EVENT_HOOK(th, event, th->cfp->self, 0, 0, 0, data); } #define gc_event_hook_available_p(objspace) ((objspace)->flags.has_hook) Index: ChangeLog =================================================================== --- ChangeLog (revision 56592) +++ ChangeLog (revision 56593) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Nov 5 22:11:33 2016 Kazuki Tsujimoto <kazuki@c...> + + * vm_trace.c (tracepoint_attr_callee_id, rb_tracearg_callee_id): + add TracePoint#callee_id. [ruby-core:77241] [Feature #12747] + + * cont.c, eval.c, gc.c, include/ruby/intern.h, insns.def, thread.c, + vm.c, vm_backtrace.c, vm_core.h, vm_eval.c, vm_insnhelper.c, vm_trace.c: ditto. + + * test/ruby/test_settracefunc.rb: tests for above. + Sat Nov 5 22:09:48 2016 Kazuki Tsujimoto <kazuki@c...> * eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: Index: insns.def =================================================================== --- insns.def (revision 56592) +++ insns.def (revision 56593) @@ -831,7 +831,7 @@ trace https://github.com/ruby/ruby/blob/trunk/insns.def#L831 } } - EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0 /* id and klass are resolved at callee */, + EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0, 0 /* id and klass are resolved at callee */, (flag & (RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN)) ? TOPN(0) : Qundef); } Index: NEWS =================================================================== --- NEWS (revision 56592) +++ NEWS (revision 56593) @@ -160,6 +160,10 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L160 * Thread#report_on_exception and Thread.report_on_exception [Feature #6647] +* TracePoint + + * TracePoint#callee_id [Feature #12747] + * Warning * New module named Warning is introduced. By default it has only Index: vm_core.h =================================================================== --- vm_core.h (revision 56592) +++ vm_core.h (revision 56593) @@ -1420,7 +1420,7 @@ RUBY_SYMBOL_EXPORT_BEGIN https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1420 VALUE rb_iseq_eval(const rb_iseq_t *iseq); VALUE rb_iseq_eval_main(const rb_iseq_t *iseq); RUBY_SYMBOL_EXPORT_END -int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp); +int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, ID *called_idp, VALUE *klassp); VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, int argc, const VALUE *argv, VALUE block_handler); VALUE rb_vm_make_proc_lambda(rb_thread_t *th, const struct rb_captured_block *captured, VALUE klass, int8_t is_lambda); @@ -1468,7 +1468,7 @@ int rb_vm_get_sourceline(const rb_contro https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1468 VALUE rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method); void rb_vm_stack_to_heap(rb_thread_t *th); void ruby_thread_init_stack(rb_thread_t *th); -int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp); +int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp); void rb_vm_rewind_cfp(rb_thread_t *th, rb_control_frame_t *cfp); void rb_vm_register_special_exception(enum ruby_special_exceptions sp, VALUE exception_class, const char *mesg); @@ -1580,6 +1580,7 @@ struct rb_trace_arg_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1580 rb_control_frame_t *cfp; VALUE self; ID id; + ID called_id; VALUE klass; VALUE data; @@ -1593,17 +1594,17 @@ struct rb_trace_arg_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1594 void rb_threadptr_exec_event_hooks(struct rb_trace_arg_struct *trace_arg); void rb_threadptr_exec_event_hooks_and_pop_frame(struct rb_trace_arg_struct *trace_arg); -#define EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, pop_p_) do { \ +#define EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, called_id_, klass_, data_, pop_p_) do { \ const rb_event_flag_t flag_arg_ = (flag_); \ if (UNLIKELY(ruby_vm_event_flags & (flag_arg_))) { \ /* defer evaluating the other arguments */ \ - ruby_exec_event_hook_orig(th_, flag_arg_, self_, id_, klass_, data_, pop_p_); \ + ruby_exec_event_hook_orig(th_, flag_arg_, self_, id_, called_id_, klass_, data_, pop_p_); \ } \ } while (0) static inline void ruby_exec_event_hook_orig(rb_thread_t *const th, const rb_event_flag_t flag, - VALUE self, ID id, VALUE klass, VALUE data, int pop_p) + VALUE self, ID id, ID called_id, VALUE klass, VALUE data, int pop_p) { if ((th->event_hooks.events | th->vm->event_hooks.events) & flag) { struct rb_trace_arg_struct trace_arg; @@ -1612,6 +1613,7 @@ ruby_exec_event_hook_orig(rb_thread_t *c https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1613 trace_arg.cfp = th->cfp; trace_arg.self = self; trace_arg.id = id; + trace_arg.called_id = called_id; trace_arg.klass = klass; trace_arg.data = data; trace_arg.path = Qundef; @@ -1621,11 +1623,11 @@ ruby_exec_event_hook_orig(rb_thread_t *c https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1623 } } -#define EXEC_EVENT_HOOK(th_, flag_, self_, id_, klass_, data_) \ - EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, 0) +#define EXEC_EVENT_HOOK(th_, flag_, self_, id_, called_id_, klass_, data_) \ + EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, called_id_, klass_, data_, 0) -#define EXEC_EVENT_HOOK_AND_POP_FRAME(th_, flag_, self_, id_, klass_, data_) \ - EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, 1) +#define EXEC_EVENT_HOOK_AND_POP_FRAME(th_, flag_, self_, id_, called_id_, klass_, data_) \ + EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, called_id_, klass_, data_, 1) RUBY_SYMBOL_EXPORT_BEGIN Index: vm.c =================================================================== --- vm.c (revision 56592) +++ vm.c (revision 56593) @@ -330,7 +330,7 @@ ruby_th_dtrace_setup(rb_thread_t *th, VA https://github.com/ruby/ruby/blob/trunk/vm.c#L330 enum ruby_value_type type; if (!klass) { if (!th) th = GET_THREAD(); - if (!rb_thread_method_id_and_class(th, &id, &klass) || !klass) + if (!rb_thread_method_id_and_class(th, &id, 0, &klass) || !klass) return FALSE; } if (RB_TYPE_P(klass, T_ICLASS)) { @@ -522,7 +522,7 @@ rb_vm_pop_cfunc_frame(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L522 rb_control_frame_t *cfp = th->cfp; const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(cfp); - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, cfp->self, me->def->original_id, me->owner, Qnil); + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, cfp->self, me->def->original_id, me->called_id, me->owner, Qnil); RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->def->original_id); vm_pop_frame(th, cfp, cfp->ep); } @@ -984,9 +984,9 @@ invoke_bmethod(rb_thread_t *th, const rb https://github.com/ruby/ruby/blob/trunk/vm.c#L984 iseq->body->stack_max); RUBY_DTRACE_METHOD_ENTRY_HOOK(th, me->owner, me->def->original_id); - EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, self, me->def->original_id, me->owner, Qnil); + EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, self, me->def->original_id, me->called_id, me->owner, Qnil); ret = vm_exec(th); - EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->def->original_id, me->owner, ret); + EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->def->original_id, me->called_id, me->owner, ret); RUBY_DTRACE_METHOD_RETURN_HOOK(th, me->owner, me->def->original_id); return ret; } @@ -1592,26 +1592,27 @@ hook_before_rewind(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm.c#L1592 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); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0, 0, Qnil); break; case VM_FRAME_MAGIC_BLOCK: case VM_FRAME_MAGIC_LAMBDA: if (VM_FRAME_BMETHOD_P(th->cfp)) { - EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); + EXEC_EVENT_HOOK(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, 0, Qnil); if (!will_finish_vm_exec) { /* kick RUBY_EVENT_RETURN at invoke_block_from_c() for bmethod */ EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, rb_vm_frame_method_entry(th->cfp)->def->original_id, + rb_vm_frame_method_entry(th->cfp)->called_id, rb_vm_frame_method_entry(th->cfp)->owner, Qnil); } } else { - EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 0, Qnil); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_B_RETURN, th->cfp->self, 0, 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); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_END, th->cfp->self, 0, 0, 0, Qnil); break; } } @@ -1735,6 +1736,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L1736 if (UNLIKELY(VM_FRAME_TYPE(th->cfp) == VM_FRAME_MAGIC_CFUNC)) { EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, th->cfp->self, rb_vm_frame_method_entry(th->cfp)->def->original_id, + rb_vm_frame_method_entry(th->cfp)->called_id, rb_vm_frame_method_entry(th->cfp)->owner, Qnil); RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, rb_vm_frame_method_entry(th->cfp)->owner, @@ -1958,12 +1960,13 @@ rb_iseq_eval_main(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/vm.c#L1960 } int -rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp) +rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp) { const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(cfp); if (me) { if (idp) *idp = me->def->original_id; + if (called_idp) *called_idp = me->called_id; if (klassp) *klassp = me->owner; return TRUE; } @@ -1973,15 +1976,15 @@ rb_vm_control_frame_id_and_class(const r https://github.com/ruby/ruby/blob/trunk/vm.c#L1976 } int -rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp) +rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, ID *called_idp, VALUE *klassp) { - return rb_vm_control_frame_id_and_class(th->cfp, idp, klassp); + return rb_vm_control_frame_id_and_class(th->cfp, idp, called_idp, klassp); } int -rb_frame_method_id_and_class(ID *idp, VALUE *klassp) +rb_frame_method_id_and_class(ID *idp, ID *called_idp, VALUE *klassp) { - return rb_thread_method_id_and_class(GET_THREAD(), idp, klassp); + return rb_thread_method_id_and_class(GET_THREAD(), idp, called_idp, klassp); } VALUE Index: vm_eval.c =================================================================== --- vm_eval.c (revision 56592) +++ vm_eval.c (revision 56593) @@ -68,7 +68,7 @@ vm_call0_cfunc(rb_thread_t* th, struct r https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L68 VALUE val; RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, cc->me->owner, ci->mid); - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, calling->recv, ci->mid, cc->me->owner, Qnil); + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, calling->recv, ci->mid, ci->mid, cc->me->owner, Qnil); { rb_control_frame_t *reg_cfp = th->cfp; const rb_callable_method_entry_t *me = cc->me; @@ -98,7 +98,7 @@ vm_call0_cfunc(rb_thread_t* th, struct r https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L98 rb_vm_pop_frame(th); } } - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, calling->recv, ci->mid, callnig->cc->me->owner, val); + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, calling->recv, ci->mid, ci->mid, callnig->cc->me->owner, val); RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, cc->me->owner, ci->mid); return val; @@ -117,7 +117,7 @@ vm_call0_cfunc_with_frame(rb_thread_t* t https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L117 VALUE block_handler = calling->block_handler; RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, mid); - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->def->original_id, me->owner, Qnil); + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->def->original_id, mid, me->owner, Qnil); { rb_control_frame_t *reg_cfp = th->cfp; @@ -136,7 +136,7 @@ vm_call0_cfunc_with_frame(rb_thread_t* t https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L136 VM_PROFILE_UP(C2C_POPF); rb_vm_pop_frame(th); } - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->def->original_id, me->owner, val); + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->def->original_id, mid, me->owner, val); RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, mid); return val; Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 56592) +++ include/ruby/intern.h (revision 56593) @@ -969,7 +969,7 @@ VALUE rb_mod_remove_cvar(VALUE, VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L969 ID rb_frame_callee(void); VALUE rb_str_succ(VALUE); VALUE rb_time_succ(VALUE); -int rb_frame_method_id_and_class(ID *idp, VALUE *klassp); +int rb_frame_method_id_and_class(ID *idp, ID *called_idp, VALUE *klassp); VALUE rb_make_backtrace(void); VALUE rb_make_exception(int, const VALUE*); Index: test/ruby/test_settracefunc.rb =================================================================== --- test/ruby/test_settracefunc.rb (revision 56592) +++ test/ruby/test_settracefunc.rb (revision 56593) @@ -1488,4 +1488,115 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L1488 assert_equal ev, :fiber_switch } end + + def test_tracepoint_callee_id + events = [] + capture_events = Proc.new{|tp| + events << [tp.event, tp.method_id, tp.callee_id] + } + + o = Class.new{ + def m + raise + end + alias alias_m m + }.new + TracePoint.new(:raise, :call, :return, &capture_events).enable{ + o.alias_m rescue nil + } + assert_equal [[:call, :m, :alias_m], [:raise, :m, :alias_m], [:return, :m, :alias_m]], events + events.clear + + o = Class.new{ + alias alias_raise raise + def m + alias_raise + end + }.new + TracePoint.new(:c_return, &capture_events).enable{ + o.m rescue nil + } + assert_equal [:c_return, :raise, :alias_raise], events[0] + events.clear + + o = Class.new(String){ + include Enumerable + alias each each_char + }.new('foo') + TracePoint.new(:c_return, &capture_events).enable{ + o.find{true} + } + assert_equal [:c_return, :each_char, :each], events[0] + events.clear + + o = Class.new{ + define_method(:m){} + alias alias_m m + }.new + TracePoint.new(:call, :return, &capture_events).enable{ + o.alias_m + } + assert_equal [[:call, :m, :alias_m], [:return, :m, :alias_m]], events + events.clear + + o = Class.new{ + def m + tap{return} + end + alias alias_m m + }.new + TracePoint.new(:return, &capture_events).enable{ + o.alias_m + } + assert_equal [[:return, :m, :alias_m]], events + events.clear + + o = Class.new{ + define_method(:m){raise} + alias alias_m m + }.new + TracePoint.new(:b_return, :return, &capture_events).enable{ + o.alias_m rescue nil + } + assert_equal [[:b_return, :m, :alias_m], [:return, :m, :alias_m]], events[0..1] + events.clear + + o = Class.new{ + define_method(:m){tap{return}} + alias alias_m m + }.new + TracePoint.new(:b_return, &capture_events).enable{ + o.alias_m + } + assert_equal [[:b_return, :m, :alias_m], [:b_return, :m, :alias_m]], events[0..1] + events.clear + + o = Class.new{ + alias alias_tap tap + define_method(:m){alias_tap{return}} + }.new + TracePoint.new(:c_return, &capture_events).enable{ + o.m + } + assert_equal [[:c_return, :tap, :alias_tap]], (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/