# Debugger.jl: Access object \`%2\`

**URL:** <https://discourse.julialang.org/t/debugger-jl-access-object-2/39959>\
**Category:** General Usage\
**Created:** [May 22, 2020, 12:31pm UTC](https://discourse.julialang.org/t/debugger-jl-access-object-2/39959 "2020-05-22T12:31:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gdkrmr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdkrmr/32/2791_2.png) [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Post date:** [May 22, 2020, 12:31pm UTC](https://discourse.julialang.org/t/debugger-jl-access-object-2/39959/1 "2020-05-22T12:31:01Z")

</div>

I am trying to debug some code using `Debug.jl`:

```julia
In _pullback(ctx, f, args) at /home/gkraemer/.julia/packages/Zygote/YeCEW/src/compiler/interface2.jl:7
  1 1 ─ $(Expr(:meta, :inline))
  2 │ %2 = (ZygoteRules._pullback)(ctx, Zygote.unwrap, :(Main.sr), Main.sr)
> 3 │ %3 = (getindex)(%2, 1)
  4 │ %4 = (getindex)(%2, 2)
  5 │ %5 = (ZygoteRules._pullback)(ctx, loss, %3)
  6 │ %6 = (getindex)(%5, 1)
  7 │ %7 = (getindex)(%5, 2)
  8 │ %8 = (tuple)(%4, %7)
  9 │ %9 = (typeof(∂(#18)))(%8)
 10 │ %10 = (tuple)(%6, %9)
 11 └── return %10

About to run: <(getindex)((VBagg.Bags{Float64}(VBagg.Bag{Float64}[VBagg.Bag{Float64}([0.9323391769092779 0.056934747...>
1|julia> %2
ERROR: syntax: "%" is not a unary operator

```

I want to know how `%2` looks like, because the code will fail when executing line 4. In normal code I can just press ``` and get an interactive Julia prompt to explore local variables. This doesn’t work in the present case. How can I take a look at `%2`?

---

<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:** [May 22, 2020, 5:58pm UTC](https://discourse.julialang.org/t/debugger-jl-access-object-2/39959/2 "2020-05-22T17:58:32Z")

</div>

I am not sure Debugger.jl is set up to support this. If you can create all the arguments to `_pullback`, you could manually create a `frame` with `JuliaInterpreter.enter_frame` and then issue `debugcommand`s until you’ve passed statement 2. Then you can look up the value in `frame.framedata.ssavlues`.

For more info, see the [docs](https://juliadebug.github.io/JuliaInterpreter.jl/stable/).

---

<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:** [May 22, 2020, 6:22pm UTC](https://discourse.julialang.org/t/debugger-jl-access-object-2/39959/3 "2020-05-22T18:22:28Z")

</div>

Yeah, we should add syntax in Debugger.jl for querying SSAvalues. Any suggestions?

---

<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:** [May 22, 2020, 6:46pm UTC](https://discourse.julialang.org/t/debugger-jl-access-object-2/39959/4 "2020-05-22T18:46:51Z")

</div>

Debugger seems to get the string and then do its own parsing. Could we just check for a first non-whitespace character of `%`?

---

<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:** [May 22, 2020, 7:53pm UTC](https://discourse.julialang.org/t/debugger-jl-access-object-2/39959/5 "2020-05-22T19:53:24Z")

</div>

I thought it would be cool to include it in the standard julia evaluation mode (which uses the Julia parser) so you could do `sin(a * %2 * 5)` for example but that runs into `%` not being an infix operator. Hmm…

---

<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:** [May 22, 2020, 7:58pm UTC](https://discourse.julialang.org/t/debugger-jl-access-object-2/39959/6 "2020-05-22T19:58:59Z")

</div>

`var"%2"`? That’s what I’d try to do (as a user) first.

---

<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:** [May 22, 2020, 8:00pm UTC](https://discourse.julialang.org/t/debugger-jl-access-object-2/39959/7 "2020-05-22T20:00:13Z")

</div>

Yeah, that is a good idea, I’ll try it out.

---

<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:** [May 22, 2020, 8:48pm UTC](https://discourse.julialang.org/t/debugger-jl-access-object-2/39959/8 "2020-05-22T20:48:30Z")

</div>

[https://github.com/JuliaDebug/JuliaInterpreter.jl/pull/395](https://github.com/JuliaDebug/JuliaInterpreter.jl/pull/395) has a PR with the var syntax:

```julia
1|debug>
In sin(x) at special/trig.jl:30
  3 │ Core.NewvarNode(:(n))
  4 │ absx = (abs)(x)
  5 │ %5 = absx
  6 │ %6 = ($(Expr(:static_parameter, 1)))(π)
> 7 │ %7 = (/)(%6, 4)
  8 │ %8 = (<)(%5, %7)
  9 └─── goto #6 if not %8
 10 2 ── %10 = absx
 11 │ %11 = (eps)($(Expr(:static_parameter, 1)))

About to run: (/)(3.141592653589793, 4)
1|julia> var"%5", var"%6"
(2.0, 3.141592653589793)

```
