JuliaDebug / Gallium.jl

The Julia debugger
Other
174 stars 23 forks source link

Does not work when called in file (not directly in REPL) #163

Open essenciary opened 8 years ago

essenciary commented 8 years ago

When doing julia -L the_file.jl if within the file I attempt Gallium.breakpoint(function_name) it crashes with UndefVarError(:active_repl)

DatName commented 8 years ago

The same exception rises when called "breakpointed" function from within Juno. More specifically: "in RunDebugREPL at ASTInterperter\src\ASTInterpreter.jl:1565".

This happens on Windows platform, Julia version is

Julia Version 0.5.0 Commit 3c9d753 (2016-09-19 18:14 UTC)

Gallium version is 0.0.4 ASTInterpreter version is 0.0.4

mm3509 commented 6 years ago

I have the same problem and a helpful comment on StackOverflow pointed me here. I do research in Julia with literate analysis: text, code, and results live in the same document, and the results in sync with the code (similar to R-markdown, e.g. in RStudio). I can have the files in either Emacs Org-mode with Org-babel or in Jupyter with IJulia. I tried Gallium and it works well in a shell session, but not in Emacs or Jupyter. In both cases I get:

ERROR: UndefVarError: active_repl not defined
Stacktrace:
 [1] RunDebugger(::Array{ASTInterpreter2.JuliaStackFrame,1}) at ~/.julia/v0.6/DebuggerFramework/src/DebuggerFramework.jl:238
dgenin commented 5 years ago

I ran into the same issue on Julia 0.6.2 and Gallium 0.1.0. I found that I could resolve the issue by adding code from https://github.com/Keno/Arsenic.jl/blob/master/bin/attach.jl to the program

if !isdefined(Base, :active_repl)
    term = Base.Terminals.TTYTerminal(get(ENV, "TERM", @static is_windows() ? "" : "dumb"), STDIN, STDOUT, STDERR)
     active_repl = Base.REPL.LineEditREPL(term, true)
     eval(Base,:(active_repl = $active_repl))
     eval(Base,:(have_color = true))
     eval(Base,:(is_interactive = true))
end

It's a hack but it seems to work and given that no one has looked at this in over 2 years it is probably the best anyone is likely to get.