Skip to content

Use correct binding in debug mode - #1007

Merged
tompng merged 1 commit into
ruby:masterfrom
tompng:fix_debug_binding
Oct 2, 2024
Merged

tompng merged 1 commit into
ruby:masterfrom
tompng:fix_debug_binding

Conversation

@tompng

@tompng tompng commented Sep 21, 2024 •

Copy link
Copy Markdown
Member

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
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants