Project

General

Profile

Feature #12747

Add TracePoint#callee_id

Added by ktsj (Kazuki Tsujimoto) almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:77241]

Description

Abstract

I propose to add TracePoint#callee_id which returns the called name of the method.

def m
end
alias am m

TracePoint.new(:call) do |tp|
  p [tp.method_id, tp.callee_id] #=> [:m, :am]
end.enable do
  am
end

Background

We can get callee id by tp.binding.eval('__callee__')),
but it is slow(10x~) and can't get callee id of CFUNC.

class Object
  alias aitself itself
end

TracePoint.new(:c_call) do |tp|
  p [tp.method_id, tp.binding.eval('__callee__')] #=> [:itself, nil]
end.enable do
  aitself
end

Implementation

I attached 2 patches.

  • 0001-TracePoint-method_id-should-return-method_id-not-cal.patch
    • Now, TracePoint#method_id returns not only method id(__method__) but callee id. This patch makes TracePoint#method_id return method id always, so it introduces some incompatibility.
  • 0002-Add-TracePoint-callee_id.patch
    • Add TracePoint#callee_id.

Usecase

power_assert gem wants this method to get column number of each method calls.


Files

Associated revisions

Revision 8004ad33
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

  • eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
    TracePoint#method_id should return method_id, not callee_id.
    [ruby-core:77241] [Feature #12747]

  • test/ruby/test_settracefunc.rb: change accordingly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 56592
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

  • eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
    TracePoint#method_id should return method_id, not callee_id.
    [ruby-core:77241] [Feature #12747]

  • test/ruby/test_settracefunc.rb: change accordingly.

Revision 56592
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

  • eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
    TracePoint#method_id should return method_id, not callee_id.
    [ruby-core:77241] [Feature #12747]

  • test/ruby/test_settracefunc.rb: change accordingly.

Revision 56592
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

  • eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
    TracePoint#method_id should return method_id, not callee_id.
    [ruby-core:77241] [Feature #12747]

  • test/ruby/test_settracefunc.rb: change accordingly.

Revision 56592
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

  • eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
    TracePoint#method_id should return method_id, not callee_id.
    [ruby-core:77241] [Feature #12747]

  • test/ruby/test_settracefunc.rb: change accordingly.

Revision 9cbd6ee0
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

  • vm_trace.c (tracepoint_attr_callee_id, rb_tracearg_callee_id):
    add TracePoint#callee_id. [ruby-core:77241] [Feature #12747]

  • cont.c, eval.c, gc.c, include/ruby/intern.h, insns.def, thread.c,
    vm.c, vm_backtrace.c, vm_core.h, vm_eval.c, vm_insnhelper.c, vm_trace.c: ditto.

  • test/ruby/test_settracefunc.rb: tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 56593
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

  • vm_trace.c (tracepoint_attr_callee_id, rb_tracearg_callee_id):
    add TracePoint#callee_id. [ruby-core:77241] [Feature #12747]

  • cont.c, eval.c, gc.c, include/ruby/intern.h, insns.def, thread.c,
    vm.c, vm_backtrace.c, vm_core.h, vm_eval.c, vm_insnhelper.c, vm_trace.c: ditto.

  • test/ruby/test_settracefunc.rb: tests for above.

Revision 56593
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

  • vm_trace.c (tracepoint_attr_callee_id, rb_tracearg_callee_id):
    add TracePoint#callee_id. [ruby-core:77241] [Feature #12747]

  • cont.c, eval.c, gc.c, include/ruby/intern.h, insns.def, thread.c,
    vm.c, vm_backtrace.c, vm_core.h, vm_eval.c, vm_insnhelper.c, vm_trace.c: ditto.

  • test/ruby/test_settracefunc.rb: tests for above.

Revision 56593
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

  • vm_trace.c (tracepoint_attr_callee_id, rb_tracearg_callee_id):
    add TracePoint#callee_id. [ruby-core:77241] [Feature #12747]

  • cont.c, eval.c, gc.c, include/ruby/intern.h, insns.def, thread.c,
    vm.c, vm_backtrace.c, vm_core.h, vm_eval.c, vm_insnhelper.c, vm_trace.c: ditto.

  • test/ruby/test_settracefunc.rb: tests for above.

Revision 56593
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

  • vm_trace.c (tracepoint_attr_callee_id, rb_tracearg_callee_id):
    add TracePoint#callee_id. [ruby-core:77241] [Feature #12747]

  • cont.c, eval.c, gc.c, include/ruby/intern.h, insns.def, thread.c,
    vm.c, vm_backtrace.c, vm_core.h, vm_eval.c, vm_insnhelper.c, vm_trace.c: ditto.

  • test/ruby/test_settracefunc.rb: tests for above.

Revision b16d1968
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

Revert changes on rb_frame_method_id_and_class()

r56593 introduced backwards incompatible changes in the API.
[ruby-core:78471] [Feature #12747]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 56979
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

Revert changes on rb_frame_method_id_and_class()

r56593 introduced backwards incompatible changes in the API.
[ruby-core:78471] [Feature #12747]

Revision 56979
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

Revert changes on rb_frame_method_id_and_class()

r56593 introduced backwards incompatible changes in the API.
[ruby-core:78471] [Feature #12747]

Revision 56979
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

Revert changes on rb_frame_method_id_and_class()

r56593 introduced backwards incompatible changes in the API.
[ruby-core:78471] [Feature #12747]

Revision 56979
Added by ktsj (Kazuki Tsujimoto) over 2 years ago

Revert changes on rb_frame_method_id_and_class()

r56593 introduced backwards incompatible changes in the API.
[ruby-core:78471] [Feature #12747]

Revision f8f026c4
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 56592: [Backport #11964]

    * eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
      TracePoint#method_id should return method_id, not callee_id.
      [ruby-core:77241] [Feature #12747]

    * test/ruby/test_settracefunc.rb: change accordingly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 58148
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 56592: [Backport #11964]

* eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
  TracePoint#method_id should return method_id, not callee_id.
  [ruby-core:77241] [Feature #12747]

* test/ruby/test_settracefunc.rb: change accordingly.

History

Updated by shyouhei (Shyouhei Urabe) almost 3 years ago

  • Assignee set to ko1 (Koichi Sasada)
  • Status changed from Open to Assigned

Updated by ko1 (Koichi Sasada) over 2 years ago

Sorry for late response.

I missed incompatibility.
How about to commit it before next preview and ask feedback from users?

Thansk,
Koichi

#3

Updated by ktsj (Kazuki Tsujimoto) over 2 years ago

  • Status changed from Assigned to Closed

Applied in changeset r56592.


  • eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
    TracePoint#method_id should return method_id, not callee_id.
    [ruby-core:77241] [Feature #12747]

  • test/ruby/test_settracefunc.rb: change accordingly.

Updated by ktsj (Kazuki Tsujimoto) over 2 years ago

Thank you, I committed.

Updated by rhenium (Kazuki Yamaguchi) over 2 years ago

r56593 changed the signature of rb_frame_method_id_and_class() which is exposed to C extensions. For example, this broke ruby-prof gem. Is this intentional?

Updated by ktsj (Kazuki Tsujimoto) over 2 years ago

Thanks Yamaguchi-san, good catch.

I'll revert rb_frame_method_id_and_class.

Also available in: Atom PDF