Ruby debug

From wikinotes
Revision as of 13:44, 29 March 2020 by Will (talk | contribs) (→‎Usage)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Builtin ruby module, that provides an interactive debugger.


Usage

Run the ruby interpreter in debugger mode. Stops before first line is run, presents debugging prompt.

ruby -r debug yourmodule.rb

Commands

Very similar to gdb and pdb.
These commands are issued at the debugger prompt.

# standard commands
h[elp]       # print available commands
l[ist]       # list lines of code
c[ontinue]   # continue running normally (until next breakpoint)
s[tep]       # run next line (go inside function)
n[ext]       # run next line (skip inside function)

# new commands
w[here]      # print stacktrace
p <variable> # print variable value