Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct binding in debug mode #1007

Merged
merged 1 commit into from
Oct 2, 2024
Merged

Conversation

tompng
Copy link
Member

@tompng tompng commented Sep 21, 2024

Debug evaluates code in frame.eval_binding, not frame.binding

irb(main):001> debug
irb:rdbg(main):002> tc = DEBUGGER__::SESSION.instance_variable_get(:@tc)
#<DBG:TC 1:running@a.rb:1:in `<main>'>
irb:rdbg(main):003> foobar = 1
1
irb:rdbg(main):004> tc.current_frame.binding.local_variables
[:_]
irb:rdbg(main):005> tc.current_frame.eval_binding.local_variables
[:foobar, :tc, :_]

Fixes this command and colorization bug. (left: master branch, right: this pull request)
debug_binding_before_after

eval_binding is added in debug-1.0.0.rc1 ruby/debug@4c87393,

In debug command, IRB's context was using wrong binding.
Some code colorization, command detection failed because binding.local_variable returned wrong value.
@tompng tompng added the bug Something isn't working label Sep 21, 2024
@tompng tompng merged commit 68f718d into ruby:master Oct 2, 2024
30 checks passed
@tompng tompng deleted the fix_debug_binding branch October 2, 2024 03:18
matzbot pushed a commit to ruby/ruby that referenced this pull request Oct 2, 2024
(ruby/irb#1007)

In debug command, IRB's context was using wrong binding.
Some code colorization, command detection failed because binding.local_variable returned wrong value.

ruby/irb@68f718de21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants