general Informations and Key shortcuts for Kent Sibilev's great ruby-debug gem.
(http://www.datanoise.com/ruby-debug/,
http://rubyforge.org/projects/ruby-debug/)
Installation
gem install ruby-debug
Usage
rdebug [options] <script.rb> -- <script.rb parameters>
startup settings:
rdebug reads its configuration file at startup.
create a file ~/.rdebugrc with this content:
set autolist
set autoeval
set autoreload
after starting rdebug like: rdebug script/server
enter 'c' and 'return' for starting up rdebug finally.
Most important commands:
r[eload], n[ext], c[ont]
Commands (available as 'help <command-name>' in active debug mode)
backtrace (alias for where)
$ bt|backtrace
break
$ b[reak] file:line [if expr]
$ b[reak] class(.|#)method [if expr]
set breakpoint to some position, (optionally) if expr == true
$ b[reak] list breakpoints
catch
$ cat[ch] (show catchpoint)
$ cat[ch] <an Exception> (set catchpoint to an exception)
cont
$ c[ont][ nnn] (run until program ends or hits breakpoint or reaches line nnn)
delete
$ del[ete][ nnn] (delete some or all breakpoints)
display
$ disp[lay] <expression> (add expression into display expression list)
$ disp[lay] (display expression list)
down
$ down[count] (move to lower frame)
eval
$ e[val] expression evaluate expression and print its value, alias for p.
* NOTE - to turn on autoeval, use 'set autoeval'
exit
$ q[uit] exit from debugger,
$ exit alias to quit
finish
$ fin[ish] return to outer frame
frame
$ f[rame] frame-number
Move the current frame to the specified frame number.
A negative number indicates position from the other end.
So 'frame -1' moves to the oldest frame, and 'frame 0' moves to
the newest frame.
help
$ h[elp] print help
$ h[elp] command print help on command
irb
$ irb starts an IRB session. (EXPERIMENTAL)
list
$ l[ist] list forward
$ l[ist] - list backward
$ l[ist] = list current line
$ l[ist] nn-mm list given lines
method
$ m[ethod] i[nstance] <obj> show methods of object
$ m[ethod] <class|module> show instance methods of class or module
next
$ n[ext][+][ nnn] step over once or nnn times,
'+' forces to move to another line
p
p$ expression evaluate expression and print its value
pp
$ pp expression evaluate expression and pretty-print its value
quit
$ q[uit] exit from debugger,
$ exit alias to quit
reload
$ r[eload] forces source code reloading
restart
$ restart|R [args]
Restart the program. This is is a re-exec - all debugger state
is lost. If command arguments are passed those are used.
save
$ save FILE saves current breakpoints and catchpoint as a script file
script
script$ FILE executes a script file
set
$ set <setting>, where <setting>:
$ autolist - execute 'list' command on every breakpoint
$ autoeval - evaluate every unrecognized command
$ autoreload - enables automatic source code reloading
$ autoirb - debugger invokes IRB on every stop
$ trace - display stack trace when 'eval' raises exception
$ framefullpath - frame will display full file names
$ frameclassname - frame will display class names
$ forcestep - make sure 'next/step' commands always move to a new line
To disable setting, use 'no' prefix, like 'noautolist'
step
$ s[tep][ nnn] step (into methods) once or nnn times
thread
$ th[read] l[ist] list all threads
$ th[read] [sw[itch]] <nnn> switch thread context to nnn
$ th[read] stop <nnn> stop thread nnn
$ th[read] c[ur[rent]] show current thread
$ th[read] resume <nnn> resume thread nnn
trace
$ tr[ace] (on|off) set trace mode of current thread
$ tr[ace] (on|off) all set trace mode of all threads
undisplay
$ undisp[lay][ nnn] delete one particular or all display expressions
up
$ up[count] move to higher frame
var
$ v[ar] c[onst] <object> show constants of object
$ v[ar] g[lobal] show global variables
$ v[ar] i[nstance] <object> show instance variables of object
$ v[ar] l[ocal] show local variables
where
$ w[here] display frames