Juno Debugger ignores breakpoints

Hi all,

I am new to Julia but I am used to debug with C++ and Python both in gdb and Jetbrains, so I know a bit the idea!

I am running a code of someone else, it is fairly complex and several functions are defined within other files.

I have the following questions and problems that I could not solve on the Juno Debugger documentation.

  1. I can only debug functions, not files. Let’s say I have not a main function but a whole file with imperative coding, can’t I debug on that?

  2. I tested both Juno.@enter while Juno.@run with a simple script, like this

function test_fun()
    a    = rand(1:5,10)
    sum(a)
    x = collect(1:2:4)
end


function test_b()
    a    = rand(1:5,10)
    sum(a)
    x = collect(1:2:4)
end


function main()
    test_b()
    test_fun()
    return 1
end

and it works very nice, I like it

  1. I now tried the debugger on my complex file, “with a lot of input and a lot of output”, it is a simulator of spiking neural network. This is the “main” file and the function I am trying to debug with Juno.@enter runsim().
using Printf
using PyPlot #set doplot=true to plot a raster. #doplot=false needed on cluster!!

g_axon_delay = false #load sim.jl or sim_delay.jl

include("../lib/structDefinitions.jl") # Defines value types.
include("../lib/filesystemstuff.jl")   # Functions to save and load hdf5 files.
include("lib/stimCreators.jl")         # Functions to define stimuli (including from language file)
if g_axon_delay
    include("lib/sim_delay.jl")        # The network simulation function with axonal delay.
else
    include("lib/sim.jl")              # The network simulation function.
end
include("lib/simplots.jl")             # Functions for rasterplot and weight histogram

function runsim()
    ##############################################################3
    # Simulation Parameters
    ###############################################################
    doplot = true      # Plot a raster and weight histogram
    save_plot = true
    loadtrained = false # If true, loads trained network.  if false, generates a new network.
    saveweights = true # Save weights to hdf5 format in Results folder. Search Nskip in sim.jl for further parameters.
    saveparams = true  # Save network parameters, popmembers and weights to hdf5 after simulation is done.
    languageinput = true
    lang_order_seed = 5432#6789 #seed that determines the permutation of input sentences
    do_readout = true  #collect membrane potentials
    do_recording = true  #collect spikerate and input currents of one neuron
    do_poprec = true  #collect spikerates per word of each population
    langfile = "LanguageInput/Input_Sentences_allWords.txt"
    partial_input = false # If true only a part of each populations neurons get stimulated. see p_input parameter in sim.jl
    input_mode = "phonemes_only" # "lexeme_only" or "phonemes_only" or "" (empty is normal mode)
    Results = "../Results/"
#DEBUGGERLOVES
    rdl = Results*"test_idle" #directory to load weights from if loadtrained==true (and sometimes language)
#DEBUGGERLOVES
    rdw = Results*"test_readout" #directory to write weights and results to
    phonms = 10 #phonemetime in milliseconds
    nwords = 200 #number of words to present
### and more and more

I have this issues:
a. the debugger ignores my breakpoints, it moves to the line with the #DEBUGGERLOVES, both if I click on “continue” or I click “next” in the debugger interface.
b. the debugger sticks in some external called function (not in the pasted script) and takes a life-time to come out, while in vanilla runs it takes less than 10 seconds.

Can you help me with this?
I wonder if the debug option enables some controls which slow the code, also I wonder if it is possible that the file is marked with debug symbols I cannot visualize from the Juno interface.
For completeness I run the same stuff from the REPL with Debugger, in that case I can set the breakpoints, but the life-lasting function is still there, and btw I prefer the fancy Juno interface that have to set those manually

Thanks a lot,
Alessio

1 Like

Currently no. Put it in a function.

It will move to the next function call. There isn’t much to debug with assignments since they are a no-op in Julia.

The code is much much slower in the debugger.

3 Likes

Juno.@run YourFunciton(arguments)

Use Juno.@run macro, which interprets your code and drops you in a debugging session if it hits a breakpoint, while Juno.@enter allows you to step through starting from the first line.
It is faster as well.

Also, try some other debuggers like JuliaInterpreter. I have also some problems with the debuggers in Julia.

Is there any debugger which will be faster? maybe I am using the debugger in a wrong way or Juno debugger is very slow? Me copy pasting code manually into REPL takes much less time than waiting for the debugger to do its thing and reach my breakpoint.
Particularly among all debuggers introduced here, which one is faster for hitting breakpoint?
https://julialang.org/blog/2019/03/debuggers

Yeah, that’s what I said. Code being debugged is slower.

They are all equally fast, they are just different frontends for the same debugger backend.

1 Like

Hi,
thanks for explanation, I should read a bit more about how Julia process code.

Btw the debugger is that slow that I cannot use in my project proficiently, like the code itself takes 10 minutes, with the debugger I just go home from work.
Crucially the operations that take the most of the time are matrix multiplication and initialization.

Have you tried to check the “Run in compile mode” box of Juno’s debugger?

My understanding is that if the slower part of your code is in a function different of that which you are @entering - and you don’t step deliberately into that function - the performance of the debugging mode will not be spoiled that much if you do that (although it will always be slower than the “normal” mode anyway).

Hi, thanks for answering,
yes I tried, but the @run macro skips my breakpoints all the way through, while the @enter keep being enough slow to prevent the usage of the debugger.

Always depends on what function’s you’re using, but you can usually get pretty good performance out of the debugger in compiled mode:

julia> using BenchmarkTools

julia> function expensive(N)
           A = rand(N, N)
           b = rand(N)

           return A*b
       end
expensive (generic function with 1 method)

julia> @btime expensive(10000)
  511.712 ms (6 allocations: 763.09 MiB)

julia> @btime Juno.@run expensive(10000);
  540.510 ms (276 allocations: 763.11 MiB)

Also note that once you’ve stepped into a function all breakpoints set directly in that functions will still be respected, so setting a breakpoint e.g. on the second line and running your code with Juno.@enter in compiled mode, followed by Continue will get you to your breakpoint quite quickly (usually).

1 Like