Changes
- [This talk](https://www.youtube.com/watch?v=gseo4vdmSjE) shows simple and advanced usages of the [ruby/debug](https://github.com/ruby/debug) debugger. It goes through a step by step debugging workflow.
- Here are some command examples:
- ```plain
- (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:
- ```rb
- 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](https://github.com/ruby/debug?tab=readme-ov-file#remote-debugging) for details.
- +
Posted by Niklas Hä. to makandra dev (2025-12-08 12:36)