如何在Byebug中没有断点继续

ard*_*vis 3 ruby byebug

使用byebuggem让我能够continue直到下一个断点:

(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
Run Code Online (Sandbox Code Playgroud)

我看了一遍,我找不到"继续没有断点"的方法.我能想到的唯一方法是删除或评论byebug语句,退出q!并重新启动测试.

如何在不停止byebugRuby 中的其他语句的情况下继续?

fan*_*ing 7

您可以使用continue!或别名c!

看到这个 PR https://github.com/deivid-rodriguez/byebug/pull/546


Luc*_*son 5

一个byebug在你的代码的方法调用是不是一个"断点"(引用的思维在帮助输出断点).

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

既然byebug只是一个方法调用,你可以使它成为条件:

byebug if SomeModule.byebug?
Run Code Online (Sandbox Code Playgroud)

然后,在SomeModule中,您可以使用全局变量来打开/关闭它.您要么在调用byebug的所有调用时都这样做,要么可以修改byebug方法来执行相同的操作,alias_method_chain或类似的操作.

" 让Byebug完成执行而不退出Pry "是一个类似的答案.


est*_*ani 5

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

Byebug.mode = :off
Run Code Online (Sandbox Code Playgroud)

您无法重新打开它,因为它不会再附加到自身上,但这很方便,例如,在调试要完成运行的脚本时。