Skip to content

Commit 5f6fb30

Browse files
authored
Merge pull request #486 from JuliaDebug/sp/duplicate-slotnames
Improve handling of duplicate slotnames
2 parents 8e7bac9 + b71da5a commit 5f6fb30

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

src/breakpoints.jl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,10 @@ function shouldbreak(frame::Frame, pc::Int)
188188
end
189189

190190
function prepare_slotfunction(framecode::FrameCode, body::Union{Symbol,Expr})
191-
uslotnames = Set{Symbol}()
192-
slotnames = Symbol[]
193-
for name in framecode.src.slotnames
194-
if name uslotnames
195-
push!(slotnames, name)
196-
push!(uslotnames, name)
197-
end
198-
end
199191
framename, dataname = gensym("frame"), gensym("data")
200192
assignments = Expr[:($dataname = $framename.framedata)]
201193
default = Unassigned()
202-
for i = 1:length(slotnames)
203-
slotname = framecode.src.slotnames[i]
204-
qslotname = QuoteNode(slotname)
194+
for slotname in unique(framecode.src.slotnames)
205195
list = framecode.slotnamelists[slotname]
206196
if length(list) == 1
207197
maxexpr = :($dataname.last_reference[$(list[1])] > 0 ? $(list[1]) : 0)

test/breakpoints.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,31 @@ empty!(breakpoint_update_hooks)
433433
remove()
434434
end
435435
end
436+
437+
@testset "duplicate slotnames" begin
438+
tmp_dupl() = (1,2,3,4)
439+
ln = @__LINE__
440+
function duplnames(x)
441+
for iter in Iterators.CartesianIndices(x)
442+
i = iter[1]
443+
c = i
444+
a, b, c, d = tmp_dupl()
445+
end
446+
return x
447+
end
448+
bp = breakpoint(@__FILE__, ln+5, :(i == 1))
449+
c = @code_lowered(duplnames((1,2)))
450+
if length(unique(c.slotnames)) < length(c.slotnames)
451+
f = JuliaInterpreter.enter_call(duplnames, (1,2))
452+
ex = JuliaInterpreter.prepare_slotfunction(f.framecode, :(i==1))
453+
@test ex isa Expr
454+
found = false
455+
for arg in ex.args[end].args
456+
if arg.args[1] == :i
457+
found = true
458+
end
459+
end
460+
@test found
461+
@test last(JuliaInterpreter.debug_command(f, :c)) isa BreakpointRef
462+
end
463+
end

0 commit comments

Comments
 (0)