本帖最后由 taroxd 于 2015-5-23 17:40 编辑
给你一个来自Ruby文档的例子。不过一般来说Ruby不怎么需要单步调试。有一些好用的调试gem但是放到RGSS就不太方便
class Test def test a = 1 b = 2 end end set_trace_func proc { |event, file, line, id, binding, classname| printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname } t = Test.new t.test __END__ 下面是输出: c-return F:/Documents/test.rb:8 set_trace_func Kernel line F:/Documents/test.rb:11 c-call F:/Documents/test.rb:11 new Class c-call F:/Documents/test.rb:11 initialize BasicObject c-return F:/Documents/test.rb:11 initialize BasicObject c-return F:/Documents/test.rb:11 new Class line F:/Documents/test.rb:12 call F:/Documents/test.rb:2 test Test line F:/Documents/test.rb:3 test Test line F:/Documents/test.rb:4 test Test return F:/Documents/test.rb:5 test Test
class Test
def test
a = 1
b = 2
end
end
set_trace_func proc { |event, file, line, id, binding, classname|
printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}
t = Test.new
t.test
__END__
下面是输出:
c-return F:/Documents/test.rb:8 set_trace_func Kernel
line F:/Documents/test.rb:11
c-call F:/Documents/test.rb:11 new Class
c-call F:/Documents/test.rb:11 initialize BasicObject
c-return F:/Documents/test.rb:11 initialize BasicObject
c-return F:/Documents/test.rb:11 new Class
line F:/Documents/test.rb:12
call F:/Documents/test.rb:2 test Test
line F:/Documents/test.rb:3 test Test
line F:/Documents/test.rb:4 test Test
return F:/Documents/test.rb:5 test Test
set_trace_func 的详细用法请参考 Ruby 文档(非 F1) |