Project

General

Profile

Feature #12747 ยป 0001-TracePoint-method_id-should-return-method_id-not-cal.patch

ktsj (Kazuki Tsujimoto), 09/10/2016 06:29 AM

View differences:

eval.c
738 738
    ID mid = me->called_id;
739 739

  
740 740
    rb_vm_pop_frame(th);
741
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, self, mid, klass, Qnil);
741
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, self, me->def->original_id, klass, Qnil);
742 742

  
743 743
    setup_exception(th, TAG_RAISE, mesg, cause);
744 744

  
method.h
205 205
void rb_sweep_method_entry(void *vm);
206 206

  
207 207
const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
208
const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, VALUE defined_class);
208
const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);
209 209
void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
210 210

  
211 211
void rb_scope_visibility_set(rb_method_visibility_t);
proc.c
2225 2225
	else {
2226 2226
	    klass = rb_include_class_new(methclass, klass);
2227 2227
	}
2228
	RB_OBJ_WRITE(method, &bound->me, rb_method_entry_complement_defined_class(bound->me, klass));
2228
	RB_OBJ_WRITE(method, &bound->me, rb_method_entry_complement_defined_class(bound->me, bound->me->called_id, klass));
2229 2229
    }
2230 2230

  
2231 2231
    return method;
test/ruby/test_settracefunc.rb
1153 1153
    }
1154 1154
    assert_equal([
1155 1155
      [:call, :size],
1156
      [:c_call, :original_size],
1157
      [:c_return, :original_size],
1156
      [:c_call, :size],
1157
      [:c_return, :size],
1158 1158
      [:return, :size]
1159 1159
    ], events, "should use alias method name for tracing c methods")
1160 1160
  end
......
1287 1287
      }.enable{
1288 1288
        p 1
1289 1289
      }
1290
    }, %w[:p :inspect 1], [], '[Bug #9940]')
1290
    }, %w[:p :to_s 1], [], '[Bug #9940]')
1291 1291
  end
1292 1292

  
1293 1293
  def method_prefix event
vm.c
522 522
    rb_control_frame_t *cfp = th->cfp;
523 523
    const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(cfp);
524 524

  
525
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, cfp->self, me->called_id, me->owner, Qnil);
526
    RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->called_id);
525
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, cfp->self, me->def->original_id, me->owner, Qnil); /* TODO */
526
    RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->def->original_id);
527 527
    vm_pop_frame(th, cfp, cfp->ep);
528 528
}
529 529

  
......
983 983
		  th->cfp->sp + arg_size, iseq->body->local_table_size - arg_size,
984 984
		  iseq->body->stack_max);
985 985

  
986
    RUBY_DTRACE_METHOD_ENTRY_HOOK(th, me->owner, me->called_id);
987
    EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, self, me->called_id, me->owner, Qnil);
986
    RUBY_DTRACE_METHOD_ENTRY_HOOK(th, me->owner, me->def->original_id);
987
    EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, self, me->def->original_id, me->owner, Qnil);
988 988
    ret = vm_exec(th);
989
    EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->called_id, me->owner, ret);
990
    RUBY_DTRACE_METHOD_RETURN_HOOK(th, me->owner, me->called_id);
989
    EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, self, me->def->original_id, me->owner, ret);
990
    RUBY_DTRACE_METHOD_RETURN_HOOK(th, me->owner, me->def->original_id);
991 991
    return ret;
992 992
}
993 993

  
......
1602 1602
	    if (!will_finish_vm_exec) {
1603 1603
		/* kick RUBY_EVENT_RETURN at invoke_block_from_c() for bmethod */
1604 1604
		EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self,
1605
					      rb_vm_frame_method_entry(th->cfp)->called_id,
1605
					      rb_vm_frame_method_entry(th->cfp)->def->original_id,
1606 1606
					      rb_vm_frame_method_entry(th->cfp)->owner, Qnil);
1607 1607
	    }
1608 1608
	}
