From 76e03521a9ae36c7dc620bb1ef2bc1774ccc3e12 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sat, 20 Nov 2021 21:44:14 +0000 Subject: [PATCH 1/9] Add path option to CatchBreakpoint --- lib/debug/breakpoint.rb | 4 +++- lib/debug/session.rb | 5 +++-- test/debug/catch_test.rb | 48 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/lib/debug/breakpoint.rb b/lib/debug/breakpoint.rb index 37102ab72..7eddf7b08 100644 --- a/lib/debug/breakpoint.rb +++ b/lib/debug/breakpoint.rb @@ -263,13 +263,14 @@ class CatchBreakpoint < Breakpoint attr_reader :last_exc include SkipPathHelper - def initialize pat, cond: nil, command: nil + def initialize pat, cond: nil, command: nil, path: nil @pat = pat.freeze @key = [:catch, @pat].freeze @last_exc = nil @cond = cond @command = command + @path = path super() end @@ -279,6 +280,7 @@ def setup next if skip_path?(tp.path) exc = tp.raised_exception next if SystemExit === exc + next if @path && !tp.path.match?(@path) next if !safe_eval(tp.binding, @cond) if @cond should_suspend = false diff --git a/lib/debug/session.rb b/lib/debug/session.rb index 6a85ad069..b3c53a858 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -1251,7 +1251,7 @@ def delete_bp arg = nil end end - BREAK_KEYWORDS = %w(if: do: pre:).freeze + BREAK_KEYWORDS = %w(if: do: pre: path:).freeze def parse_break arg mode = :sig @@ -1293,8 +1293,9 @@ def repl_add_catch_breakpoint arg expr = parse_break arg.strip cond = expr[:if] cmd = ['catch', expr[:pre], expr[:do]] if expr[:pre] || expr[:do] + path = Regexp.compile(expr[:path]) if expr[:path] - bp = CatchBreakpoint.new(expr[:sig], cond: cond, command: cmd) + bp = CatchBreakpoint.new(expr[:sig], cond: cond, command: cmd, path: path) add_bp bp end diff --git a/test/debug/catch_test.rb b/test/debug/catch_test.rb index a01ffd548..22aa03414 100644 --- a/test/debug/catch_test.rb +++ b/test/debug/catch_test.rb @@ -148,4 +148,52 @@ def test_catch_with_namespace_stops_at_exception end end end + + class PathOptionTest < TestCase + def additional_file + <<~RUBY + def bar + raise "bar" + rescue + end + RUBY + end + + ADDITIONAL_FILE_BASENAME = __FILE__.hash.abs.to_s(16) + + def program(additional_file_path) + <<~RUBY + 1| load "#{additional_file_path}" + 2| + 3| def foo + 4| raise "foo" + 5| rescue + 6| end + 7| + 8| foo + 9| bar + RUBY + end + + def with_tempfile + t = Tempfile.create([ADDITIONAL_FILE_BASENAME, '.rb']).tap do |f| + f.write(additional_file) + f.close + end + yield t + ensure + File.unlink t if t + end + + def test_catch_only_stops_when_path_matches + with_tempfile do |additional_file| + debug_code(program(additional_file.path)) do + type "catch RuntimeError path: #{additional_file.path}" + type 'c' + assert_line_text(/bar/) + type 'c' + end + end + end + end end From 1d6aae2d3bab9baa6bcd00a037c98b418224fe44 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sat, 20 Nov 2021 21:56:19 +0000 Subject: [PATCH 2/9] Add path option to CheckBreakpoint --- lib/debug/breakpoint.rb | 4 +- lib/debug/session.rb | 7 +-- test/debug/break_test.rb | 96 +++++++++++++++++++++++++++++++--------- 3 files changed, 82 insertions(+), 25 deletions(-) diff --git a/lib/debug/breakpoint.rb b/lib/debug/breakpoint.rb index 7eddf7b08..66c433702 100644 --- a/lib/debug/breakpoint.rb +++ b/lib/debug/breakpoint.rb @@ -305,9 +305,10 @@ def description end class CheckBreakpoint < Breakpoint - def initialize expr + def initialize expr, path @expr = expr.freeze @key = [:check, @expr].freeze + @path = path super() end @@ -317,6 +318,7 @@ def setup next if tp.path.start_with? __dir__ next if tp.path.start_with? ' Date: Sat, 20 Nov 2021 22:00:55 +0000 Subject: [PATCH 3/9] Add path option to MethodBreakpoint --- lib/debug/breakpoint.rb | 4 +++- lib/debug/session.rb | 2 +- lib/debug/thread_client.rb | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/debug/breakpoint.rb b/lib/debug/breakpoint.rb index 66c433702..bd06b1d86 100644 --- a/lib/debug/breakpoint.rb +++ b/lib/debug/breakpoint.rb @@ -385,7 +385,7 @@ def to_s class MethodBreakpoint < Breakpoint attr_reader :sig_method_name, :method - def initialize b, klass_name, op, method_name, cond: nil, command: nil + def initialize b, klass_name, op, method_name, cond: nil, command: nil, path: nil @sig_klass_name = klass_name @sig_op = op @sig_method_name = method_name @@ -397,6 +397,7 @@ def initialize b, klass_name, op, method_name, cond: nil, command: nil @cond = cond @cond_class = nil @command = command + @path = path @key = "#{klass_name}#{op}#{method_name}".freeze super(false) @@ -406,6 +407,7 @@ def setup @tp = TracePoint.new(:call){|tp| next if !safe_eval(tp.binding, @cond) if @cond next if @cond_class && !tp.self.kind_of?(@cond_class) + next if @path && !tp.path.match?(@path) next if @override_method ? (caller_locations(2, 1).first.to_s.start_with?(__dir__)) : tp.path.start_with?(__dir__) suspend diff --git a/lib/debug/session.rb b/lib/debug/session.rb index a96fc1fdf..2bae2ee56 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -1279,7 +1279,7 @@ def repl_add_breakpoint arg when /\A(.+)[:\s+](\d+)\z/ add_line_breakpoint $1, $2.to_i, cond: cond, command: cmd when /\A(.+)([\.\#])(.+)\z/ - @tc << [:breakpoint, :method, $1, $2, $3, cond, cmd] + @tc << [:breakpoint, :method, $1, $2, $3, cond, cmd, path] return :noretry when nil add_check_breakpoint cond, path diff --git a/lib/debug/thread_client.rb b/lib/debug/thread_client.rb index 5161f6409..c2581cfad 100644 --- a/lib/debug/thread_client.rb +++ b/lib/debug/thread_client.rb @@ -635,8 +635,8 @@ def class_method_map(classes) def make_breakpoint args case args.first when :method - klass_name, op, method_name, cond, cmd = args[1..] - bp = MethodBreakpoint.new(current_frame.binding, klass_name, op, method_name, cond: cond, command: cmd) + klass_name, op, method_name, cond, cmd, path = args[1..] + bp = MethodBreakpoint.new(current_frame.binding, klass_name, op, method_name, cond: cond, command: cmd, path: path) begin bp.enable rescue Exception => e From 82dd6a2b6b3c0eb628198b0249796b2fd4de3c5b Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 21 Nov 2021 16:33:19 +0000 Subject: [PATCH 4/9] MethodBreakpoint should use call location instead of tp.path for path check --- lib/debug/breakpoint.rb | 6 ++- test/debug/break_test.rb | 83 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/lib/debug/breakpoint.rb b/lib/debug/breakpoint.rb index bd06b1d86..c6ab28945 100644 --- a/lib/debug/breakpoint.rb +++ b/lib/debug/breakpoint.rb @@ -407,8 +407,10 @@ def setup @tp = TracePoint.new(:call){|tp| next if !safe_eval(tp.binding, @cond) if @cond next if @cond_class && !tp.self.kind_of?(@cond_class) - next if @path && !tp.path.match?(@path) - next if @override_method ? (caller_locations(2, 1).first.to_s.start_with?(__dir__)) : tp.path.start_with?(__dir__) + + caller_location = caller_locations(2, 1).first.to_s + next if @path && !caller_location.match?(@path) + next if caller_location.start_with?(__dir__) suspend } diff --git a/test/debug/break_test.rb b/test/debug/break_test.rb index cac2d7699..434e2ca22 100644 --- a/test/debug/break_test.rb +++ b/test/debug/break_test.rb @@ -203,6 +203,50 @@ def test_debugger_doesnt_stop_when_other_instance_calls_the_inherited_method type "c" end end + + class PathOptionTest < TestCase + def additional_file + <<~RUBY + Foo.new.bar + RUBY + end + + ADDITIONAL_FILE_BASENAME = __FILE__.hash.abs.to_s(16) + + def program(additional_file_path) + <<~RUBY + 1| class Foo + 2| def bar; end + 3| end + 4| + 5| Foo.new.bar + 6| + 7| load "#{additional_file_path}" + RUBY + end + + def with_tempfile + t = Tempfile.create([ADDITIONAL_FILE_BASENAME, '.rb']).tap do |f| + f.write(additional_file) + f.close + end + yield t + ensure + File.unlink t if t + end + + def test_break_only_stops_when_path_matches + with_tempfile do |additional_file| + debug_code(program(additional_file.path)) do + type "break Foo#bar path: #{additional_file.path}" + type 'c' + assert_line_text(/#{ADDITIONAL_FILE_BASENAME}/) + type 'c' + assert_finish + end + end + end + end end class BreakAtCMethodsTest < TestCase @@ -275,6 +319,45 @@ def test_break_C_method_with_singleton_method type 'c' end end + + class PathOptionTest < TestCase + def additional_file + <<~RUBY + 1.abs + RUBY + end + + ADDITIONAL_FILE_BASENAME = __FILE__.hash.abs.to_s(16) + + def program(additional_file_path) + <<~RUBY + 1| load "#{additional_file_path}" + 2| 1.abs + RUBY + end + + def with_tempfile + t = Tempfile.create([ADDITIONAL_FILE_BASENAME, '.rb']).tap do |f| + f.write(additional_file) + f.close + end + yield t + ensure + File.unlink t if t + end + + def test_break_only_stops_when_path_matches + with_tempfile do |additional_file| + debug_code(program(additional_file.path)) do + type "break Integer#abs path: #{additional_file.path}" + type 'c' + assert_line_text(/#{ADDITIONAL_FILE_BASENAME}/) + type 'c' + assert_finish + end + end + end + end end class BreakAtCMethod2Test < TestCase From 4b66d575c942d989c825849698c0da2af0eb46cb Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 21 Nov 2021 17:04:49 +0000 Subject: [PATCH 5/9] Refactor Breakpoint tests --- test/debug/break_test.rb | 96 +++++++++++-------------------- test/debug/catch_test.rb | 26 +++------ test/support/extra_file_helper.rb | 15 +++++ test/support/test_case.rb | 1 + 4 files changed, 58 insertions(+), 80 deletions(-) create mode 100644 test/support/extra_file_helper.rb diff --git a/test/debug/break_test.rb b/test/debug/break_test.rb index 434e2ca22..5504696bc 100644 --- a/test/debug/break_test.rb +++ b/test/debug/break_test.rb @@ -205,15 +205,15 @@ def test_debugger_doesnt_stop_when_other_instance_calls_the_inherited_method end class PathOptionTest < TestCase - def additional_file + include ExtraFileHelper + + def extra_file <<~RUBY Foo.new.bar RUBY end - ADDITIONAL_FILE_BASENAME = __FILE__.hash.abs.to_s(16) - - def program(additional_file_path) + def program(extra_file_path) <<~RUBY 1| class Foo 2| def bar; end @@ -221,26 +221,16 @@ def program(additional_file_path) 4| 5| Foo.new.bar 6| - 7| load "#{additional_file_path}" + 7| load "#{extra_file_path}" RUBY end - def with_tempfile - t = Tempfile.create([ADDITIONAL_FILE_BASENAME, '.rb']).tap do |f| - f.write(additional_file) - f.close - end - yield t - ensure - File.unlink t if t - end - def test_break_only_stops_when_path_matches - with_tempfile do |additional_file| - debug_code(program(additional_file.path)) do - type "break Foo#bar path: #{additional_file.path}" + with_extra_tempfile do |extra_file| + debug_code(program(extra_file.path)) do + type "break Foo#bar path: #{extra_file.path}" type 'c' - assert_line_text(/#{ADDITIONAL_FILE_BASENAME}/) + assert_line_text(/#{extra_file.path}/) type 'c' assert_finish end @@ -321,37 +311,27 @@ def test_break_C_method_with_singleton_method end class PathOptionTest < TestCase - def additional_file + include ExtraFileHelper + + def extra_file <<~RUBY 1.abs RUBY end - ADDITIONAL_FILE_BASENAME = __FILE__.hash.abs.to_s(16) - - def program(additional_file_path) + def program(extra_file_path) <<~RUBY - 1| load "#{additional_file_path}" + 1| load "#{extra_file_path}" 2| 1.abs RUBY end - def with_tempfile - t = Tempfile.create([ADDITIONAL_FILE_BASENAME, '.rb']).tap do |f| - f.write(additional_file) - f.close - end - yield t - ensure - File.unlink t if t - end - def test_break_only_stops_when_path_matches - with_tempfile do |additional_file| - debug_code(program(additional_file.path)) do - type "break Integer#abs path: #{additional_file.path}" + with_extra_tempfile do |extra_file| + debug_code(program(extra_file.path)) do + type "break Integer#abs path: #{extra_file.path}" type 'c' - assert_line_text(/#{ADDITIONAL_FILE_BASENAME}/) + assert_line_text(/#{extra_file.path}/) type 'c' assert_finish end @@ -640,40 +620,32 @@ def test_conditional_breakpoint_shows_error end class PathOptionTest < TestCase - def additional_file + include ExtraFileHelper + + def extra_file <<~RUBY - a = 1 - b = 200 + a = 100 + b = 1 + _ = 0 RUBY end - ADDITIONAL_FILE_BASENAME = __FILE__.hash.abs.to_s(16) - - def program(additional_file_path) + def program(extra_file_path) <<~RUBY - 1| a = 1 - 2| b = 100 - 3| load "#{additional_file_path}" + 1| a = 200 + 2| b = 1 + 3| _ = 0 + 4| load "#{extra_file_path}" RUBY end - def with_tempfile - t = Tempfile.create([ADDITIONAL_FILE_BASENAME, '.rb']).tap do |f| - f.write(additional_file) - f.close - end - yield t - ensure - File.unlink t if t - end - def test_conditional_breakpoint_only_stops_when_path_matches - with_tempfile do |additional_file| - debug_code(program(additional_file.path)) do - type "break if: a == 1 path: #{additional_file.path}" + with_extra_tempfile do |extra_file| + debug_code(program(extra_file.path)) do + type "break if: b == 1 path: #{extra_file.path}" type 'c' - assert_line_text(/#{additional_file.path}/) - assert_line_text(/b = 200/) + type 'a + b' + assert_line_text(/101/) type 'c' end end diff --git a/test/debug/catch_test.rb b/test/debug/catch_test.rb index 22aa03414..a6a0cabf4 100644 --- a/test/debug/catch_test.rb +++ b/test/debug/catch_test.rb @@ -150,7 +150,9 @@ def test_catch_with_namespace_stops_at_exception end class PathOptionTest < TestCase - def additional_file + include ExtraFileHelper + + def extra_file <<~RUBY def bar raise "bar" @@ -159,11 +161,9 @@ def bar RUBY end - ADDITIONAL_FILE_BASENAME = __FILE__.hash.abs.to_s(16) - - def program(additional_file_path) + def program(extra_file_path) <<~RUBY - 1| load "#{additional_file_path}" + 1| load "#{extra_file_path}" 2| 3| def foo 4| raise "foo" @@ -175,20 +175,10 @@ def program(additional_file_path) RUBY end - def with_tempfile - t = Tempfile.create([ADDITIONAL_FILE_BASENAME, '.rb']).tap do |f| - f.write(additional_file) - f.close - end - yield t - ensure - File.unlink t if t - end - def test_catch_only_stops_when_path_matches - with_tempfile do |additional_file| - debug_code(program(additional_file.path)) do - type "catch RuntimeError path: #{additional_file.path}" + with_extra_tempfile do |extra_file| + debug_code(program(extra_file.path)) do + type "catch RuntimeError path: #{extra_file.path}" type 'c' assert_line_text(/bar/) type 'c' diff --git a/test/support/extra_file_helper.rb b/test/support/extra_file_helper.rb new file mode 100644 index 000000000..bd599e351 --- /dev/null +++ b/test/support/extra_file_helper.rb @@ -0,0 +1,15 @@ +require 'securerandom' + +module DEBUGGER__ + module ExtraFileHelper + def with_extra_tempfile + t = Tempfile.create([SecureRandom.hex(5), '.rb']).tap do |f| + f.write(extra_file) + f.close + end + yield t + ensure + File.unlink t if t + end + end +end diff --git a/test/support/test_case.rb b/test/support/test_case.rb index a8740eb95..b0c7b8b70 100644 --- a/test/support/test_case.rb +++ b/test/support/test_case.rb @@ -5,6 +5,7 @@ require_relative 'utils' require_relative 'assertions' +require_relative 'extra_file_helper' module DEBUGGER__ class TestCase < Test::Unit::TestCase From cd24a3948896ab529dd10b1c531bf1e7a32e3545 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 21 Nov 2021 19:33:15 +0000 Subject: [PATCH 6/9] path option should supersede skip_path config --- lib/debug/breakpoint.rb | 9 +++++++-- test/debug/catch_test.rb | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/debug/breakpoint.rb b/lib/debug/breakpoint.rb index c6ab28945..d74c41aba 100644 --- a/lib/debug/breakpoint.rb +++ b/lib/debug/breakpoint.rb @@ -277,10 +277,15 @@ def initialize pat, cond: nil, command: nil, path: nil def setup @tp = TracePoint.new(:raise){|tp| - next if skip_path?(tp.path) exc = tp.raised_exception next if SystemExit === exc - next if @path && !tp.path.match?(@path) + + if @path + next if !tp.path.match?(@path) + elsif skip_path?(tp.path) + next + end + next if !safe_eval(tp.binding, @cond) if @cond should_suspend = false diff --git a/test/debug/catch_test.rb b/test/debug/catch_test.rb index a6a0cabf4..0e1c49fab 100644 --- a/test/debug/catch_test.rb +++ b/test/debug/catch_test.rb @@ -185,5 +185,24 @@ def test_catch_only_stops_when_path_matches end end end + + def test_the_path_option_supersede_skip_path_config + with_extra_tempfile do |extra_file| + debug_code(program(extra_file.path)) do + type "config set skip_path #{extra_file.path}" + type 'c' + assert_finish + end + + debug_code(program(extra_file.path)) do + type "config set skip_path #{extra_file.path}" + type "catch RuntimeError path: #{extra_file.path}" + type 'c' + assert_line_text(/bar/) + type 'c' + assert_finish + end + end + end end end From e3e40318abcab0184f29a2d2d9ec18da6b269e96 Mon Sep 17 00:00:00 2001 From: st0012 Date: Fri, 26 Nov 2021 10:19:00 +0000 Subject: [PATCH 7/9] Remove redundant assert_finish --- test/debug/break_test.rb | 2 -- test/debug/catch_test.rb | 2 -- 2 files changed, 4 deletions(-) diff --git a/test/debug/break_test.rb b/test/debug/break_test.rb index 5504696bc..c234baaaf 100644 --- a/test/debug/break_test.rb +++ b/test/debug/break_test.rb @@ -232,7 +232,6 @@ def test_break_only_stops_when_path_matches type 'c' assert_line_text(/#{extra_file.path}/) type 'c' - assert_finish end end end @@ -333,7 +332,6 @@ def test_break_only_stops_when_path_matches type 'c' assert_line_text(/#{extra_file.path}/) type 'c' - assert_finish end end end diff --git a/test/debug/catch_test.rb b/test/debug/catch_test.rb index 0e1c49fab..7205337cd 100644 --- a/test/debug/catch_test.rb +++ b/test/debug/catch_test.rb @@ -191,7 +191,6 @@ def test_the_path_option_supersede_skip_path_config debug_code(program(extra_file.path)) do type "config set skip_path #{extra_file.path}" type 'c' - assert_finish end debug_code(program(extra_file.path)) do @@ -200,7 +199,6 @@ def test_the_path_option_supersede_skip_path_config type 'c' assert_line_text(/bar/) type 'c' - assert_finish end end end From 6ed4dc97753dd1dcaa5aeb0e5e1fe149ae827e45 Mon Sep 17 00:00:00 2001 From: st0012 Date: Fri, 26 Nov 2021 10:23:14 +0000 Subject: [PATCH 8/9] Remove extra file helper --- test/debug/break_test.rb | 6 ------ test/debug/catch_test.rb | 2 -- test/support/extra_file_helper.rb | 15 --------------- test/support/test_case.rb | 12 +++++++++++- 4 files changed, 11 insertions(+), 24 deletions(-) delete mode 100644 test/support/extra_file_helper.rb diff --git a/test/debug/break_test.rb b/test/debug/break_test.rb index c234baaaf..1fcd5bbc3 100644 --- a/test/debug/break_test.rb +++ b/test/debug/break_test.rb @@ -205,8 +205,6 @@ def test_debugger_doesnt_stop_when_other_instance_calls_the_inherited_method end class PathOptionTest < TestCase - include ExtraFileHelper - def extra_file <<~RUBY Foo.new.bar @@ -310,8 +308,6 @@ def test_break_C_method_with_singleton_method end class PathOptionTest < TestCase - include ExtraFileHelper - def extra_file <<~RUBY 1.abs @@ -618,8 +614,6 @@ def test_conditional_breakpoint_shows_error end class PathOptionTest < TestCase - include ExtraFileHelper - def extra_file <<~RUBY a = 100 diff --git a/test/debug/catch_test.rb b/test/debug/catch_test.rb index 7205337cd..18293b7f2 100644 --- a/test/debug/catch_test.rb +++ b/test/debug/catch_test.rb @@ -150,8 +150,6 @@ def test_catch_with_namespace_stops_at_exception end class PathOptionTest < TestCase - include ExtraFileHelper - def extra_file <<~RUBY def bar diff --git a/test/support/extra_file_helper.rb b/test/support/extra_file_helper.rb deleted file mode 100644 index bd599e351..000000000 --- a/test/support/extra_file_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'securerandom' - -module DEBUGGER__ - module ExtraFileHelper - def with_extra_tempfile - t = Tempfile.create([SecureRandom.hex(5), '.rb']).tap do |f| - f.write(extra_file) - f.close - end - yield t - ensure - File.unlink t if t - end - end -end diff --git a/test/support/test_case.rb b/test/support/test_case.rb index b0c7b8b70..7baee0504 100644 --- a/test/support/test_case.rb +++ b/test/support/test_case.rb @@ -2,10 +2,10 @@ require 'test/unit' require 'tempfile' +require 'securerandom' require_relative 'utils' require_relative 'assertions' -require_relative 'extra_file_helper' module DEBUGGER__ class TestCase < Test::Unit::TestCase @@ -24,5 +24,15 @@ def remove_temp_file File.unlink(@temp_file) if @temp_file @temp_file = nil end + + def with_extra_tempfile + t = Tempfile.create([SecureRandom.hex(5), '.rb']).tap do |f| + f.write(extra_file) + f.close + end + yield t + ensure + File.unlink t if t + end end end From b1a3a899dc551a2b707d66851ff0e2fcc2566722 Mon Sep 17 00:00:00 2001 From: st0012 Date: Fri, 26 Nov 2021 10:53:57 +0000 Subject: [PATCH 9/9] Add path option to WatchBreakpoint --- lib/debug/breakpoint.rb | 4 +++- lib/debug/session.rb | 3 ++- lib/debug/thread_client.rb | 8 ++++---- test/debug/watch_test.rb | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/lib/debug/breakpoint.rb b/lib/debug/breakpoint.rb index d74c41aba..802d230b3 100644 --- a/lib/debug/breakpoint.rb +++ b/lib/debug/breakpoint.rb @@ -337,7 +337,7 @@ def to_s end class WatchIVarBreakpoint < Breakpoint - def initialize ivar, object, current, cond: nil, command: nil + def initialize ivar, object, current, cond: nil, command: nil, path: nil @ivar = ivar.to_sym @object = object @key = [:watch, object.object_id, @ivar].freeze @@ -346,6 +346,7 @@ def initialize ivar, object, current, cond: nil, command: nil @cond = cond @command = command + @path = path super() end @@ -371,6 +372,7 @@ def setup @tp = TracePoint.new(:line, :return, :b_return){|tp| next if tp.path.start_with? __dir__ next if tp.path.start_with? ' 25/) + type 'c' + end + end + end + end end end