Skip to content

Commit 45bb0de

Browse files
authored
simplify next_line! implementation (#263)
1 parent 89dd171 commit 45bb0de

File tree

2 files changed

+9
-40
lines changed

2 files changed

+9
-40
lines changed

src/commands.jl

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -168,40 +168,9 @@ function next_line!(@nospecialize(recurse), frame::Frame, istoplevel::Bool=false
168168
expr = pc_expr(frame, pc)
169169
(!first && isexpr(expr, :return)) && return pc
170170
first = false
171-
# If this is a goto node, step it and reevaluate
172-
if is_goto_node(expr)
173-
pc = step_expr!(recurse, frame, istoplevel)
174-
(pc === nothing || isa(pc, BreakpointRef)) && return pc
175-
elseif recurse !== nothing && is_wrapper_call(expr)
176-
# With splatting it can happen that we do something like ssa = tuple(#self#), _apply(ssa), which
177-
# confuses the logic here, just step into the first call that's not a builtin
178-
switched = false
179-
while is_wrapper_call(expr)
180-
ret = evaluate_call!(dummy_breakpoint, frame, expr)
181-
if frame.callee === nothing && !isa(ret, BreakpointRef)
182-
# This wasn't a real wrapper call
183-
if isassign(frame, pc)
184-
lhs = getlhs(pc)
185-
do_assignment!(frame, lhs, ret)
186-
end
187-
frame.pc = pc = pc + 1
188-
break
189-
end
190-
frame = frame.callee
191-
switched = true
192-
expr = pc_expr(frame)
193-
end
194-
# Signal that we've switched frames
195-
if switched
196-
pc = next_line!(recurse, frame, false)
197-
pc === nothing && error("confusing next_line!")
198-
lframe = leaf(frame)
199-
return isa(pc, BreakpointRef) ? pc : BreakpointRef(lframe.framecode, lframe.pc)
200-
end
201-
else
202-
pc = step_expr!(recurse, frame, istoplevel)
203-
(pc === nothing || isa(pc, BreakpointRef)) && return pc
204-
end
171+
172+
pc = step_expr!(recurse, frame, istoplevel)
173+
(pc === nothing || isa(pc, BreakpointRef)) && return pc
205174
shouldbreak(frame, pc) && return BreakpointRef(frame.framecode, pc)
206175
end
207176
maybe_step_through_kwprep!(recurse, frame, istoplevel)

test/debug.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ struct B{T} end
127127
cos(x)
128128
end
129129
frame = JuliaInterpreter.enter_call_expr(:($(optional)()))
130-
# First call steps in and executes the first statement
131-
f, pc = debug_command(frame, :n)
130+
# Step through the wrapper
131+
f = JuliaInterpreter.maybe_step_through_wrapper!(frame)
132132
@test frame !== f
133+
# asin(n)
134+
f, pc = debug_command(f, :n)
133135
# cos(1.0)
134-
debug_command(f, :n)
136+
f, pc = debug_command(f, :n)
135137
# return
136-
f2, pc = debug_command(f, :n)
137-
@test f2 === frame
138-
@test debug_command(frame, :n) === nothing
138+
@test debug_command(f, :n) === nothing
139139
end
140140

141141
@testset "Keyword arguments" begin

0 commit comments

Comments
 (0)