首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Byebug中不带断点继续

如何在Byebug中不带断点继续
EN

Stack Overflow用户
提问于 2016-04-06 20:52:31
回答 3查看 11K关注 0票数 12

使用byebug gem使我能够在下一个断点之前使用continue

代码语言:javascript
复制
(byebug) help

  break      -- Sets breakpoints in the source code
  catch      -- Handles exception catchpoints
  condition  -- Sets conditions on breakpoints
  continue   -- Runs until program ends, hits a breakpoint or reaches a line
  delete     -- Deletes breakpoints
  disable    -- Disables breakpoints or displays
  display    -- Evaluates expressions every time the debugger stops
  down       -- Moves to a lower frame in the stack trace
  edit       -- Edits source files
  enable     -- Enables breakpoints or displays
  finish     -- Runs the program until frame returns
  frame      -- Moves to a frame in the call stack
  help       -- Helps you using byebug
  history    -- Shows byebug's history of commands
  info       -- Shows several informations about the program being debugged
  interrupt  -- Interrupts the program
  irb        -- Starts an IRB session
  kill       -- Sends a signal to the current process
  list       -- Lists lines of source code
  method     -- Shows methods of an object, class or module
  next       -- Runs one or more lines of code
  pry        -- Starts a Pry session
  ps         -- Evaluates an expression and prettyprints & sort the result
  quit       -- Exits byebug
  restart    -- Restarts the debugged program
  save       -- Saves current byebug session to a file
  set        -- Modifies byebug settings
  show       -- Shows byebug settings
  source     -- Restores a previously saved byebug session
  step       -- Steps into blocks or methods one or more times
  thread     -- Commands to manipulate threads
  tracevar   -- Enables tracing of a global variable
  undisplay  -- Stops displaying all or some expressions when program stops
  untracevar -- Stops tracing a global variable
  up         -- Moves to a higher frame in the stack trace
  var        -- Shows variables and its values
  where      -- Displays the backtrace

我到处看了看,找不到一种“没有断点继续”的方法。我能想到的唯一方法是删除或注释byebug语句,退出q!并重新启动测试。

如果不停止Ruby中的其他byebug语句,我怎么才能继续呢?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2020-08-13 09:20:03

我刚刚在代码中发现,您可以使用以下方法完全停止byebug:

代码语言:javascript
复制
Byebug.mode = :off

您不能再打开它,因为它将不再附加到自身,但这是方便的,例如,当您只是调试一个脚本,您想要完成运行。

票数 5
EN

Stack Overflow用户

发布于 2021-02-01 09:08:14

自2019年2月15日发布的byebug 11.0.0以来,您可以使用continue!或别名c!

参见这个PR https://github.com/deivid-rodriguez/byebug/pull/524

如果您正在使用Rails,您可能希望在新请求时重新设置Rails,而不是添加筛选器:

代码语言:javascript
复制
# application_controller.rb
 before_action do
    if defined?(Byebug) && Byebug.mode == :off && Rails.env.development?
      Byebug.mode = nil
    end
 end
票数 16
EN

Stack Overflow用户

发布于 2016-04-06 21:48:46

代码中的byebug方法调用不是“断点”(考虑帮助输出中对断点的引用)。

根据帮助输出,可以使用breakpoint命令禁用disable。但这并不能解决您的问题,因为下一个byebug将再次暂停执行。

由于byebug只是一个方法调用,所以可以将其设置为条件:

代码语言:javascript
复制
byebug if SomeModule.byebug?

然后,在SomeModule中,可以使用一个全局变量来打开/关闭它。您要么必须在所有对byebug的调用中都这样做,要么就可以对byebug方法进行猴子修补以完成同样的操作,alias_method_chain或其他类似的操作。

"使Byebug完成执行而不需要退出查询“是一个类似的答案。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36462112

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档