Learn how to use ruby/debug

Posted . Visible to the public.

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
Niklas Hä.
Last edit
Michael Leimstädtner
Keywords
debugging, pry, byebug
License
Source code in this card is licensed under the MIT License.
Posted by Niklas Hä. to makandra dev (2024-10-15 06:49)