Skip to content

Instantly share code, notes, and snippets.

@siman-man
Last active April 17, 2019 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siman-man/0b43dafbe6a56e228fc55dac3b0d92f1 to your computer and use it in GitHub Desktop.
Save siman-man/0b43dafbe6a56e228fc55dac3b0d92f1 to your computer and use it in GitHub Desktop.
最適化されて TracePoint で取得できなくなっている `+` 演算子を最適化 OFF にして取得する
RubyVM::InstructionSequence.compile_option = false
class RubyVM::InstructionSequence
def self.load_iseq(fpath)
RubyVM::InstructionSequence.compile_file(fpath)
end
end
require_relative 'add'
TracePoint.trace(:c_call) do |tp|
p tp.method_id
end
add(1, 2)
@siman-man
Copy link
Author

add.rb

def add(a, b)
  a + b
end

@siman-man
Copy link
Author

実行結果

$ ruby trace_plus_ope.rb 
:+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment