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

fix breakpoint on first line of function call #235

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions src/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ In the latter case, `leaf(frame)` returns the frame in which it hit the breakpoi
by normal dispatch, whereas the default `recurse = finish_and_return!` uses recursive interpretation.
"""
function finish!(@nospecialize(recurse), frame::Frame, istoplevel::Bool=false)
shouldbreak(frame, frame.pc) && return BreakpointRef(frame.framecode, frame.pc)
while true
pc = step_expr!(recurse, frame, istoplevel)
(pc === nothing || isa(pc, BreakpointRef)) && return pc
Expand All @@ -26,6 +27,7 @@ Call [`JuliaInterpreter.finish!`](@ref) and pass back the return value `ret`. If
pauses at a breakpoint, `ret` is the reference to the breakpoint.
"""
function finish_and_return!(@nospecialize(recurse), frame::Frame, istoplevel::Bool=false)
shouldbreak(frame, frame.pc) && return BreakpointRef(frame.framecode, frame.pc)
pc = finish!(recurse, frame, istoplevel)
isa(pc, BreakpointRef) && return pc
return get_return(frame)
Expand Down
9 changes: 9 additions & 0 deletions test/breakpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ end
@test bp.stmtidx == 3
end

@testset "breakpoint on first statement" begin
JuliaInterpreter.breakpoint(gcd)
frame = JuliaInterpreter.enter_call_expr(Expr(:call, gcd, 2,3))
ret = JuliaInterpreter.debug_command(frame, :finish)
@test ret !== nothing
@test ret[2] isa BreakpointRef
JuliaInterpreter.remove()
end

if tmppath != ""
rm(tmppath)
end