JuliaInterpreter.jl
JuliaInterpreter.jl copied to clipboard
Break point on line stops at an awkward place
function f_debug(x)
out = []
for i in x
push!(out, 2i)
end
out
end
julia> @enter f_debug(rand(10))
In f_debug(x) at /home/kc/demo.jl:14
14 function f_debug(x)
>15 out = []
16 for i in x
17 push!(out, 2i)
18 end
19 out
20 end
About to run: (Base.vect)()
1|debug> bp add 17
1] /home/kc/demo.jl:17
1|debug> c
Hit breakpoint:
In f_debug(x) at /home/kc/demo.jl:14
14 function f_debug(x)
15 out = []
16 for i in x
>17 push!(out, 2i)
18 end
19 out
20 end
About to run: _J4
The "About to run: _J4" is probably a bad place to stop at.
What happens here is that the first statement on the given line nr is an assignment:
In f_debug(x) at /Users/kristoffercarlsson/JuliaPkgs/JuliaInterpreter.jl/test.jl:1
7 2 ┄ %7 = @_3
8 │ i = Core.getfield(%7, 1)
9 │ %9 = Core.getfield(%7, 2)
●10 │ %10 = out
11 │ %11 = 2 * i
12 │ Base.push!(%10, %11)
We could skip ahead to the next call via:
diff --git a/src/commands.jl b/src/commands.jl
index b1f68ad..c4e094a 100644
--- a/src/commands.jl
+++ b/src/commands.jl
@@ -514,7 +514,13 @@ function debug_command(@nospecialize(recurse), frame::Frame, cmd::Symbol, rootis
if cmd === :c
r = root(frame)
ret = finish_stack!(recurse, r, rootistoplevel)
- return isa(ret, BreakpointRef) ? (leaf(r), ret) : nothing
+ if isa(ret, BreakpointRef)
+ newframe = leaf(frame)
+ maybe_next_call!(recurse, newframe, istoplevel)
+ return newframe, ret
+ else
+ return nothing
+ end
end
cmd === :finish && return maybe_reset_frame!(recurse, frame, finish!(recurse,
frame, istoplevel), rootistoplevel)
catch err
Is that the best solution? Any opinions?
Yeah, that seems like a sensible solution to me. Agreed the current situation is not ideal.