This talk Show archive.org snapshot shows simple and advanced usages of the ruby/debug Show archive.org snapshot debugger. It goes through a step by step debugging workflow.
Here are some command examples:
(rdbg) step 2 # step twice
(rdbg) info # show current scope, including self
(rdbg) bt # show backtrace
(rdbg) frame 3 # go directly to frame 3
(rdbg) break User#email # add a breakpoint in the email instance method
(rdbg) catch SomeException # break when SomeException is raised
Some advanced examples for scriptable breakpoints:
debugger(pre: "info ;; puts @foo ;; info ;; bt ;; break @user.name") # starts debugging session after executing each of the pre commands
debugger(do: "break @user.name ;; pre info") # runs commands and continues immediately afterwards, breaking in `@user.name` and running info at the breakpoint
Remote debugging
If for some reason you cannot send stdin correctly to the debugged process (e.g. because you're running multiple processes with bin/dev), you can use remote debugging instead. Start your process with RUBY_DEBUG_OPEN set, e.g. with RUBY_DEBUG_OPEN=1 bin/dev. As soon as you run into the debugger statement, you'll see
DEBUGGER: wait for debugger connection.... You can now connect to the debugger with rdbg -A and should be able to type correctly again.
If you want to use the chrome devtools as a debugger UI instead, you can also just use RUBY_DEBUG_OPEN=chrome. The chrome devtools will open and connect to the debugger automatically.
Read the docs about remote debugging Show archive.org snapshot for details.