# How to debug JuMP code (not debug model feasiblity, etc.) in VScode

**URL:** https://discourse.julialang.org/t/how-to-debug-jump-code-not-debug-model-feasiblity-etc-in-vscode/68613
**Category:** Optimization (Mathematical)
**Tags:** question, jump
**Created:** [September 23, 2021, 4:05am UTC](https://discourse.julialang.org/t/how-to-debug-jump-code-not-debug-model-feasiblity-etc-in-vscode/68613 "2021-09-23T04:05:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![iiitr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iiitr/32/24586_2.png) [@iiitr](https://discourse.julialang.org/u/iiitr)
#### Post date: [September 23, 2021, 4:05am UTC](https://discourse.julialang.org/t/how-to-debug-jump-code-not-debug-model-feasiblity-etc-in-vscode/68613/1 "2021-09-23T04:05:34Z")

</div>

Hi, all

When the jump macro is included in my code, the debug using vscode always jumps to some internal functions. What I want to ask is how to step through these codes without jumping into places where no breakpoints are set. for example:

```julia
model = Model(Gurobi.Optimizer)
A = 2
B = 10
@variable(model, x[1:A, 1:B]) 
@constraint(model, sum(x) == 10)

```

When I set a breakpoint at the position of `@variable(model, x[1:A, 1:B]) ` and step through it, it will be transferred to `macros.jl`.

When I set a breakpoint at the position of `@constraint(model, sum(x) == 10) ` and step through it, it will be transferred to `rewrite.jl`, and then jump to `macros.jl`.

My current approach is to write `println(...)` after the code that needs to set breakpoints to see what variables or constraints are created. This is obviously very troublesome, especially when these JuMP macros are in for loops or functions. Difficult to modify my code in real time based on the results of debugging

By the way, clicking VScode’s debug button always takes a very long time to start. Is there any way to speed up this process?

Thanks a lot !

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [September 23, 2021, 4:17am UTC](https://discourse.julialang.org/t/how-to-debug-jump-code-not-debug-model-feasiblity-etc-in-vscode/68613/2 "2021-09-23T04:17:32Z")

</div>

Others here may have advice (and I’d also be interested in hearing it), but I’ve had similar experience with the debugger.

The problem is that the code JuMP emits is not friendly to the debugger, so you can’t step into or through the `@variable` and `@constraint` macros in any meaningful way (i.e., if you write `sum(x[k] for k in 1:2)` we don’t actually call this function as written).

If you use the debugger, you’ll probably have to continue using `print` and setting breakpoints.

I’d suggest you avoid the debugger entirely and:

1. build and test each constraint in isolation
2. make use of `print(model)` or `write_to_file(model, "model.lp")` to see if the model is being constructed as you expect
3. Make use of the Julia logging tools [Logging · The Julia Language](https://docs.julialang.org/en/v1/stdlib/Logging/)
