Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

step into <name> #786

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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