Skip to content

Commit

Permalink
Fix bug that "trace line" does not work after stopping trace once
Browse files Browse the repository at this point in the history
  • Loading branch information
ono-max authored and ko1 committed Mar 7, 2023
1 parent 411d7e6 commit bd9a3be
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ def add_iseq_breakpoint iseq, **kw
# tracers

def add_tracer tracer
if @tracers.has_key? tracer.key
if @tracers[tracer.key]&.enabled?
tracer.disable
@ui.puts "Duplicated tracer: #{tracer}"
else
Expand Down
4 changes: 4 additions & 0 deletions lib/debug/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def disable
@tracer.disable
end

def enabled?
@tracer.enabled?
end

def description
nil
end
Expand Down
26 changes: 26 additions & 0 deletions test/console/trace_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -532,5 +532,31 @@ def test_tracer_prints_correct_method_receiving_messages
end
end
end

class TraceOnAfterStoppingOnceTest < ConsoleTestCase
def program
<<~RUBY
1| a=1
2|
3| b=1
4|
5| c=1
6| p a
RUBY
end

def test_1656237686
debug_code(program) do
type 'trace line'
type 'trace off'
type 'trace line'
type 'b 5'
type 'c'
assert_line_num 5
assert_line_text(/DEBUGGER \(trace\/line\)/)
type 'kill!'
end
end
end
end
end

0 comments on commit bd9a3be

Please sign in to comment.