-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support seamless integration with ruby/debug #575
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
st0012
force-pushed
the
irb-debug-2
branch
8 times, most recently
from
May 25, 2023 17:15
2ea619c
to
1af942e
Compare
st0012
changed the title
Support native integration with ruby/debug
Support seamless integration with ruby/debug
May 27, 2023
tompng
reviewed
May 27, 2023
tompng
reviewed
Jun 6, 2023
st0012
added a commit
that referenced
this pull request
Jun 27, 2023
This makes sure `Context#evaluate` really just evaluates the input. It will also make #575's implementation cleaner.
tompng
pushed a commit
that referenced
this pull request
Jun 27, 2023
This makes sure `Context#evaluate` really just evaluates the input. It will also make #575's implementation cleaner.
st0012
force-pushed
the
irb-debug-2
branch
3 times, most recently
from
July 1, 2023 16:05
6f14b26
to
8f8b970
Compare
tompng
reviewed
Jul 15, 2023
vinistock
reviewed
Jul 20, 2023
st0012
force-pushed
the
irb-debug-2
branch
4 times, most recently
from
July 21, 2023 13:48
5e89aa1
to
0727006
Compare
st0012
force-pushed
the
irb-debug-2
branch
3 times, most recently
from
August 9, 2023 21:03
f3f334c
to
8e9f4ee
Compare
st0012
force-pushed
the
irb-debug-2
branch
3 times, most recently
from
August 11, 2023 22:30
cb96b24
to
0aa3f08
Compare
@tompng would you mind giving it another look when have time? Thx 🙏 |
Multi-irb makes a few assumptions: - IRB will manage all threads that host sub-irb sessions - All IRB sessions will be run on the threads created by IRB itself However, when using the debugger these assumptions are broken: - `debug` will freeze ALL threads when it suspends the session (e.g. when hitting a breakpoint, or performing step-debugging). - Since the irb-debug integration runs IRB as the debugger's interface, it will be run on the debugger's thread, which is not managed by IRB. So we should prevent the 2 features from being used at the same time. To do that, we check if the other feature is already activated when executing the commands that would activate the other feature.
tompng
approved these changes
Aug 13, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
IRB is completely a great debugger now 🎉
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Aug 13, 2023
(ruby/irb#575) * Support native integration with ruby/debug * Prevent using multi-irb and activating debugger at the same time Multi-irb makes a few assumptions: - IRB will manage all threads that host sub-irb sessions - All IRB sessions will be run on the threads created by IRB itself However, when using the debugger these assumptions are broken: - `debug` will freeze ALL threads when it suspends the session (e.g. when hitting a breakpoint, or performing step-debugging). - Since the irb-debug integration runs IRB as the debugger's interface, it will be run on the debugger's thread, which is not managed by IRB. So we should prevent the 2 features from being used at the same time. To do that, we check if the other feature is already activated when executing the commands that would activate the other feature. ruby/irb@d8fb3246be
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the debugging experience by keeping users within the IRB session when executing debugging commands. This ensures users retain multi-line input support and access to all IRB commands, while benefiting from
debug
's enhanced debugging functionalities.Simply put: this will be
pry-byebug
equivalent for IRB anddebug
.Demonstrations
Current Debugging Experience:
Current.debug.integration.mp4
Improved Debugging Experience:
Improved.debug.integration.mp4
Design & Implementation
Debugging commands execution is handled by
ExtendCommand::Debug#execute
, which performs several actions:binding.irb
call.Irb#debug_break
with the intended command.Irb#run
call viathrow :IRB_EXIT
.When
Irb#debug_break
is automatically called after stepiv
, the breakpoint triggers, executing the intended command.The new
IRB::Debug::UI
class andIrb#debug_readline
method transform IRB into the debugger session's UI. Depending on the user's input, the behavior varies:step 3
) are passed directly to the debugger.show_source Foo#bar
) are evaluated within the IRB session.my_object.my_method
) are passed to the debugger.After the debugger evaluates the input, it calls
Irb#debug_readline
again, maintaining the impression of a continuous IRB session.Known Limitations
_
variable is not functional untildebug
supports it.Resolves #521