[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>
Currently, ruby/spec is maintained mostly by individuals and enjoys the
13 messages
2016/12/13
[#78963] Re: ruby/spec needs help from CRuby committers
— Urabe Shyouhei <shyouhei@...>
2017/01/04
I did ask attendees of last developer meeting to join this
[#78642] Re: ruby/spec needs help from CRuby committers
— Eric Wong <normalperson@...>
2016/12/14
Benoit Daloze <eregontp@gmail.com> wrote:
[ruby-core:78475] [Ruby trunk Feature#12747] Add TracePoint#callee_id
From:
kazuki@...
Date:
2016-12-03 12:40:52 UTC
List:
ruby-core #78475
Issue #12747 has been updated by Kazuki Tsujimoto.
Thanks Yamaguchi-san, good catch.
I'll revert rb_frame_method_id_and_class.
----------------------------------------
Feature #12747: Add TracePoint#callee_id
https://bugs.ruby-lang.org/issues/12747#change-61852
* Author: Kazuki Tsujimoto
* Status: Closed
* Priority: Normal
* Assignee: Koichi Sasada
----------------------------------------
# Abstract
I propose to add TracePoint#callee_id which returns the called name of the method.
~~~ruby
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--------------------------------
0001-TracePoint-method_id-should-return-method_id-not-cal.patch (9.76 KB)
0002-Add-TracePoint-callee_id.patch (19.4 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>