如何在我的Rack应用程序运行时调试它?

时间:2014-01-30 19:23:23

标签: ruby debugging gdb rack

我写了一个机架应用程序(here),每天锁定大约一到两次,我需要调试应用程序。

所以,我尝试了这个:http://robots.thoughtbot.com/using-gdb-to-inspect-a-running-ruby-process。我尝试针对一个简单的测试脚本进行调试:

class MyTest
  def initialize
    @a ||= 1
  end

  def something
    @a += 1
    puts @a
  end
end

test = MyTest.new

while true do
  sleep 3
  test.something
end

然而,我明白了:

(gdb) redirect_stdout
No symbol "rb_eval_string" in current context.
(gdb) ruby_eval('Kernel.caller')
No symbol "rb_p" in current context.

知道我需要做些什么吗?或者有另一种调试方法吗?我想避免使用“puts”语句并写入日志,因为我已经尝试过了,而且非常受欢迎。

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:1)

看起来它没有正确附加到过程中。在root模式下运行让我附加和调试。我跑了call rb_backtrace(),这给了一些有用的输出。

相关问题