Skip to content

Commit

Permalink
step into <name>
Browse files Browse the repository at this point in the history
`step into <name>` stops at the beggining of the method `<name>`.

`into` is added because there are alreay `step back` and `step reset`
commands.

fix #655
  • Loading branch information
ko1 committed Nov 1, 2022
1 parent 9eb5e3e commit 23cb4ae
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
10 changes: 10 additions & 0 deletions lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ def process_command line
# * Step in. Resume the program until next breakable point.
# * `s[tep] <n>`
# * Step in, resume the program at `<n>`th breakable point.
# * `s[tep] into <name>` or `s[tep] into /regexp/`
# * Stop at the beggining of method `<name>` or the name matched to `/regexp/`
when 's', 'step'
cancel_auto_continue
check_postmortem
Expand Down Expand Up @@ -1077,6 +1079,14 @@ def step_command type, arg
iter = $2&.to_i
request_tc [:step, type, iter]
end
when /\Ainto\s+(\S+)(\s+(\d+))?\z/
pat = $1
iter = $3&.to_i
if /\A\/(.+)\/\z/ =~ pat
pat = Regexp.new($1)
end

request_tc [:step, :into, pat, iter]
else
@ui.puts "Unknown option: #{arg}"
:retry
Expand Down
11 changes: 9 additions & 2 deletions lib/debug/thread_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def step_tp iter, events = [:line, :b_return, :return]
tp.disable
next
end
next if !yield(tp.event)
next if !yield(tp)
next if tp.path.start_with?(__dir__)
next if tp.path.start_with?('<internal:trace_point>')
next unless File.exist?(tp.path) if CONFIG[:skip_nosrc]
Expand All @@ -355,7 +355,7 @@ def step_tp iter, events = [:line, :b_return, :return]
tp.disable
next
end
next if !yield(tp.event)
next if !yield(tp)
next if tp.path.start_with?(__dir__)
next if tp.path.start_with?('<internal:trace_point>')
next unless File.exist?(tp.path) if CONFIG[:skip_nosrc]
Expand Down Expand Up @@ -859,6 +859,13 @@ def wait_next_action_
break
end

when :into
pat, iter = args[1], args[2]
step_tp iter, [:call, :c_call] do |tp|
pat === tp.callee_id.to_s
end
break

when :next
frame = @target_frames.first
path = frame.location.absolute_path || "!eval:#{frame.path}"
Expand Down
14 changes: 14 additions & 0 deletions test/console/control_flow_commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ def test_step_with_number_goes_to_the_next_nth_statement
end
end

def test_step_into
debug_code program do
type 'step into name'
assert_line_num 7
type 'step into xyzzy' # doesn't match
end

debug_code program do
type 'step into /.ame/'
assert_line_num 7
type 'step into xyzzy' # doesn't match
end
end

def test_next_goes_to_the_next_line
debug_code(program) do
type 'b 11'
Expand Down

0 comments on commit 23cb4ae

Please sign in to comment.