如何使用键盘进入ruby-debug运行rails应用程序?

时间:2023-01-23 20:44:29

I'm running ruby-debug with bundle exec rdebug script/server on Rails 2.3. When I press Ctrl-C, it exits the entire program and the debugger. I want it to stop execution of the program and bring me into a debugger session.

我正在Rails 2.3上使用bundle exec rdebug脚本/服务器运行ruby-debug。当我按Ctrl-C时,它会退出整个程序和调试器。我希望它停止执行程序并将我带入调试器会话。

I tried catch Interrupt but it didn't work. Is there an exception that gets called when I stop rails with Ctrl-C that would be good to use for this purpose? Or is there another way?

我试图插嘴,但没有用。当我使用Ctrl-C停止rails时,会不会有一个异常被调用?还是有别的办法?

What I want is the equivalent of pressing the Break (pause) button in Visual Studio (I haven't yet done this with a Rails IDE).

我想要的是在Visual Studio中按下Break (pause)按钮(我还没有使用Rails IDE)。

2 个解决方案

#1


3  

I recommend pry over ruby-debug. Install the gem and then you can just stick this into your code where you want to debug:

我推荐pry而不是ruby-debug。安装gem,然后您可以将它插入到您想要调试的代码中:

binding.pry

#2


1  

you should just drop a debugger line in your code, this will automatically create a debugging session.

您应该在代码中删除调试器行,这将自动创建调试会话。

#1


3  

I recommend pry over ruby-debug. Install the gem and then you can just stick this into your code where you want to debug:

我推荐pry而不是ruby-debug。安装gem,然后您可以将它插入到您想要调试的代码中:

binding.pry

#2


1  

you should just drop a debugger line in your code, this will automatically create a debugging session.

您应该在代码中删除调试器行,这将自动创建调试会话。