Skip to content

Commit

Permalink
ensure si doesn't step over anything (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored Mar 20, 2019
1 parent 3387cae commit 26a9a66
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,11 @@ function debug_command(@nospecialize(recurse), frame::Frame, cmd::Symbol, rootis

istoplevel = rootistoplevel && frame.caller === nothing
cmd0 = cmd
is_si = false
if cmd == :si
stmt = pc_expr(frame)
cmd = is_call(stmt) ? :s : :se
is_si = true
end
try
cmd == :nc && return nicereturn!(recurse, frame, next_call!(recurse, frame, istoplevel), rootistoplevel)
Expand All @@ -422,7 +424,7 @@ function debug_command(@nospecialize(recurse), frame::Frame, cmd::Symbol, rootis
if cmd == :s
pc = maybe_next_call!(recurse, frame, istoplevel)
(isa(pc, BreakpointRef) || pc === nothing) && return maybe_reset_frame!(recurse, frame, pc, rootistoplevel)
maybe_step_through_kwprep!(recurse, frame, istoplevel)
is_si || maybe_step_through_kwprep!(recurse, frame, istoplevel)
pc = frame.pc
stmt0 = stmt = pc_expr(frame, pc)
isexpr(stmt0, :return) && return maybe_reset_frame!(recurse, frame, nothing, rootistoplevel)
Expand All @@ -439,7 +441,8 @@ function debug_command(@nospecialize(recurse), frame::Frame, cmd::Symbol, rootis
if isa(ret, BreakpointRef)
newframe = leaf(frame)
cmd0 == :si && return newframe, ret
newframe = maybe_step_through_wrapper!(recurse, newframe)
is_si || (newframe = maybe_step_through_wrapper!(recurse, newframe))
is_si || maybe_step_through_kwprep!(recurse, newframe, istoplevel)
return newframe, BreakpointRef(newframe.framecode, 0)
end
# if we got here, the call returned a value
Expand Down
16 changes: 16 additions & 0 deletions test/debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,20 @@ struct B{T} end
frame, pc = debug_command(frame, :finish)
@test frame.framecode.scope == @which f(2, 3)
end

h_1(x, y) = h_2(x, y)
h_2(x, y) = h_3(x; y=y)
h_3(x; y = 2) = x + y
@testset "stepping through kwprep after stepping through wrapper" begin
frame = JuliaInterpreter.enter_call(h_1, 2, 1)
frame, pc = debug_command(frame, :s)
# Should have skipped the kwprep in h_2 and be at call to kwfunc h_3
@test Core.kwfunc(h_3) == JuliaInterpreter.@lookup frame JuliaInterpreter.pc_expr(frame).args[1]
end

@testset "si should not step through wrappers or kwprep" begin
frame = JuliaInterpreter.enter_call(h_1, 2, 1)
frame, pc = debug_command(frame, :si)
@test frame.pc == 1
end
# end

0 comments on commit 26a9a66

Please sign in to comment.