Created
May 9, 2011 12:52
-
-
Save mcrmfc/962462 to your computer and use it in GitHub Desktop.
ruby-debug cheat sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To end the debugging session and return control to the app: | |
quit | |
To find out where you are: | |
where | |
Note, this will print out a stack trace only if you’ve added the Debugger.start as specified above. If you haven’t, where will only print out the line number and file name of where execution has reached. | |
To see where you are in context (current line with a few lines before and after): | |
list | |
To print out the value of an individual variable: | |
p my_var | |
To print out all local and instance variables in the current stack frame: | |
info variables | |
To go to the next step (equivalent of ‘step into’): | |
step | |
To step over the next line: | |
next | |
To let the app run to the next breakpoint: | |
continue | |
To restart the app: | |
restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many folks like "set autoeval on". In the newer *trepanning debuggers that is on by default. We don't change it for ruby-debug because of the confusion it might cause on entering an invalid command.
Anothre popular setting is "set different". When on, it causes stopping at a different line. Sometimes stepping is tedious without it. There are suffixes + and - to step and next which change this for the next command.
Another popular command is "irb" to go into an irb session.
You list "continue" to go to the next breakpoint (or debugger call), but nothing about setting breakpoints itself. And a popular option to "continue" is to give a line number which sets that line number as a temporary breakpoint. A temporary breakpoint is one which is removed as soon as it is hit. So, for example, "continue 8" would run until line 8.