class User
def some_method
puts "some method"
end
end
set_trace_func proc { |event, file, line, id, binding, classname|
printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}
user = User.new
user.some_method
#=>
c-return test.rb:9 set_trace_func Kernel
line test.rb:11
c-call test.rb:11 new Class
c-call test.rb:11 initialize BasicObject
c-return test.rb:11 initialize BasicObject
c-return test.rb:11 new Class
line test.rb:12
call test.rb:2 some_method User
line test.rb:3 some_method User
c-call test.rb:3 puts Kernel
c-call test.rb:3 puts IO
c-call test.rb:3 write IO
some methodc-return test.rb:3 write IO
c-call test.rb:3 write IO
c-return test.rb:3 write IO
c-return test.rb:3 puts IO
c-return test.rb:3 puts Kernel
return test.rb:4 some_method User
ユーザーのメソッドに関する情報のみを出力するようにprocを変更できます。