diff --git a/.github/workflows/protocol.yml b/.github/workflows/protocol.yml index c756a0538..b2889aab1 100644 --- a/.github/workflows/protocol.yml +++ b/.github/workflows/protocol.yml @@ -24,7 +24,7 @@ jobs: ruby-version: ['2.6', '2.7', '3.0', '3.1', 'head', 'debug'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, # change this to (see https://github.com/ruby/setup-ruby#versioning): diff --git a/.github/workflows/ruby-macos.yaml b/.github/workflows/ruby-macos.yaml index f3ef96c53..0274941df 100644 --- a/.github/workflows/ruby-macos.yaml +++ b/.github/workflows/ruby-macos.yaml @@ -24,7 +24,7 @@ jobs: ruby-version: ['3.2', 'head'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, # change this to (see https://github.com/ruby/setup-ruby#versioning): diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 5dcc41426..a41da836a 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -24,7 +24,7 @@ jobs: ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', 'head', 'debug'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, # change this to (see https://github.com/ruby/setup-ruby#versioning): diff --git a/.github/workflows/test_test.yml b/.github/workflows/test_test.yml index 9f83f3719..db4cb9e95 100644 --- a/.github/workflows/test_test.yml +++ b/.github/workflows/test_test.yml @@ -24,7 +24,7 @@ jobs: ruby-version: ['3.0', '3.1', '3.2', 'head', 'debug'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, # change this to (see https://github.com/ruby/setup-ruby#versioning): diff --git a/debug.gemspec b/debug.gemspec index f05d0faa7..a07018a77 100644 --- a/debug.gemspec +++ b/debug.gemspec @@ -28,5 +28,5 @@ Gem::Specification.new do |spec| 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 "reline", ">= 0.3.8" end diff --git a/lib/debug/console.rb b/lib/debug/console.rb index 2da261662..959b940e4 100644 --- a/lib/debug/console.rb +++ b/lib/debug/console.rb @@ -56,10 +56,10 @@ def readline_setup prompt Reline.prompt_proc = -> args, *kw do case state = parse_input(args.first, commands) when nil, :command - [prompt, prompt] + [prompt] when :ruby - [prompt.sub('rdbg'){colorize('ruby', [:RED])}] * 2 - end + [prompt.sub('rdbg'){colorize('ruby', [:RED])}] + end * args.size end Reline.completion_proc = -> given do @@ -96,7 +96,7 @@ def readline_setup prompt when nil buff when :ruby - colorize_code(buff.chomp) + colorize_code(buff) end end unless CONFIG[:no_hint] @@ -224,11 +224,11 @@ def deactivate end def load_history - read_history_file.count{|line| + read_history_file.each{|line| line.strip! history << line unless line.empty? - } + } if history.empty? + history.count end end # class Console end - diff --git a/lib/debug/session.rb b/lib/debug/session.rb index 50c9d8bf4..d3549ae44 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -1740,15 +1740,19 @@ def on_load iseq, src # check breakpoints if file_path @bps.find_all do |_key, bp| - LineBreakpoint === bp && bp.path_is?(file_path) + LineBreakpoint === bp && bp.path_is?(file_path) && (iseq.first_lineno..iseq.last_line).cover?(bp.line) end.each do |_key, bp| if !bp.iseq bp.try_activate iseq elsif reloaded @bps.delete bp.key # to allow duplicate - if nbp = LineBreakpoint.copy(bp, iseq) - add_bp nbp - end + + # When we delete a breakpoint from the @bps hash, we also need to deactivate it or else its tracepoint event + # will continue to be enabled and we'll suspend on ghost breakpoints + bp.delete + + nbp = LineBreakpoint.copy(bp, iseq) + add_bp nbp end end else # !file_path => file_path is not existing @@ -2490,7 +2494,7 @@ def trap sig, *command, &command_proc sig end - case sig&.to_s&.to_sym + case sym when :INT, :SIGINT if defined?(SESSION) && SESSION.active? && SESSION.intercept_trap_sigint? return SESSION.save_int_trap(command.empty? ? command_proc : command.first) diff --git a/lib/debug/thread_client.rb b/lib/debug/thread_client.rb index 57a802615..3ec53fb81 100644 --- a/lib/debug/thread_client.rb +++ b/lib/debug/thread_client.rb @@ -614,7 +614,7 @@ def get_consts expr = nil, only_self: false, &block if expr && !expr.empty? begin _self = frame_eval(expr, re_raise: true) - rescue Exception => e + rescue Exception # ignore else if M_KIND_OF_P.bind_call(_self, Module) diff --git a/test/console/backtrace_test.rb b/test/console/backtrace_test.rb index 52b1238a1..dd1316ee5 100644 --- a/test/console/backtrace_test.rb +++ b/test/console/backtrace_test.rb @@ -22,7 +22,7 @@ def program 14| end 15| end 16| - 17| 3.times do + 17| [1, 2, 3].each do 18| Foo.new.first_call 19| end RUBY @@ -33,7 +33,7 @@ def test_backtrace_prints_c_method_frame type 'b 18' type 'c' type 'bt' - assert_line_text(/\[C\] Integer#times/) + assert_line_text(/\[C\] Array#each/) type 'kill!' end end diff --git a/test/console/break_test.rb b/test/console/break_test.rb index 2b9b1e6f8..dc06f3d1d 100644 --- a/test/console/break_test.rb +++ b/test/console/break_test.rb @@ -873,6 +873,34 @@ def test_break_on_reloaded_file type 'c' end end + + def test_removing_breakpoint_on_reloaded_file + code = <<~'DEBUG_CODE' + 1| require 'tempfile' + 2| tf = Tempfile.new('debug_gem_test', mode: File::TRUNC) + 3| tf.write(<<~RUBY) + 4| def foo + 5| "hello" + 6| end + 7| RUBY + 8| tf.close + 9| load tf.path + 10| alias bar foo + 11| debugger do: "b #{tf.path}:2" + 12| bar + 13| load tf.path + 14| bar + 15| load tf.path + 16| bar + DEBUG_CODE + + debug_code code do + type "c" + assert_line_num 2 + + type "c" + end + end end class BreakAtLineTest < ConsoleTestCase diff --git a/test/console/control_flow_commands_test.rb b/test/console/control_flow_commands_test.rb index 6e7ff98da..de19c267b 100644 --- a/test/console/control_flow_commands_test.rb +++ b/test/console/control_flow_commands_test.rb @@ -226,7 +226,7 @@ def test_finish end def test_finish_0 - omit "This test failed with only reline environeent. It may be bug of Reline" unless defined?(Readline) + omit "This test failed with only reline environment. It may be bug of Reline" unless defined?(Readline) debug_code program do type 'b 8'