-
Notifications
You must be signed in to change notification settings - Fork 136
Closed
Description
Background
When debugging programs with Ruby 2.7+ , it's common to start with adding binding.irb breakpoints in the code. This is because irb is the only console-based tool (including REPLs and debuggers) that doesn't require installation nor require.
However, because irb is a REPL and lacks debugger features like step-debugging, frame navigation...etc., users may need to switch to debuggers like ruby/debug for advanced debugging.
And currently, that switch looks like this:
- Exit the current
irbsession. - Add
require "debug"if it's not yet required. - Replace
binding.irbwithruby/debug's breakpoints likebinding.bordebugger(they're the same). - Rerun the program and start debugging.
It's a 4-step process and requires switching between terminal and editor.
During a discussion with @k0kubun, he mentioned that maybe irb can help reduce the pain.
Proposal
Add a new debug command to irb, which when being executed will
- Run
require "debug/session"and start the debugger.- If it causes
LoadError, it means the newdebuggem is not installed. So it will print a message to remind the user instead.
- If it causes
- Replace the current
irbsession with a newdebugconsole. - The user can start debugging at the same location as
binding.irbwas placed.
With this command, a user's irb -> debug switch would be:
- Type
debugin theirbsession. - Start debugging.
Demo
Discussion Points
- Should the command be
debugordebugger?debug:- As a verb it seems to convey the intention well as "Debug in the current context"
- On the other hand, it's another debugging related name to remember.
debugger:- It's the same as the
debuggerstatementruby/debugalready has. - It may give a false impression that we're simply calling the same statement in
irb.
- It's the same as the
- When users exit the debugger, should they exit completely or return to
irb?- IMO, it should exit completely so users don't need to exit twice.
- Because
irbregisters autocompletion logic toreline,debug's console (also powered byreline) will inherit that too.- Perhaps it should be suspended to avoid unexpected side-effects?
Metadata
Metadata
Assignees
Labels
No labels
