I’d like to interactively inspect the value of large struct at a certain point in the execution of my program. I am able to use JuliaInterpreter.jl to set a breakpoint, but it seems to be returning the wrong frame.
This minimal example where I’d like to inspect the value of b
but am only able to do so for a
demonstrates the issue:
julia> function f(x)
a = x*rand()
g(a)
end
f (generic function with 1 method)
julia> function g(y)
b = y*rand()
@bp
1/b
end
g (generic function with 1 method)
julia> r = @interpret f(0.3)
(Frame for f(x) in Main at REPL[36]:1
1 2 1 ─ %1 = (rand)()
2 2 │ a = (*)(x, %1)
3 3 │ %3 = (g)(a)
4 3 └── return %3
x = 0.3
a = 0.0508096
callee: g(y) in Main at REPL[37]:1, breakpoint(g(y) in Main at REPL[37]:1, line 3))
julia> JuliaInterpreter.eval_code(r[1], "b")
ERROR: UndefVarError: b not defined
Stacktrace:
[1] top-level scope at none:1
[2] eval at ./boot.jl:331 [inlined]
[3] eval_code(::Frame, ::Expr) at /home/me/.julia/packages/JuliaInterpreter/owKmt/src/utils.jl:525
[4] eval_code(::Frame, ::String) at /home/me/.julia/packages/JuliaInterpreter/owKmt/src/utils.jl:502
[5] top-level scope at REPL[39]:1
julia> JuliaInterpreter.eval_code(r[1], "a")
0.05080960253582343