如何在 RadRails 中调试纯 ruby​​ 程序

发布于 2024-10-20 08:37:39 字数 261 浏览 8 评论 0原文

我是 Ruby 新手,所以安装了 RadRails、Ruby 1.92 和 ruby​​-debug-ide19。我有一个非常简单的 ruby​​ 程序来打印 hello world。但是,当我尝试在代码中放置断点并在调试模式下运行时,我在控制台上得到的只是以下行:

Fast Debugger (ruby-debug-ide 0.4.9) listens on :51224

为什么它仍然需要侦听端口?我怎样才能让它运行我的程序直到断点?

I am new to Ruby so have installed RadRails, Ruby 1.92 and ruby-debug-ide19. I have a very simple ruby program that prints hello world. But when I try and place a breakpoint in the code and run in debug mode all i get is the following line on the console:

Fast Debugger (ruby-debug-ide 0.4.9) listens on :51224

Why does it need to listen on a port anyway? And how can i get it to run my program until the breakpoint?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄凉少年不暖心 2024-10-27 08:37:39

就我个人而言,我并不费心使用 IDE 进行调试。我更喜欢接近金属...呃...命令行,所以我从命令行使用 ruby​​-debug19。

rdebug some_file_to_debug

对于基础知识,请使用:

  • b 设置断点
  • n 跳过方法
  • s 进入方法
  • c命中断点后继续运行
  • cn 运行到特定行然后停止
  • p 显示值
  • h 将显示内置帮助
  • < code>irb 放入 IRB 中,当前变量已预先初始化,这样您就可以用棍子戳一下东西,看看它们会做什么。

更多文档位于 Ruby-Debug 站点

Personally, I don't bother with an IDE for debugging. I prefer to be closer to the metal... err... command-line, so I use ruby-debug19 from the command-line.

rdebug some_file_to_debug

For the basics use:

  • b to set your breakpoints
  • n to step over methods
  • s to step into methods
  • c to continue running after hitting a breakpoint
  • c n to run to a particular line then stop
  • p to display a value
  • h will display the built-in help
  • irb drops into IRB with the current variables pre-initialized so you can poke at things with a stick and see what they'll do.

More docs are at the Ruby-Debug site.

雾里花 2024-10-27 08:37:39

它使用端口在 IDE 和 ruby​​-debug 进程之间进行通信,ruby-debug-ide 正在打开一个端口并等待 IDE 连接到它,但这必须立即发生。

根据您的陈述,调试应该已经开始工作:您可以右键单击并选择“切换断点”,或者双击编辑器的左侧装订线。当您的程序遇到任何启用的断点行时,程序应该挂起,您可以检查变量、堆栈帧、执行任意代码、单步执行代码、继续等。

It uses the port to communicate between the IDE and the ruby-debug process, ruby-debug-ide is opening a port and waiting for the IDE to connect to it, but that happens pretty must instantly.

From what you've stated, debugging should already be working: You can right-click and select Toggle breakpoint, or double-click on the left-hand gutter of the editor. When your program hits any enabled breakpoint line the program should suspend and you can inspect variables, the stackframes, execute arbitrary code, step into or through your code, continue, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文