# Juno Debugger ignores breakpoints

**URL:** <https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988>\
**Category:** Juno\
**Created:** [July 3, 2019, 3:15pm UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988 "2019-07-03T15:15:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![alequa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alequa/32/12338_2.png) [@alequa](https://discourse.julialang.org/u/alequa)\
**Post date:** [July 3, 2019, 3:15pm UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988/1 "2019-07-03T15:15:08Z")

</div>

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

```julia
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().

```julia
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

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [July 3, 2019, 3:39pm UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988/2 "2019-07-03T15:39:06Z")

</div>

> [@alequa](#):
>
> 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?

Currently no. Put it in a function.

> [@alequa](#):
>
> 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.

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

> [@alequa](#):
>
> I wonder if the debug option enables some controls which slow the code,

The code is much much slower in the debugger.

---

<div class="post-metadata">

**Author:** ![Amin\_Yahyaabadi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amin_yahyaabadi/32/9826_2.png) [@Amin\_Yahyaabadi](https://discourse.julialang.org/u/Amin_Yahyaabadi)\
**Post date:** [July 4, 2019, 12:54am UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988/3 "2019-07-04T00:54:38Z")

</div>

> [@alequa](#):
>
> 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().

`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.

---

<div class="post-metadata">

**Author:** ![Amin\_Yahyaabadi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amin_yahyaabadi/32/9826_2.png) [@Amin\_Yahyaabadi](https://discourse.julialang.org/u/Amin_Yahyaabadi)\
**Post date:** [July 4, 2019, 1:01am UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988/4 "2019-07-04T01:01:02Z")

</div>

> [@kristoffer.carlsson](#):
>
> The code is much much slower in the debugger.

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?

> **[A Julia interpreter and debugger](https://julialang.org/blog/2019/03/debuggers/)**
>
> A Julia interpreter and debugger | The authors are pleased to announce the release of a fully-featured...

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [July 4, 2019, 1:59pm UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988/5 "2019-07-04T13:59:10Z")

</div>

> [@Amin\_Yahyaabadi](#):
>
> Me copy pasting code manually into REPL takes much less time than waiting for the debugger to do its thing and reach my breakpoint.

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

> [@Amin\_Yahyaabadi](#):
>
> Particularly among all debuggers introduced here, which one is faster for hitting breakpoint?

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

---

<div class="post-metadata">

**Author:** ![alequa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alequa/32/12338_2.png) [@alequa](https://discourse.julialang.org/u/alequa)\
**Post date:** [July 4, 2019, 2:34pm UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988/6 "2019-07-04T14:34:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [July 4, 2019, 2:52pm UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988/7 "2019-07-04T14:52:48Z")

</div>

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

> [@\[ANN\] Juno 0.8.7](https://discourse.julialang.org/t/ann-juno-0-8-7/24682):
>
> Hey folks, Juno 0.8.7 is out and brings an updated Debugger along with a few bugfixes and small features: Features Setting breakpoints in files does not require Revise anymore. Run in Compiled Mode toggle when debugging ([#299](https://github.com/JunoLab/Juno.jl/issues/299)). Both Break on Exception and Break on Uncaught Exception are now implemented. Search in Workspace/Documentation panes is automatically focused ([#200](https://github.com/JunoLab/atom-ink/pull/200)). Added return-from-goto command ([#170](https://github.com/JunoLab/atom-ink/issues/170)). stdlib paths printed in the REPL are now clickable. Packages in the Open Packa…

My understanding is that if the slower part of your code is in a function different of that which you are `@enter`ing - 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).

---

<div class="post-metadata">

**Author:** ![alequa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alequa/32/12338_2.png) [@alequa](https://discourse.julialang.org/u/alequa)\
**Post date:** [July 4, 2019, 2:59pm UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988/8 "2019-07-04T14:59:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [July 4, 2019, 4:35pm UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988/9 "2019-07-04T16:35:44Z")

</div>

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
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).

---

<div class="post-metadata">

**Author:** ![floswald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/floswald/32/195_2.png) [@floswald](https://discourse.julialang.org/u/floswald)\
**Post date:** [February 10, 2020, 9:04am UTC](https://discourse.julialang.org/t/juno-debugger-ignores-breakpoints/25988/10 "2020-02-10T09:04:19Z")

</div>

wow, doing what’s written in that little post just increased my debugging efficiency by a huge factor! i used to wait for 20 mins till the debugger ran through some code. no more! awesome work. thanks.
