Skip to content

Commit

Permalink
Merge branch 'master' into share-variable-inspection-logic
Browse files Browse the repository at this point in the history
  • Loading branch information
amomchilov authored Sep 26, 2023
2 parents c62eb1e + 840d8ad commit 1c06d55
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ruby-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion debug.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions lib/debug/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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

14 changes: 9 additions & 5 deletions lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/debug/thread_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/console/backtrace_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
28 changes: 28 additions & 0 deletions test/console/break_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/console/control_flow_commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 1c06d55

Please sign in to comment.