summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--test/ruby/test_settracefunc.rb22
-rw-r--r--thread.c3
-rw-r--r--vm_insnhelper.c6
4 files changed, 42 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 268e1cbdac..a6dfd74ccb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Thu Jun 30 22:17:04 2011 Koichi Sasada <ko1@atdot.net>
+
+ * vm_insnhelper.c (vm_call_bmethod): fix to hook call/return event
+ for methods defined by define_method().
+
+ * thread.c (call_trace_proc): Fix to skip if class is not given (0).
+ Note that ID and Class object are passed for call/return event
+ if the called method was defined by define_method().
+ If you are author of tracer/profiler/debugger, this may be an
+ important change. You should check passed class as zero or
+ non-zero instead of checking the event type.
+
+ * test/ruby/test_settracefunc.rb: add a test for above.
+
Thu Jun 30 21:18:35 2011 Yutaka Kanemoto <kanemoto@ruby-lang.org>
* configure.in: Add warnflags for XL/C on AIX during configure
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 4bace9ed61..d6c6d06f38 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -355,6 +355,28 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_equal([], events[:add])
end
+ def test_trace_defined_method
+ events = []
+ eval <<-EOF.gsub(/^.*?: /, "")
+ 1: class FooBar; define_method(:foobar){}; end
+ 2: fb = FooBar.new
+ 3: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass|
+ 4: events << [event, lineno, mid, klass]
+ 5: })
+ 6: fb.foobar
+ 7: set_trace_func(nil)
+ EOF
+
+ [["c-return", 5, :set_trace_func, Kernel],
+ ["line", 6, __method__, self.class],
+ ["call", 6, :foobar, FooBar],
+ ["return", 6, :foobar, FooBar],
+ ["line", 7, __method__, self.class],
+ ["c-call", 7, :set_trace_func, Kernel]].each{|e|
+ assert_equal(e, events.shift)
+ }
+ end
+
def test_remove_in_trace
bug3921 = '[ruby-dev:42350]'
ok = false
diff --git a/thread.c b/thread.c
index 5ba711c5c5..ab547a1d0a 100644
--- a/thread.c
+++ b/thread.c
@@ -4447,8 +4447,7 @@ call_trace_proc(VALUE args, int tracing)
ID id = 0;
VALUE klass = 0;
- if (p->event == RUBY_EVENT_C_CALL ||
- p->event == RUBY_EVENT_C_RETURN) {
+ if (p->klass != 0) {
id = p->id;
klass = p->klass;
}
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 366ac4a467..a02628dabb 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -421,11 +421,15 @@ vm_call_bmethod(rb_thread_t *th, VALUE recv, int argc, const VALUE *argv,
rb_proc_t *proc;
VALUE val;
+ EXEC_EVENT_HOOK(th, RUBY_EVENT_CALL, recv, me->called_id, me->klass);
+
/* control block frame */
th->passed_me = me;
-
GetProcPtr(me->def->body.proc, proc);
val = rb_vm_invoke_proc(th, proc, recv, argc, argv, blockptr);
+
+ EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, recv, me->called_id, me->klass);
+
return val;
}