_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using Debugger
[ Info: Precompiling Debugger [31a5f54b-26ea-5ae9-a837-f05ce5417438]
┌ Warning: Module JuliaInterpreter with build ID 1729437351070136 is missing from the cache.
│ This may mean JuliaInterpreter [aa1ae85d-cabe-5617-a682-6adf51b2e16a] does not support precompilation but is imported by a module that does.
└ @ Base loading.jl:947
julia> function f(n)
a=20
for i = 1:20
s=n+i+a
end
end
f (generic function with 1 method)
julia> @enter f(20)
In f(n) at none:2
1 2 1 ─ a = 20
>2 4 │ %2 = (Colon())(1, 20)
3 │ #temp# = (iterate)(%2)
4 │ %4 = (===)(#temp#, nothing)
5 │ %5 = (not_int)(%4)
6 └── goto #4 if not %5
* `o` : open the current line in an editor
* `q` : quit the debugger, returning `nothing`
* `C` : toggle compiled mode
* `L` : toggle showing lowered code instead of source code
* `+` / `-` : increase / decrease the number of lines of source code shown
It works out well, except the option o. But it is understandable because the function f is in REPL, not in a file. But, I’m deeply confused with the option n
``n : step to the next line
julia> @enter f(20)
In f(n) at none:2
1 2 1 ─ a = 20
>2 4 │ %2 = (Colon())(1, 20)
3 │ #temp# = (iterate)(%2)
4 │ %4 = (===)(#temp#, nothing)
5 │ %5 = (not_int)(%4)
6 └── goto #4 if not %5
7 2 ┄ %7 = #temp#
About to run: (Colon())(1, 20)
1|debug> n
ERROR: MethodError: no method matching iterate(::Core.SSAValue)
Closest candidates are:
iterate(::Core.SimpleVector) at essentials.jl:589
iterate(::Core.SimpleVector, ::Any) at essentials.jl:589
iterate(::ExponentialBackOff) at error.jl:171
...
Stacktrace:
[1] f(::Int64) at none:4
Not sure why I get this error, as the only thing I’d like to do is to step into the next line. Any comments are greatly appreciated.
The example works for me (Julia 1.2, Debugger 0.6.2).
The precompile warning probably means that something is wrong with the Debugger installation. I would try to remove Debugger, restart and add it back in.
Something seems odd with your REPL history file. It prints weirdly because it cannot find the source code of the function (which gets stored in .julia/logs/repl_history.jl.
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.2.0 (2019-08-20)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> ┌ Warning: Juno's evalrepl handler is deprecated.
└ @ Atom ~/.julia/packages/Atom/X8fAI/src/eval.jl:117
julia>
(v1.2) pkg> activate ~/Desktop/dev
Activating environment at `~/Desktop/dev/Project.toml`
current directory:/home/Desktop/myProject
*************** generating simulation input files *********************
***************** simulating with generated simulation input files **************************
In #initSim!#23(allowWriteOutput, doPrint, , configFln) at /home/devel/Desktop/simbulance_oct_21st/init_sim.jl:15
13 function initSim!(configFln::String; allowWriteOutput::Bool = true, doPrint::Bool = true)
14 # two progress function definitions
>15 timeLog = 0.0 # if doPint is true, then get the current time log returned by time() function, and print out current time and message; meanwhile, the value of variable timeLog is updated
16 updateTimeLogPrintMsg(msg) = doPrint && (timeLog = time(); println("current time: ", timeLog, " message: ", msg))
17 printTimeSinceLastLog() = doPrint && println("time taken since last time log: ", time()-timeLog, " seconds")
18 ############################################################################
19 crrDir = @__DIR__ # current working directory
About to run: (Core.Box)()
1|debug>
no previous command executed
1|debug>
no previous command executed
1|debug>
the last three command I tried out is, option n, option c, …
I do not know why it does not work. I think it probably has something to do with the warning message.
In any case, if you want a UI debugger then follow these docs, and if you don’t then make sure to stay in the REPL (crucially, you need to start debugging in the REPL, not in a Juno editor).
Thank you for your quick reply, You mean using Juno for Julia debugging is different from using debugger.jl? I finally got it running in REPL using debugger.jl to debug my project code. Yet, the current situation is, it does not recognise the @bp (to set a breakpoint)… sigh.
If you really want to use @bp in your source code, make sure that Debugger is available in whatever module your code is in. So you’ll need to have e.g.
module MyModule
using Debugger
function f(x)
y = sin(x)
@bp
return cos(y)*sin(x)
end
end
In most cases I’d recommend the bp command though (or just use Juno and click on the line number).
Is debugger package any different from all other packages, like CSV, DataFrames, etc… Because, I put “using Debugger” where I put all the other “using ***” in my project setting, and tried both “@enter myFunction(myArgument)” and “Debugger.@enter myFunction(myArgument)” and it does not work as I expected, only to get “@enter not defined error”. On the other hand, if I put “using Debugger” in the files where “@enter” or “@bp” is used, then it works.
Only in that you both need it when starting your debugging session (with Debugger.@enter) and when you want to put a breakpoint into your source code with Debugger.@bp.
In my experience it’s fairly stable, but you’ll definitely run into trouble with code that does lots of operations. Switching to compiled mode is very helpful in those cases.
Thank you for your quick reply. I finally roughly figure out why do I get the feedback message “no previous command executed”. Somehow I typed “n” and then press enter, but debugger does not get it. Debugger understands it as “nothing”, which literally means nothing is typed… sigh. In this case, it will execute the previous command. But there is no previous command.