Skip to content

Commit 8664e4d

Browse files
authored
Merge pull request #90 from JuliaDebug/teh/rebugger
Small fixes to breakpoint operation
2 parents e93f52a + 367e7cb commit 8664e4d

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/breakpoints.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ end
2727
BreakpointRef(framecode, stmtidx) = BreakpointRef(framecode, stmtidx, nothing)
2828

2929
function Base.show(io::IO, bp::BreakpointRef)
30-
lineno = linenumber(bp.framecode, bp.stmtidx)
31-
print(io, "breakpoint(", bp.framecode.scope, ", ", lineno, ')')
30+
if checkbounds(Bool, bp.framecode.breakpoints, bp.stmtidx)
31+
lineno = linenumber(bp.framecode, bp.stmtidx)
32+
print(io, "breakpoint(", bp.framecode.scope, ", ", lineno)
33+
else
34+
print(io, "breakpoint(", bp.framecode.scope, ", %", bp.stmtidx)
35+
end
36+
if bp.err !== nothing
37+
print(io, ", ", bp.err)
38+
end
39+
print(io, ')')
3240
end
3341

3442
const _breakpoints = BreakpointRef[]
@@ -59,7 +67,7 @@ function shouldbreak(frame, pc=frame.pc[])
5967
isassigned(frame.code.breakpoints, idx) || return false
6068
bp = frame.code.breakpoints[idx]
6169
bp.isactive || return false
62-
return bp.condition(frame)::Bool
70+
return Base.invokelatest(bp.condition, frame)::Bool
6371
end
6472

6573
function prepare_slotfunction(framecode::JuliaFrameCode, body::Union{Symbol,Expr})

test/breakpoints.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,17 @@ end
9999
finally
100100
JuliaInterpreter.break_on_error[] = false
101101
end
102+
103+
# Breakpoint display
104+
io = IOBuffer()
105+
frame = JuliaInterpreter.enter_call(loop_radius2, 2)
106+
bp = JuliaInterpreter.BreakpointRef(frame.code, 1)
107+
show(io, bp)
108+
@test String(take!(io)) == "breakpoint(loop_radius2(n) in $(@__MODULE__) at $(@__FILE__):3, 3)"
109+
bp = JuliaInterpreter.BreakpointRef(frame.code, 0) # fictive breakpoint
110+
show(io, bp)
111+
@test String(take!(io)) == "breakpoint(loop_radius2(n) in $(@__MODULE__) at $(@__FILE__):3, %0)"
112+
bp = JuliaInterpreter.BreakpointRef(frame.code, 1, ArgumentError("whoops"))
113+
show(io, bp)
114+
@test String(take!(io)) == "breakpoint(loop_radius2(n) in $(@__MODULE__) at $(@__FILE__):3, 3, ArgumentError(\"whoops\"))"
102115
end

0 commit comments

Comments
 (0)