# Debugging Julia

**URL:** <https://discourse.julialang.org/t/debugging-julia/22147>\
**Category:** Package Announcements\
**Created:** [March 21, 2019, 2:34pm UTC](https://discourse.julialang.org/t/debugging-julia/22147 "2019-03-21T14:34:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 21, 2019, 2:34pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/1 "2019-03-21T14:34:44Z")

</div>

After two and half months of intense collaborative development, we (@kristoffer.carlsson, @pfitzseb, and myself, based on original work by @Keno) are pleased to announce a fully-featured debugging stack for Julia. You can read details in a new blog post:

> **[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:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [March 21, 2019, 2:45pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/2 "2019-03-21T14:45:08Z")

</div>

How does one run `@interpret MyPackageTests` for a package that follows the usual separation of `src` and `test` directories?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 21, 2019, 3:09pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/3 "2019-03-21T15:09:52Z")

</div>

Currently it’s a bit more involved than `@interpret`, unfortunately. Check out the [`test/utils.jl`](https://github.com/JuliaDebug/JuliaInterpreter.jl/blob/master/test/utils.jl) file and try something like

```julia
run_test_by_eval("name of tests", filename, 10^6)

```

where `filename` is the absolute path to your test file. 10^6 controls the maximum number of statements the interpreter will run before giving up and switching to compiled code.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [March 21, 2019, 3:24pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/4 "2019-03-21T15:24:23Z")

</div>

Congratulations and great work by all involved!  
This has been epic to watch come together,  
and the side-effects bring wide ranging improvements to the ecosystem.  
(E.g. Revise.jl v2.0)

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [March 21, 2019, 3:29pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/5 "2019-03-21T15:29:00Z")

</div>

Awesome stuff. But how do you set a break point?

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [March 21, 2019, 3:31pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/6 "2019-03-21T15:31:02Z")

</div>

Am I doing something wrong with `JuliaInterpreter`, or is broadcasting just not implemented yet?

```julia
In [14]: x = rand(1:500, 16000);

In [15]: @interpret x .* x
UndefVarError: .* not defined

Stacktrace:
 [1] top-level scope at /home/adam/.julia/packages/JuliaInterpreter/62ZyY/src/construct.jl:638
 [2] execute_request(::ZMQ.Socket, ::IJulia.Msg) at /home/adam/.julia/packages/IJulia/4UizY/src/execute_request.jl:67
 [3] #invokelatest#1 at ./essentials.jl:742 [inlined]
 [4] invokelatest at ./essentials.jl:741 [inlined]
 [5] eventloop(::ZMQ.Socket) at /home/adam/.julia/packages/IJulia/4UizY/src/eventloop.jl:8
 [6] (::getfield(IJulia, Symbol("##15#18")))() at ./task.jl:259

```

In any case, all of this is **very** exciting. Kudos to everyone involved.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 21, 2019, 3:31pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/7 "2019-03-21T15:31:03Z")

</div>

Nicely done all.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [March 21, 2019, 3:32pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/8 "2019-03-21T15:32:38Z")

</div>

That’s just a case of Julia itself behaving poorly — and same problem as `@which x .* x`. Instead try `@interpret broadcast(*, x, x)` or `f(x) = x .* x; @interpret f(x)`.

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [March 21, 2019, 3:33pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/9 "2019-03-21T15:33:40Z")

</div>

Ah. Makes sense. I still haven’t entirely wrapped my head around how arguments to macros work. Thanks!

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [March 21, 2019, 3:41pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/10 "2019-03-21T15:41:19Z")

</div>

> **[GitHub - JuliaDebug/Debugger.jl: Julia debugger](https://github.com/JuliaDebug/Debugger.jl#breakpoints)**
>
> Julia debugger. Contribute to JuliaDebug/Debugger.jl development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 21, 2019, 3:48pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/11 "2019-03-21T15:48:37Z")

</div>

All three packages support the methods in [JuliaInterpreter](https://juliadebug.github.io/JuliaInterpreter.jl/stable/), which is what’s documented in Debugger’s README as linked by Stefan. Moreover,

- in Juno you can just click in the leftmost column (you have to have fully-updated atom packages `ink` and `julia-client`)
- in Rebugger you can just hit `b` or `c` when you come to a line that you want to set a breakpoint at

---

<div class="post-metadata">

**Author:** ![louisponet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/louisponet/32/2070_2.png) [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Post date:** [March 21, 2019, 3:57pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/12 "2019-03-21T15:57:01Z")

</div>

Very Nice! Thanks a lot for this.

How well does this handle things as `@async while true .... end` things? Last time I checked it didn’t really. (mainly interested in breakpoint on error stuff)

---

<div class="post-metadata">

**Author:** ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)\
**Post date:** [March 21, 2019, 4:08pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/13 "2019-03-21T16:08:32Z")

</div>

1. This is awesome, thanks to all involved!!
2. You might want to change the README’s Usage section to mention that one has to use `Juno.@enter` when running in Juno (this confused me until I read the blog post).

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 21, 2019, 4:14pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/14 "2019-03-21T16:14:25Z")

</div>

It can’t work through tasks, at least not yet. Works fine without the `@async`, though. In Rebugger:

```julia
julia> using Rebugger

julia> function foo()
           while true
               error("oops")
           end
       end
foo (generic function with 1 method)

julia> foo()
ERROR: oops
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] foo() at ./REPL[2]:3
 [3] top-level scope at none:0

interpret> foo() # here I hit Meta-i followed by Enter (to run until breakpoint)
foo() in Main at REPL[2]:2
foo() in Main at REPL[2]:2
 error(s::AbstractString) in Base at error.jl:33
  s = oops
 33 error(s::AbstractString) = begin
 33 throw(ErrorException(s))
         end

```

---

<div class="post-metadata">

**Author:** ![louisponet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/louisponet/32/2070_2.png) [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Post date:** [March 21, 2019, 4:18pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/15 "2019-03-21T16:18:02Z")

</div>

Ok cool, Yea the main issues with debugging I’ve had recently were related to some rendering package I’m working on that let’s you asyncronous interact with what’s displayed. But I’ll somehow find a way to use these tools with it during development! Thanks again

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [March 21, 2019, 4:39pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/16 "2019-03-21T16:39:59Z")

</div>

How to remove breakpoints when using Debugger.jl? It doesn’t seem to reexport `remove()` or `disable()` from JuliaInterpreter.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 21, 2019, 4:42pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/17 "2019-03-21T16:42:03Z")

</div>

Hi, confess that have been having some difficulties using the debugger (btw, thanks a LOT for this work). Shouldn’t the `MethodError` be caught (at least this one isn’t)?

```julia
julia> using Debugger, JuliaInterpreter

julia> cd("c:/v");using GMT, Webview

julia> break_on(:error)

julia> grdcontour("@osu91a1f_16.nc", R=:d, J=:H14, cont=10, A="50+f7p", G=(params=(dist="4i",),), L=(-1000,-1), W=((contour=1,pen="thinnest,-"), (annot=1, pen="thin,-")), T=(gap=("0.1i","0.02i"),), Vd=1)
ERROR: MethodError: no method matching *(::String, ::Tuple{String,String})
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...) at operators.jl:502
  *(::Union{AbstractChar, AbstractString}, ::Union{AbstractChar, AbstractString}...) at strings/basic.jl:229
  *(::AbstractString, ::Missing) at missing.jl:144
Stacktrace:
 [1] add_opt(::NamedTuple{(:params,),Tuple{NamedTuple{(:dist,),Tuple{String}}}}, ::NamedTuple{(:params,),Tuple{Tuple{String,typeof(GMT.helper_decorated)}}}, ::Nothing) at C:\j\.julia\v0.7\GMT\src\common_options.jl:913
 [2] add_opt(::String, ::Char, ::Dict{Symbol,Any}, ::Array{Symbol,2}, ::NamedTuple{(:params,),Tuple{Tuple{String,typeof(GMT.helper_decorated)}}}, ::Bool, ::Nothing) at C:\j\.julia\v0.7\GMT\src\common_options.jl:869
 [3] add_opt at C:\j\.julia\v0.7\GMT\src\common_options.jl:867 [inlined]
 [4] #grdcontour#80(::Bool, ::Base.Iterators.Pairs{Symbol,Any,NTuple{9,Symbol},NamedTuple{(:R, :J, :cont, :A, :G, :L, :W, :T, :Vd),Tuple{Symbol,Symbol,Int64,String,NamedTuple{(:params,),Tuple{NamedTuple{(:dist,),Tuple{String}}}},Tuple{Int64,Int64},Tuple{NamedTuple{(:contour, :pen),Tuple{Int64,String}},NamedTuple{(:annot, :pen),Tuple{Int64,String}}},NamedTuple{(:gap,),Tuple{Tuple{String,String}}},Int64}}}, ::Function, ::String, ::Array{Any,1}) at C:\j\.julia\v0.7\GMT\src\grdcontour.jl:95
 [5] #grdcontour at .\none:0 [inlined] (repeats 2 times)
 [6] top-level scope at none:0

```

---

<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:** [March 21, 2019, 4:42pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/18 "2019-03-21T16:42:04Z")

</div>

We should reexport them as well. You can use `Debugger.JuliaInterpreter.remove` for now.

Edit: [reexport some more breakpoint functionality by KristofferC · Pull Request #133 · JuliaDebug/Debugger.jl · GitHub](https://github.com/JuliaDebug/Debugger.jl/pull/133)

---

<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:** [March 21, 2019, 4:43pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/19 "2019-03-21T16:43:06Z")

</div>

> [@joa-quim](#):
>
> Hi, confess that have been having some difficulties using the debugger (btw, thanks a LOT for this work). Shouldn’t the `MethodError` be caught?

You need to actually run the debugger (with `@enter`). Otherwise you are just executing normal julia.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [March 21, 2019, 4:45pm UTC](https://discourse.julialang.org/t/debugging-julia/22147/20 "2019-03-21T16:45:40Z")

</div>

Ghrrr, sure. I did it yesterday but today I must be convinced that I already know how to use it (which I obviously don’t. Have also issues breaking at deep nested methods but that’s probably for another question).

[Next page](https://discourse.julialang.org/t/debugging-julia/22147.md?page=2)
