#GistID: dd1f4bffde8b23192433df1c93685b2e require 'pry' class Test def first_call(f) a = f b = 2 res = second_call(a,b) puts "\n\n=== result res:#{res} ===\n\n" return res end def second_call(aay, bbee) return aay * bbee end end trace = TracePoint.new(:call, :return) do |tp| p ["#{tp.event} #{tp.defined_class}##{tp.method_id}:#{tp.lineno}", tp.self.method(tp.method_id).parameters.inspect, tp.binding.local_variables.map{|a| [a, tp.binding.local_variable_get(a)]} , tp.event == :return ? tp.return_value : "nop"] #binding.pry end trace.enable t = Test.new v = t.first_call(ARGV[0]) puts "final #{v}"