Skip to content

Commit

Permalink
Upgrade the irb command to use irb:debug integration
Browse files Browse the repository at this point in the history
This means that user will get an IRB session that has access to the debug
commands too by activating IRB's debug integration automatically:
https://github.com/ruby/irb#debugging-with-irb
  • Loading branch information
st0012 committed Oct 9, 2023
1 parent 1450ad0 commit bd8e44b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions debug.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]
spec.extensions = ['ext/debug/extconf.rb']

spec.add_dependency "irb", ">= 1.5.0" # for binding.irb(show_code: false)
spec.add_dependency "reline", ">= 0.3.1"
spec.add_dependency "irb", "~> 1.8.0" # for irb:debug integration
spec.add_dependency "reline", ">= 0.3.8"
end
15 changes: 8 additions & 7 deletions lib/debug/thread_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1038,13 +1038,14 @@ def wait_next_action_
when :call
result = frame_eval(eval_src)
when :irb
require 'irb' # prelude's binding.irb doesn't have show_code option
begin
result = frame_eval('binding.irb(show_code: false)', binding_location: true)
ensure
# workaround: https://github.com/ruby/debug/issues/308
Reline.prompt_proc = nil if defined? Reline
end
require "irb"
IRB.setup(location, argv: [])
workspace = IRB::WorkSpace.new(current_frame&.binding || TOPLEVEL_BINDING)
irb = IRB::Irb.new(workspace)
IRB.conf[:MAIN_CONTEXT] = irb.context
IRB::Debug.send(:configure_irb_for_debugger, irb)
SESSION.reset_ui(IRB::Debug::UI.new(thread, irb))
IRB::Debug.setup(irb)
when :display, :try_display
failed_results = []
eval_src.each_with_index{|src, i|
Expand Down

0 comments on commit bd8e44b

Please sign in to comment.