Skip to content

Commit 26a9a66

Browse files
authored
ensure si doesn't step over anything (#199)
1 parent 3387cae commit 26a9a66

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/commands.jl

+5-2
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,11 @@ function debug_command(@nospecialize(recurse), frame::Frame, cmd::Symbol, rootis
405405

406406
istoplevel = rootistoplevel && frame.caller === nothing
407407
cmd0 = cmd
408+
is_si = false
408409
if cmd == :si
409410
stmt = pc_expr(frame)
410411
cmd = is_call(stmt) ? :s : :se
412+
is_si = true
411413
end
412414
try
413415
cmd == :nc && return nicereturn!(recurse, frame, next_call!(recurse, frame, istoplevel), rootistoplevel)
@@ -422,7 +424,7 @@ function debug_command(@nospecialize(recurse), frame::Frame, cmd::Symbol, rootis
422424
if cmd == :s
423425
pc = maybe_next_call!(recurse, frame, istoplevel)
424426
(isa(pc, BreakpointRef) || pc === nothing) && return maybe_reset_frame!(recurse, frame, pc, rootistoplevel)
425-
maybe_step_through_kwprep!(recurse, frame, istoplevel)
427+
is_si || maybe_step_through_kwprep!(recurse, frame, istoplevel)
426428
pc = frame.pc
427429
stmt0 = stmt = pc_expr(frame, pc)
428430
isexpr(stmt0, :return) && return maybe_reset_frame!(recurse, frame, nothing, rootistoplevel)
@@ -439,7 +441,8 @@ function debug_command(@nospecialize(recurse), frame::Frame, cmd::Symbol, rootis
439441
if isa(ret, BreakpointRef)
440442
newframe = leaf(frame)
441443
cmd0 == :si && return newframe, ret
442-
newframe = maybe_step_through_wrapper!(recurse, newframe)
444+
is_si || (newframe = maybe_step_through_wrapper!(recurse, newframe))
445+
is_si || maybe_step_through_kwprep!(recurse, newframe, istoplevel)
443446
return newframe, BreakpointRef(newframe.framecode, 0)
444447
end
445448
# if we got here, the call returned a value

test/debug.jl

+16
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,20 @@ struct B{T} end
403403
frame, pc = debug_command(frame, :finish)
404404
@test frame.framecode.scope == @which f(2, 3)
405405
end
406+
407+
h_1(x, y) = h_2(x, y)
408+
h_2(x, y) = h_3(x; y=y)
409+
h_3(x; y = 2) = x + y
410+
@testset "stepping through kwprep after stepping through wrapper" begin
411+
frame = JuliaInterpreter.enter_call(h_1, 2, 1)
412+
frame, pc = debug_command(frame, :s)
413+
# Should have skipped the kwprep in h_2 and be at call to kwfunc h_3
414+
@test Core.kwfunc(h_3) == JuliaInterpreter.@lookup frame JuliaInterpreter.pc_expr(frame).args[1]
415+
end
416+
417+
@testset "si should not step through wrappers or kwprep" begin
418+
frame = JuliaInterpreter.enter_call(h_1, 2, 1)
419+
frame, pc = debug_command(frame, :si)
420+
@test frame.pc == 1
421+
end
406422
# end

0 commit comments

Comments
 (0)