ruby / irb

interactive Ruby
BSD 2-Clause "Simplified" License
392 stars 119 forks source link

Use correct binding in debug mode #1007

Closed tompng closed 1 month ago

tompng commented 2 months ago

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 https://github.com/ruby/debug/commit/4c873939864ef650cd135ba1fb1bd7fe123f27ac,