mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* insnhelper.ci (vm_call_method): pass mn->nd_clss to
vm_call_cfunc() instead of klass. * vm.c (rb_thread_method_id_and_klass): traverse parent_iseq. * thread.c (call_trace_proc): use rb_thread_method_id_and_klass(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c5335ee110
commit
577eaa60a7
5 changed files with 48 additions and 22 deletions
|
@ -1,3 +1,12 @@
|
|||
Sun Nov 11 17:32:46 2007 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* insnhelper.ci (vm_call_method): pass mn->nd_clss to
|
||||
vm_call_cfunc() instead of klass.
|
||||
|
||||
* vm.c (rb_thread_method_id_and_klass): traverse parent_iseq.
|
||||
|
||||
* thread.c (call_trace_proc): use rb_thread_method_id_and_klass().
|
||||
|
||||
Sun Nov 11 16:54:25 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* lex.c: renamed from lex.c.blt.
|
||||
|
|
|
@ -496,7 +496,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
|
|||
return Qundef;
|
||||
}
|
||||
case NODE_CFUNC:{
|
||||
val = vm_call_cfunc(th, cfp, num, id, recv, klass, flag, node, blockptr);
|
||||
val = vm_call_cfunc(th, cfp, num, id, recv, mn->nd_clss, flag, node, blockptr);
|
||||
break;
|
||||
}
|
||||
case NODE_ATTRSET:{
|
||||
|
|
|
@ -35,7 +35,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||
eval("class Foo; end")
|
||||
set_trace_func nil
|
||||
|
||||
assert_equal(["c-return", 18, :set_trace_func, TestSetTraceFunc],
|
||||
assert_equal(["c-return", 18, :set_trace_func, Kernel],
|
||||
events.shift) # TODO
|
||||
assert_equal(["line", 19, :test_event, TestSetTraceFunc],
|
||||
events.shift) # a = 1
|
||||
|
|
28
thread.c
28
thread.c
|
@ -2890,22 +2890,32 @@ call_trace_proc(VALUE args)
|
|||
VALUE eventname = rb_str_new2(get_event_name(p->event));
|
||||
VALUE filename = rb_str_new2(rb_sourcefile());
|
||||
int line = rb_sourceline();
|
||||
VALUE mid;
|
||||
ID id = 0;
|
||||
VALUE klass = 0;
|
||||
|
||||
if (p->id == ID_ALLOCATOR) {
|
||||
mid = ID2SYM(rb_intern("allocate"));
|
||||
}
|
||||
else if (p->id) {
|
||||
mid = ID2SYM(p->id);
|
||||
if (p->event == RUBY_EVENT_C_CALL ||
|
||||
p->event == RUBY_EVENT_C_RETURN) {
|
||||
id = p->id;
|
||||
klass = p->klass;
|
||||
}
|
||||
else {
|
||||
mid = Qnil;
|
||||
rb_thread_method_id_and_klass(GET_THREAD(), &id, &klass);
|
||||
}
|
||||
if (id == ID_ALLOCATOR)
|
||||
return;
|
||||
if (klass) {
|
||||
if (TYPE(klass) == T_ICLASS) {
|
||||
klass = RBASIC(klass)->klass;
|
||||
}
|
||||
else if (FL_TEST(klass, FL_SINGLETON)) {
|
||||
klass = rb_iv_get(klass, "__attached__");
|
||||
}
|
||||
}
|
||||
return rb_proc_call(p->proc, rb_ary_new3(6,
|
||||
eventname, filename, INT2FIX(line),
|
||||
mid,
|
||||
id ? ID2SYM(id) : Qnil,
|
||||
p->self ? rb_binding_new() : Qnil,
|
||||
p->klass ? p->klass : Qnil));
|
||||
klass ? klass : Qnil));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
29
vm.c
29
vm.c
|
@ -1378,21 +1378,28 @@ int
|
|||
rb_thread_method_id_and_klass(rb_thread_t *th, ID *idp, VALUE *klassp)
|
||||
{
|
||||
rb_control_frame_t *cfp = th->cfp;
|
||||
|
||||
if (cfp->iseq) {
|
||||
if (cfp->pc != 0) {
|
||||
rb_iseq_t *iseq = cfp->iseq->local_iseq;
|
||||
if (idp) *idp = rb_intern(RSTRING_PTR(iseq->name));
|
||||
if (klassp) *klassp = iseq->klass;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
rb_iseq_t *iseq = cfp->iseq;
|
||||
if (!iseq) {
|
||||
if (idp) *idp = cfp->method_id;
|
||||
if (klassp) *klassp = cfp->method_klass;
|
||||
return 1;
|
||||
}
|
||||
*idp = *klassp = 0;
|
||||
while (iseq) {
|
||||
if (RUBY_VM_IFUNC_P(iseq)) {
|
||||
if (idp) *idp = rb_intern("<ifunc>");
|
||||
if (klassp) *klassp = 0;
|
||||
return 1;
|
||||
}
|
||||
if (iseq->defined_method_id) {
|
||||
if (idp) *idp = iseq->defined_method_id;
|
||||
if (klassp) *klassp = iseq->klass;
|
||||
return 1;
|
||||
}
|
||||
if (iseq->local_iseq == iseq) {
|
||||
break;
|
||||
}
|
||||
iseq = iseq->parent_iseq;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue