Even though you can get 90% of debugging done with up to 5 basic byebug
commands, it comes in handy with it's features for many use cases beyond that to make your life easier.
For this cheatsheat I tried to structure the most useful commands by different use cases, such that a practical oriented overview of all the commands can be gathered by going over this cheatsheet. For some commands I added some tips for their usage and further details on their subcommands
help
command anytime during a bybebug session to find out more about commandsquit
-- Exits byebughelp <cmd> <subcmd>
-- show information about any command with it's aliases and parameters
help
, help <cmd>
and help <cmd> <subcmd>
, ...history
-- display history of commandsirb
-- starts an irb console which helps to
execute any command that conflicts with byebug
Show archive.org snapshot
continue [n]
-- Runs until program ends, hits a breakpoint or reaches line n
continue!
- execute to end of program by ignoring all breakpointsskip
-- Runs until the next breakpoint as long as it is different from the current onestep [n]
-- Steps into blocks or methods n
timesnext [n]
-- Runs n
lines of code within the same frameframe [n]
-- Moves to a frame in the n
-th call stack
where
to find out the numbersfinish [n]
-- Runs the program until the n
-th frame returnsup
-- Moves to a higher frame in the stack tracedown
-- Moves to a lower frame in the stack tracewhere
-- Displays the backtracelist [[-=]] [ nn-mm]
-- Lists coming lines of source code from last breakpoint
list-
lists previous code lineslist=
lists code from current line around that linelist d-f
lists lines from d
to f
info [subcommand]
-- Shows several informations about the program and the current debugging session,[subcommand]
can be any of:
breakpoints
display
-- displayed variablesfile
, line
, program
args
of the current stack framevar [type] [object]
-- Shows specified variables and its values,[type]
(and possibly [object]
) can be used as:
const <object>
-- listing variables and their values in <object>.constant
instance <object>
-- listing <object>.instance_variables.
instance
-- instance_variables of self.local
-- local variables.global
-- global variablesmethod
-- shows variables of specified object, class or module
method instance <object>
-- The same as running <object>.instance_methods(false)
.method <class-or-module>
-- The same as running <class-or-module>.methods
.display
/ undisplay [<expression>]
- display or undisplays an expression at stopped breakpoint
enable
/ disable [id]
can be used activate and deactivate displayed valuesinfo display
can be used to show all id's of displayed variablescondition <i>[ <expression>]
-- Sets conditions on breakpoint i
to stop only when <expression>
is true
info breakpoints
can be used to show all id's of breakpointscatch <exception>
-- Catches the specified exception
catch off
catch <exception> off
thread
-- Commands to manipulate threads
byebug
supports stopping, switching, resuming and listing all current threadsstopped at the breakpointbreak [n]
- Set breakpoint at line n
in the current file
break [<file>:]<line>
delete
-- All breakpoints can be deleted by using the delete
command
info breakpoints
to find out the breakpoint's idWhile debugging you don't have to type out all commands presented above. For most of them it is enough to type the first letter, e.g.:
c
instead of continue
c!
s
instead of step
l=
instead of list=