......
1734 1734
	while (th->cfp->pc == 0 || th->cfp->iseq == 0) {
1735 1735
	    if (UNLIKELY(VM_FRAME_TYPE(th->cfp) == VM_FRAME_MAGIC_CFUNC)) {
1736 1736
		EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, th->cfp->self,
1737
				rb_vm_frame_method_entry(th->cfp)->called_id,
1737
				rb_vm_frame_method_entry(th->cfp)->def->original_id,
1738 1738
				rb_vm_frame_method_entry(th->cfp)->owner, Qnil);
1739 1739
		RUBY_DTRACE_CMETHOD_RETURN_HOOK(th,
1740 1740
					       rb_vm_frame_method_entry(th->cfp)->owner,
1741
					       rb_vm_frame_method_entry(th->cfp)->called_id);
1741
					       rb_vm_frame_method_entry(th->cfp)->def->original_id);
1742 1742
	    }
1743 1743
	    rb_vm_pop_frame(th);
1744 1744
	}
vm_eval.c
117 117
    VALUE block_handler = calling->block_handler;
118 118

  
119 119
    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, mid);
120
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, mid, me->owner, Qnil);
120
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->def->original_id, me->owner, Qnil);
121 121
    {
122 122
	rb_control_frame_t *reg_cfp = th->cfp;
123 123

  
......
136 136
	VM_PROFILE_UP(C2C_POPF);
137 137
	rb_vm_pop_frame(th);
138 138
    }
139
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, mid, me->owner, val);
139
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->def->original_id, me->owner, val);
140 140
    RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, mid);
141 141

  
142 142
    return val;
vm_insnhelper.c
1723 1723
    VALUE block_handler = calling->block_handler;
1724 1724
    int argc = calling->argc;
1725 1725

  
1726
    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, me->called_id);
1727
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->called_id, me->owner, Qundef);
1726
    RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, me->def->original_id);
1727
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->def->original_id, me->owner, Qundef);
1728 1728

  
1729 1729
    vm_push_frame(th, NULL, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv,
1730 1730
		  block_handler, (VALUE)me,
......
1742 1742

  
1743 1743
    rb_vm_pop_frame(th);
1744 1744

  
1745
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->called_id, me->owner, val);
1746
    RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->called_id);
1745
    EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->def->original_id, me->owner, val);
1746
    RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->def->original_id);
1747 1747

  
1748 1748
    return val;
1749 1749
}
......
2072 2072
    if (orig_me->defined_class == 0) {
2073 2073
	VALUE defined_class = find_defined_class_by_owner(me->defined_class, orig_me->owner);
2074 2074
	VM_ASSERT(RB_TYPE_P(orig_me->owner, T_MODULE));
2075
	cme = rb_method_entry_complement_defined_class(orig_me, defined_class);
2075
	cme = rb_method_entry_complement_defined_class(orig_me, me->called_id, defined_class);
2076 2076

  
2077 2077
	if (me->def->alias_count + me->def->complemented_count == 0) {
2078 2078
	    RB_OBJ_WRITE(me, &me->def->body.alias.original_me, cme);
vm_method.c
408 408
}
409 409

  
410 410
const rb_callable_method_entry_t *
411
rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, VALUE defined_class)
411
rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class)
412 412
{
413
    rb_method_entry_t *me = rb_method_entry_alloc(src_me->called_id, src_me->owner, defined_class,
413
    rb_method_entry_t *me = rb_method_entry_alloc(called_id, src_me->owner, defined_class,
414 414
						  method_definition_addref_complement(src_me->def));
415 415
    METHOD_ENTRY_FLAGS_COPY(me, src_me);
416 416
    METHOD_ENTRY_COMPLEMENTED_SET(me);
......
811 811
	    VM_ASSERT(callable_method_entry_p(cme));
812 812
	}
813 813
	else {
814
	    cme = rb_method_entry_complement_defined_class(me, defined_class);
814
	    cme = rb_method_entry_complement_defined_class(me, me->called_id, defined_class);
815 815
	    rb_id_table_insert(mtbl, id, (VALUE)cme);
816 816
	    VM_ASSERT(callable_method_entry_p(cme));
817 817
	}
......
944 944
    const rb_method_entry_t *resolved_me = resolve_refined_method(refinements, (const rb_method_entry_t *)me, &defined_class);
945 945

  
946 946
    if (resolved_me && resolved_me->defined_class == 0) {
947
	return rb_method_entry_complement_defined_class(resolved_me, defined_class);
947
	return rb_method_entry_complement_defined_class(resolved_me, me->called_id, defined_class);
948 948
    }
949 949
    else {
950 950
	return (const rb_callable_method_entry_t *)resolved_me;
951
-