ASTInterpreter.jl
ASTInterpreter.jl copied to clipboard
ASTInterpreter ignores Gallium's breakpoints
Currently I don't see a way to run until the next breakpoint is hit. Am I missing the equivalent of a continue
statement? finish
is close, but only works within the current function.
^D
works this way. Arguably that should disable breakpoints though.
Didn't know that, thanks.
Sometimes it's nice to let the function run to completion, but usually I just quit out of debugging. More useful would be to run until the next breakpoint is hit. In all graphical IDEs I know, this is the meaning of the big "play" icon. (And like gdb
's c
command.)
See first command described here: https://sourceware.org/gdb/onlinedocs/gdb/Continuing-and-Stepping.html
This super-complicated function is a good test case:
function foo(n)
count = 0
for i = 1:n
count += 1
end
count
end
It's so complicated, I'd love to be able to watch what happens on each iteration. However, I don't want to step through each line, because it's such a long function. Instead I'd like to set a breakpoint near the beginning or end of the loop, and inspect the results so far.
If I set a breakpoint inside the loop, currently both ^D
and finish
seem to ignore the breakpoint on future iterations. So at the moment, is there an alternative to stepping through each line?
Ah, I see what you mean. Currently the ASTInterpreter ignore's Gallium's breakpoint specification, so the breakpoint is only active again once we leave the interpreter. It's probably quite doable to fix.
Just as a reminder of one of the issues discussed here, we might want to make quit actually quit:
julia> @noinline foo(r) = r.start
foo (generic function with 1 method)
julia> @noinline function bar(start, stop)
r = start:stop
x = foo(r)
x*x+x
end
bar (generic function with 1 method)
julia> @noinline function bar(start, stop)
r = start:stop
x = 0
for i = 1:5
x += foo(r)
end
x
end
WARNING: Method definition bar(Any, Any) in module Main at REPL[2]:2 overwritten at REPL[3]:2.
bar (generic function with 1 method)
julia> bar(1,5)
5
julia> using Gallium
INFO: Recompiling stale cache file /home/tim/.julia/lib/v0.5/ASTInterpreter.ji for module ASTInterpreter.
INFO: Recompiling stale cache file /home/tim/.julia/lib/v0.5/Gallium.ji for module Gallium.
julia> breakpoint(foo)
Locations (+: active, -: inactive, *: source):
+ foo(r::UnitRange{Int64}) at REPL[1]:1
* Any matching method added to #foo
* Any matching specialization of foo(r) at REPL[1]:1
julia> bar(1,5)
In REPL[1]:1
1 @noinline foo(r) = r.start
About to run: Core.getfield
1|julia > r
1:5
1|debug > q
In REPL[1]:1
1 @noinline foo(r) = r.start
About to run: Core.getfield
1|debug > q
In REPL[1]:1
1 @noinline foo(r) = r.start
About to run: Core.getfield
1|debug > q
In REPL[1]:1
1 @noinline foo(r) = r.start
About to run: Core.getfield
1|debug > q
In REPL[1]:1
1 @noinline foo(r) = r.start
About to run: Core.getfield
1|debug > q
5
If you have a loop with 1000 iterations, unless you're feeling really patient it seems you have to Ctrl-Z; killall julia
and then restart julia.
Has this gone anywhere? I am interested in the functionality as well.
Roughly planned for the next major version of the debugger. Debugger work is near the top of my todo list. Just getting the julia 1.0 core language issues that are on my plate out of the way first, so they can go in as soon as possible.
Great, thanks for the update.