ruby-changes:2386
From: ko1@a...
Date: 11 Nov 2007 17:42:25 +0900
Subject: [ruby-changes:2386] shugo - Ruby:r13877 (trunk): * insnhelper.ci (vm_call_method): pass mn->nd_clss to
shugo 2007-11-11 17:42:13 +0900 (Sun, 11 Nov 2007)
New Revision: 13877
Modified files:
trunk/ChangeLog
trunk/insnhelper.ci
trunk/test/ruby/test_settracefunc.rb
trunk/thread.c
trunk/vm.c
Log:
* 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().
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/insnhelper.ci?r1=13877&r2=13876
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13877&r2=13876
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/thread.c?r1=13877&r2=13876
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/vm.c?r1=13877&r2=13876
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_settracefunc.rb?r1=13877&r2=13876
Index: ChangeLog
===================================================================
--- ChangeLog (revision 13876)
+++ ChangeLog (revision 13877)
@@ -1,3 +1,12 @@
+Sun Nov 11 17:32:46 2007 Shugo Maeda <shugo@r...>
+
+ * 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@f...>
* lex.c: renamed from lex.c.blt.
Index: thread.c
===================================================================
--- thread.c (revision 13876)
+++ thread.c (revision 13877)
@@ -2890,22 +2890,32 @@
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"));
+ if (p->event == RUBY_EVENT_C_CALL ||
+ p->event == RUBY_EVENT_C_RETURN) {
+ id = p->id;
+ klass = p->klass;
}
- else if (p->id) {
- mid = ID2SYM(p->id);
- }
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
Index: vm.c
===================================================================
--- vm.c (revision 13876)
+++ vm.c (revision 13877)
@@ -1378,21 +1378,28 @@
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));
+ rb_iseq_t *iseq = cfp->iseq;
+ if (!iseq) {
+ if (idp) *idp = cfp->method_id;
+ if (klassp) *klassp = cfp->method_klass;
+ return 1;
+ }
+ 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;
}
- else {
- if (idp) *idp = cfp->method_id;
- if (klassp) *klassp = cfp->method_klass;
- return 1;
- }
- *idp = *klassp = 0;
return 0;
}
Index: test/ruby/test_settracefunc.rb
===================================================================
--- test/ruby/test_settracefunc.rb (revision 13876)
+++ test/ruby/test_settracefunc.rb (revision 13877)
@@ -35,7 +35,7 @@
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
Index: insnhelper.ci
===================================================================
--- insnhelper.ci (revision 13876)
+++ insnhelper.ci (revision 13877)
@@ -496,7 +496,7 @@
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:{
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml