Skip to content

Commit 9163e7d

Browse files
committed
Provide a breakpoint macro
1 parent e7f71ca commit 9163e7d

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/JuliaInterpreter.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,6 @@ macro interpret(arg)
11191119
if frame === nothing
11201120
return eval(Expr(:call, map(QuoteNode, theargs)...))
11211121
end
1122-
empty!(framedict) # start fresh each time; kind of like bumping the world age at the REPL prompt
1123-
empty!(genframedict)
11241122
finish_and_return!(stack, frame)
11251123
end
11261124
end

src/breakpoints.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ function prepare_slotfunction(framecode::JuliaFrameCode, body::Union{Symbol,Expr
9191
return Expr(:function, Expr(:call, funcname, framename), Expr(:block, assignments..., body))
9292
end
9393

94-
9594
## The fundamental implementations of breakpoint-setting
9695
function breakpoint!(framecode::JuliaFrameCode, pc, condition::Union{Bool,Expr}=true)
9796
stmtidx = convert(Int, pc)
@@ -174,4 +173,12 @@ function breakpoint(f, condition::Union{Bool,Expr}=true)
174173
return bps
175174
end
176175

176+
macro breakpoint(call_expr, condition)
177+
whichexpr = InteractiveUtils.gen_call_with_extracted_types(__module__, :which, call_expr)
178+
return quote
179+
local method = $whichexpr
180+
$breakpoint(method, $(Expr(:quote, condition)))
181+
end
182+
end
183+
177184
end

test/breakpoints.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ end
3333
remove()
3434
breakpoint(radius2, :(y > x))
3535
runsimple()
36+
remove()
37+
@breakpoint radius2(0,0) y>x
38+
runsimple()
39+
# Demonstrate the problem that we have with scope
40+
local_identity(x) = identity(x)
41+
remove()
42+
@breakpoint radius2(0,0) y>local_identity(x)
43+
@test_broken @interpret loop_radius2(2)
3644

3745
# Conditional breakpoints on local variables
3846
remove()

0 commit comments

Comments
 (0)