Project

General

Profile

Bug #7976 ยป tp_test.rb

zenspider (Ryan Davis), 02/27/2013 10:25 AM

 
tp = TracePoint.new(:call, :return, :c_call, :c_return, :raise) do |t|
warn "%-9p %s:%02d %p" % [t.event, t.path, t.lineno, t.method_id]
end

tp.enable

class X
def x
y
end

def y
z
end

def z
raise "no"
end
end

X.new.x

# :c_return wtf.rb:05 :enable
# :c_call wtf.rb:07 :inherited
# :c_return wtf.rb:07 :inherited
# :c_call wtf.rb:08 :method_added
# :c_return wtf.rb:08 :method_added
# :c_call wtf.rb:12 :method_added
# :c_return wtf.rb:12 :method_added
# :c_call wtf.rb:16 :method_added
# :c_return wtf.rb:16 :method_added
# :c_call wtf.rb:21 :new
# :c_call wtf.rb:21 :initialize
# :c_return wtf.rb:21 :initialize
# :c_return wtf.rb:21 :new
# :call wtf.rb:08 :x
# :call wtf.rb:12 :y
# :call wtf.rb:16 :z
# :c_call wtf.rb:17 :raise
# :c_call wtf.rb:17 :new
# :c_call wtf.rb:17 :initialize
# :c_return wtf.rb:17 :initialize
# :c_return wtf.rb:17 :new
# :c_call wtf.rb:17 :backtrace
# :c_return wtf.rb:17 :backtrace
# :raise wtf.rb:17 :z
# :c_return wtf.rb:17 :raise
# :return wtf.rb:17 :z
# :return wtf.rb:13 :y
# :return wtf.rb:09 :x
# wtf.rb:17:in `z': no (RuntimeError)
# from wtf.rb:13:in `y'
# from wtf.rb:9:in `x'
# from wtf.rb:21:in `<main>'
    (1-1/1)