ruby-changes:65971
From: Jeremy <ko1@a...>
Date: Tue, 27 Apr 2021 07:25:39 +0900 (JST)
Subject: [ruby-changes:65971] d585799d73 (master): Document binding behavior for C call/return events for TracePoint/set_trace_func
https://git.ruby-lang.org/ruby.git/commit/?id=d585799d73 From d585799d7303abeb1b0ca6fc868f0b2d76a26250 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Mon, 26 Apr 2021 15:21:52 -0700 Subject: Document binding behavior for C call/return events for TracePoint/set_trace_func C methods do not have bindings, so binding returns the binding of the nearest C method. Fixes [Bug #9009] --- trace_point.rb | 12 +++++++++--- vm_trace.c | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/trace_point.rb b/trace_point.rb index d68eed4..2e85369 100644 --- a/trace_point.rb +++ b/trace_point.rb @@ -309,15 +309,21 @@ class TracePoint https://github.com/ruby/ruby/blob/trunk/trace_point.rb#L309 Primitive.tracepoint_attr_defined_class end - # Return the generated binding object from event + # Return the generated binding object from event. + # + # Note that for +c_call+ and +c_return+ events, the binding returned is the + # binding of the nearest Ruby method calling the C method, since C methods + # themselves do not have bindings. def binding Primitive.tracepoint_attr_binding end # Return the trace object during event # - # Same as TracePoint#binding: - # trace.binding.eval('self') + # Same as the following, except it returns the correct object (the method + # receiver) for +c_call+ and +c_return+ events: + # + # trace.binding.eval('self') def self Primitive.tracepoint_attr_self end diff --git a/vm_trace.c b/vm_trace.c index 383f255..6e2c058 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -519,6 +519,10 @@ static void call_trace_func(rb_event_flag_t, VALUE data, VALUE self, ID id, VALU https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L519 * line prog.rb:3 test Test * line prog.rb:4 test Test * return prog.rb:4 test Test + * + * Note that for +c-call+ and +c-return+ events, the binding returned is the + * binding of the nearest Ruby method calling the C method, since C methods + * themselves do not have bindings. */ static VALUE -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/