Skip to content

Commit bd0800a

Browse files
committed
Add more docstrings and fix the doctests
1 parent caff042 commit bd0800a

File tree

4 files changed

+58
-6
lines changed

4 files changed

+58
-6
lines changed

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[deps]
2+
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
23
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
34
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
45
JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
56
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7+
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

docs/src/dev_reference.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ JuliaInterpreter.Compiled
2828
JuliaInterpreter.step_expr!
2929
JuliaInterpreter.finish!
3030
JuliaInterpreter.finish_and_return!
31+
JuliaInterpreter.finish_stack!
3132
JuliaInterpreter.get_return
3233
JuliaInterpreter.next_until!
3334
JuliaInterpreter.through_methoddef_or_done!
@@ -36,12 +37,24 @@ JuliaInterpreter.evaluate_foreigncall!
3637
JuliaInterpreter.maybe_evaluate_builtin
3738
```
3839

40+
## Breakpoints
41+
42+
```@docs
43+
@breakpoint
44+
breakpoint
45+
enable
46+
disable
47+
remove
48+
```
49+
3950
## Types
4051

4152
```@docs
4253
JuliaInterpreter.JuliaStackFrame
4354
JuliaInterpreter.JuliaFrameCode
4455
JuliaInterpreter.JuliaProgramCounter
56+
JuliaInterpreter.BreakpointState
57+
JuliaInterpreter.BreakpointRef
4558
```
4659

4760
## Internal storage
@@ -57,4 +70,7 @@ JuliaInterpreter.compiled_methods
5770
```@docs
5871
JuliaInterpreter.@lookup
5972
JuliaInterpreter.iswrappercall
73+
JuliaInterpreter.isdocexpr
74+
JuliaInterpreter.isglobalref
75+
JuliaInterpreter.statementnumber
6076
```

src/JuliaInterpreter.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ julia> framecode, frameargs, lenv, argtypes = JuliaInterpreter.prepare_call(myme
391391
julia> framecode
392392
JuliaInterpreter.JuliaFrameCode(mymethod(x::Array{T,1}) where T in Main at none:1, CodeInfo(
393393
1 ─ return 1
394-
), Core.TypeMapEntry[#undef], BitSet([]), false, false, true)
394+
), Union{Compiled, TypeMapEntry}[#undef], JuliaInterpreter.BreakpointState[#undef], BitSet([]), false, false, true)
395395
396396
julia> frameargs
397397
2-element Array{Any,1}:
@@ -916,9 +916,9 @@ mymethod (generic function with 1 method)
916916
917917
julia> JuliaInterpreter.enter_call_expr(:(\$mymethod(1)))
918918
JuliaStackFrame(JuliaInterpreter.JuliaFrameCode(mymethod(x) in Main at none:1, CodeInfo(
919-
1 ─ %1 = (\$(QuoteNode(+)))(x, 1)
919+
1 ─ %1 = ($(QuoteNode(+)))(x, 1)
920920
└── return %1
921-
), Core.TypeMapEntry[#undef, #undef], BitSet([1]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some(1)], Any[#undef, #undef], Any[], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict{Symbol,Int64}(), Any[])
921+
), Union{Compiled, TypeMapEntry}[#undef, #undef], JuliaInterpreter.BreakpointState[#undef, #undef], BitSet([1]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some(1)], Any[#undef, #undef], Any[], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict(Symbol("#self#")=>1,:x=>2), Any[])
922922
923923
julia> mymethod(x::Vector{T}) where T = 1
924924
mymethod (generic function with 2 methods)
@@ -931,7 +931,7 @@ julia> a = [1.0, 2.0]
931931
julia> JuliaInterpreter.enter_call_expr(:(\$mymethod(\$a)))
932932
JuliaStackFrame(JuliaInterpreter.JuliaFrameCode(mymethod(x::Array{T,1}) where T in Main at none:1, CodeInfo(
933933
1 ─ return 1
934-
), Core.TypeMapEntry[#undef], BitSet([]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some([1.0, 2.0])], Any[#undef], Any[Float64], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict{Symbol,Int64}(), Any[])
934+
), Union{Compiled, TypeMapEntry}[#undef], JuliaInterpreter.BreakpointState[#undef], BitSet([]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some([1.0, 2.0])], Any[#undef], Any[Float64], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict(Symbol("#self#")=>1,:x=>2), Any[])
935935
```
936936
937937
See [`enter_call`](@ref) for a similar approach not based on expressions.
@@ -959,15 +959,15 @@ julia> JuliaInterpreter.enter_call(mymethod, 1)
959959
JuliaStackFrame(JuliaInterpreter.JuliaFrameCode(mymethod(x) in Main at none:1, CodeInfo(
960960
1 ─ %1 = ($(QuoteNode(+)))(x, 1)
961961
└── return %1
962-
), Core.TypeMapEntry[#undef, #undef], BitSet([1]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some(1)], Any[#undef, #undef], Any[], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict{Symbol,Int64}(), Any[])
962+
), Union{Compiled, TypeMapEntry}[#undef, #undef], JuliaInterpreter.BreakpointState[#undef, #undef], BitSet([1]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some(1)], Any[#undef, #undef], Any[], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict(Symbol("#self#")=>1,:x=>2), Any[])
963963
964964
julia> mymethod(x::Vector{T}) where T = 1
965965
mymethod (generic function with 2 methods)
966966
967967
julia> JuliaInterpreter.enter_call(mymethod, [1.0, 2.0])
968968
JuliaStackFrame(JuliaInterpreter.JuliaFrameCode(mymethod(x::Array{T,1}) where T in Main at none:1, CodeInfo(
969969
1 ─ return 1
970-
), Core.TypeMapEntry[#undef], BitSet([]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some([1.0, 2.0])], Any[#undef], Any[Float64], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict{Symbol,Int64}(), Any[])
970+
), Union{Compiled, TypeMapEntry}[#undef], JuliaInterpreter.BreakpointState[#undef], BitSet([]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some([1.0, 2.0])], Any[#undef], Any[Float64], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict(Symbol("#self#")=>1,:x=>2), Any[])
971971
```
972972
973973
For a `@generated` function you can use `enter_call((f, true), args...; kwargs...)`

src/breakpoints.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,51 @@ end
109109
breakpoint!(frame::JuliaStackFrame, pc=frame.pc[], condition::Condition=nothing) =
110110
breakpoint!(frame.code, pc, condition)
111111

112+
"""
113+
enable(bp::BreakpointRef)
114+
115+
Enable breakpoint `bp`.
116+
"""
112117
enable(bp::BreakpointRef) = bp[] = true
118+
119+
"""
120+
disable(bp::BreakpointRef)
121+
122+
Disable breakpoint `bp`. Disabled breakpoints can be re-enabled with [`enable`](@ref).
123+
"""
113124
disable(bp::BreakpointRef) = bp[] = false
125+
126+
"""
127+
remove(bp::BreakpointRef)
128+
129+
Remove (delete) breakpoint `bp`. Removed breakpoints cannot be re-enabled.
130+
"""
114131
function remove(bp::BreakpointRef)
115132
idx = findfirst(isequal(bp), _breakpoints)
116133
deleteat!(_breakpoints, idx)
117134
bp.framecode.breakpoints[bp.stmtidx] = BreakpointState(false, falsecondition)
118135
return nothing
119136
end
120137

138+
"""
139+
enable()
140+
141+
Enable all breakpoints.
142+
"""
121143
enable() = for bp in _breakpoints enable(bp) end
144+
145+
"""
146+
disable()
147+
148+
Disable all breakpoints.
149+
"""
122150
disable() = for bp in _breakpoints disable(bp) end
151+
152+
"""
153+
remove()
154+
155+
Remove all breakpoints.
156+
"""
123157
function remove()
124158
for bp in _breakpoints
125159
bp.framecode.breakpoints[bp.stmtidx] = BreakpointState(false, falsecondition)

0 commit comments

Comments
 (0)