Skip to content

Commit 21d77bd

Browse files
authored
ensure we leave wrapper if we step to the end of it (#156)
* ensure we leave wrapper if we step to the end of it
1 parent c41e768 commit 21d77bd

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/commands.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ function maybe_step_through_wrapper!(@nospecialize(recurse), frame::Frame)
233233
# this is a wrapper function that we might want to step through
234234
while frame.pc != length(stmts)-1
235235
pc = next_call!(recurse, frame, false) # since we're in a Method we're not at toplevel
236+
pc === nothing && return frame
236237
end
237238
ret = evaluate_call!(dummy_breakpoint, frame, last)
238239
@assert isa(ret, BreakpointRef)

test/debug.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ function step_through(frame)
99
return get_return(r)
1010
end
1111

12+
function step_through_function(f, args...)
13+
frame = JuliaInterpreter.enter_call(f, args...)
14+
while true
15+
ret = JuliaInterpreter.debug_command(JuliaInterpreter.finish_and_return!, frame, "s")
16+
ret == nothing && break
17+
frame, pc = ret
18+
end
19+
@test frame.callee === nothing
20+
@test frame.caller === nothing
21+
return JuliaInterpreter.get_return(frame)
22+
end
23+
1224
@generated function generatedfoo(T)
1325
:(return $T)
1426
end
@@ -49,14 +61,17 @@ struct B{T} end
4961

5062
f22() = string(:(a+b))
5163
@test step_through(enter_call(f22)) == "a + b"
64+
@test step_through_function(f22) == "a + b"
5265
f22() = string(QuoteNode(:a))
5366
@test step_through(enter_call(f22)) == ":a"
67+
@test step_through_function(f22) == ":a"
5468

5569
frame = enter_call(trivial, 2)
5670
@test debug_command(frame, "s") === nothing
5771
@test get_return(frame) == 2
5872

5973
@test step_through(enter_call(trivial, 2)) == 2
74+
@test step_through_function(trivial, 2) == 2
6075
@test step_through(enter_call_expr(:($(+)(1,2.5)))) == 3.5
6176
@test step_through(enter_call_expr(:($(sin)(1)))) == sin(1)
6277
@test step_through(enter_call_expr(:($(gcd)(10,20)))) == gcd(10, 20)
@@ -207,6 +222,7 @@ struct B{T} end
207222
end
208223
B_inst = B{Int}()
209224
step_through(JuliaInterpreter.enter_call(B_inst, 10)) == B_inst(10)
225+
step_through_function(B_inst, 10) == B_inst(10)
210226
end
211227

212228
@testset "Exceptions" begin

0 commit comments

Comments
 (0)