Ruby debug

From wikinotes

Builtin ruby module, that provides an interactive debugger.


Documentation

cli commands https://github.com/ruby/debug#debug-command-on-the-debug-console

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