Skip to content

Commit d502e02

Browse files
authored
Merge pull request #183 from JuliaDebug/teh/fix_178
Ensure slots get assigned in `finish_stack!`
2 parents 257ae1b + 72e5765 commit d502e02

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

src/JuliaInterpreter.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ function set_compiled_methods()
5959
push!(compiled_methods, which(reenable_sigint, Tuple{Function}))
6060
# Signal-handling in the `print` dispatch hierarchy
6161
push!(compiled_methods, which(Base.unsafe_write, Tuple{Base.LibuvStream, Ptr{UInt8}, UInt}))
62+
push!(compiled_methods, which(print, Tuple{IO, Any}))
63+
push!(compiled_methods, which(print, Tuple{IO, Any, Any}))
6264
# Libc.GetLastError()
6365
@static if Sys.iswindows()
6466
push!(compiled_methods, which(Base.access_env, Tuple{Function, AbstractString}))

src/commands.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ function finish_stack!(@nospecialize(recurse), frame::Frame, rootistoplevel::Boo
6767
if isassign(frame, pc)
6868
lhs = getlhs(pc)
6969
do_assignment!(frame, lhs, ret)
70+
else
71+
stmt = pc_expr(frame, pc)
72+
if isexpr(stmt, :(=))
73+
lhs = stmt.args[1]
74+
do_assignment!(frame, lhs, ret)
75+
end
7076
end
7177
pc += 1
7278
frame.pc = pc

src/construct.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,9 @@ macro interpret(arg)
643643
frame, BreakpointRef(frame.framecode, 1)
644644
else
645645
local ret = finish_and_return!(frame)
646+
# We deliberately return the top frame here; future debugging commands
647+
# via debug_command may alter the leaves, we want the top frame so we can
648+
# ultimately do `get_return`.
646649
isa(ret, BreakpointRef) ? (frame, ret) : ret
647650
end
648651
end

test/debug.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,4 +329,13 @@ struct B{T} end
329329
@test get_return(fr) == 2
330330
end
331331
end
332+
333+
@testset "Issue #178" begin
334+
remove()
335+
a = [1, 2, 3, 4]
336+
@breakpoint length(LinearIndices(a))
337+
frame, bp = @interpret sum(a)
338+
@test debug_command(frame, :c) === nothing
339+
@test get_return(frame) == sum(a)
340+
end
332341
# end

0 commit comments

Comments
 (0)