toivoh / Debug.jl

Prototype interactive debugger for Julia
Other
86 stars 13 forks source link

IJulia infinite loop on reaching breakpoint. #52

Open john9631 opened 11 years ago

john9631 commented 11 years ago

I've got a little test routine:

@debug function doitfor(x,y)
    println(x, " ", y)
    x += 1
    y *= 2
    z = 5
    for i in 1:10
        z = z+5
        z = z-3
        @bp
        z = z+6
    end
    println(x, " ", y, " ", z)
end

which in Julia in terminal results in:

julia> require("testdebug.jl")
55 1

at /home/john/Julia/data/testdebug.jl:11

      10           z = z-3
 -->  11           @bp
      12           z = z+6

debug:11> q
ERROR: interrupted
 in trap at /home/john/.julia/Debug/src/UI.jl:68
 in doitfor at no file:11
 in include at boot.jl:238
at /home/john/Julia/data/testdebug.jl:20

but in IJulia an "infinite" loop locks it up:

55 1

at In[12]:9

No context available!
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")
debug:9> ParseError("end of input")

Apologies for throwing issues at you so quickly. I've been adding the basic debug commands to my reference card so I was testing a few things. It is an excellent piece of software!

John

toivoh commented 11 years ago

Don't apologize; it's better that I know about the issues :) I've actually never tried Debug in IJulia, now I might. I will see if get some time to look into this. Did you paste your example straight into a Julia prompt or put it into a script and run it? I had an experience the other day with the No context available! message when I tried a debug example straight at the prompt, but it worked fine when I put it in a script.

john9631 commented 11 years ago

It was at the prompt (well in 3 sequential cell, enable, load code, run code ... just a sec ...

doing it this time with require("testdebug.jl") as I do it from Julia repl

No. That had almost exactly the same effect:

55 1

at /home/john/Julia/data/testdebug.jl:11

      10           z = z-3
 -->  11           @bp
      12           z = z+6

debug:11> ParseError("end of input")
debug:11> ParseError("end of input")
debug:11> ParseError("end of input")
debug:11> ParseError("end of input")
debug:11> ParseError("end of input")
debug:11> ParseError("end of input")
debug:11> ParseError("end of input")
debug:11> ParseError("end of input")
debug:11> ParseError("end of input")
debug:11> ParseError("end of input")
debug:11> ParseError("end of input")

I run ijulia from the same directory as my test files.

The test file is here

Versioninfo() shows:

Julia Version 0.2.0-rc3+4 Commit 15d0e9d (0 days old master) Platform Info: System: Linux (x86_64-linux-gnu) WORD_SIZE: 64 BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY) LAPACK: libopenblas LIBM: libopenlibm

Pkg.status() shows: Required packages:

toivoh commented 11 years ago

I see, using a script fixed the context problem¸ but not the loop. Debug uses readline() for user input. Have you tried to call it in IJulia to see if it works as in julia?

john9631 commented 11 years ago

In IJulia readline returns:

In [5]: readline()
Out[5]: ""

In [6]: typeof(readline())
Out[6]: ASCIIString (constructor with 1 method)

with no wait for input.

I'm not certain that debug should/must work in IJ Notebook because its cell by cell input model doesn't quite make the same sense ... perhaps stopping would be sufficient. In IJ Qtconsole the user would expect it to work though because it is essentially just an enhanced console.

ipython qtconsole --profile julia
toivoh commented 11 years ago

It seems that readline was just made to work in IJulia. Would you mind to try again after Pkg.update()? (Or after Pkg.checkout("IJulia") if the first one makes no difference)

john9631 commented 11 years ago

Same problem still. What I'm running:

In [2]:

versioninfo() Julia Version 0.2.0-rc4+8 Commit b778b87 (2013-11-12 18:42 UTC) Platform Info: System: Linux (x86_64-linux-gnu) WORD_SIZE: 64 BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY) LAPACK: libopenblas LIBM: libopenlibm In [3]:

Pkg.status() Required packages:

Secondary problem is that this version of IJulia Notebook is unstable so I'm going to back out of it

john9631 commented 11 years ago

I'll give it another try after the instability problem is fixed if you want. Or 24 hours from now if I see nothing on that issue.