Skip to content

Commit

Permalink
Merge pull request #486 from JuliaDebug/sp/duplicate-slotnames
Browse files Browse the repository at this point in the history
Improve handling of duplicate slotnames
  • Loading branch information
pfitzseb authored Jun 2, 2021
2 parents 8e7bac9 + b71da5a commit 5f6fb30
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
12 changes: 1 addition & 11 deletions src/breakpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,10 @@ function shouldbreak(frame::Frame, pc::Int)
end

function prepare_slotfunction(framecode::FrameCode, body::Union{Symbol,Expr})
uslotnames = Set{Symbol}()
slotnames = Symbol[]
for name in framecode.src.slotnames
if name uslotnames
push!(slotnames, name)
push!(uslotnames, name)
end
end
framename, dataname = gensym("frame"), gensym("data")
assignments = Expr[:($dataname = $framename.framedata)]
default = Unassigned()
for i = 1:length(slotnames)
slotname = framecode.src.slotnames[i]
qslotname = QuoteNode(slotname)
for slotname in unique(framecode.src.slotnames)
list = framecode.slotnamelists[slotname]
if length(list) == 1
maxexpr = :($dataname.last_reference[$(list[1])] > 0 ? $(list[1]) : 0)
Expand Down
28 changes: 28 additions & 0 deletions test/breakpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,31 @@ empty!(breakpoint_update_hooks)
remove()
end
end

@testset "duplicate slotnames" begin
tmp_dupl() = (1,2,3,4)
ln = @__LINE__
function duplnames(x)
for iter in Iterators.CartesianIndices(x)
i = iter[1]
c = i
a, b, c, d = tmp_dupl()
end
return x
end
bp = breakpoint(@__FILE__, ln+5, :(i == 1))
c = @code_lowered(duplnames((1,2)))
if length(unique(c.slotnames)) < length(c.slotnames)
f = JuliaInterpreter.enter_call(duplnames, (1,2))
ex = JuliaInterpreter.prepare_slotfunction(f.framecode, :(i==1))
@test ex isa Expr
found = false
for arg in ex.args[end].args
if arg.args[1] == :i
found = true
end
end
@test found
@test last(JuliaInterpreter.debug_command(f, :c)) isa BreakpointRef
end
end

0 comments on commit 5f6fb30

Please sign in to comment.