This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def trace_calls_on | |
scope = {} | |
trace = TracePoint.new(:call, :line) do |tp| | |
case tp.event | |
when :call then puts "#{tp.path}:#{tp.lineno} #{tp.defined_class}::#{tp.method_id} " \ | |
"called from #{scope[:path]}:#{scope[:lineno]} #{scope[:class]}::#{scope[:method_id]}" | |
when :line then scope = { | |
event: :line, | |
lineno: tp.lineno, | |
path: tp.path, |