Debugger.jl icon indicating copy to clipboard operation
Debugger.jl copied to clipboard

Debugger REPL has no memory

Open CameronBieganek opened this issue 5 years ago • 5 comments

julia> function foo(x)
           y = 2x
           a = 1
           return a + y
       end
foo (generic function with 2 methods)

julia> @enter foo(3)
In foo(x) at REPL[13]:2
 1  function foo(x)
>2      y = 2x
 3      a = 1
 4      return a + y
 5  end

About to run: (*)(2, 3)
1|debug> n
In foo(x) at REPL[13]:2
 1  function foo(x)
 2      y = 2x
 3      a = 1
>4      return a + y
 5  end

About to run: (+)(1, 6)
1|julia> asdf = 1234  # I typed ` here to run code in the context of foo() 
1234

1|julia> asdf
ERROR: UndefVarError: asdf not defined

Another issue with this example, unrelated to the title of this issue, is that when I hit n it ran both the y = 2x line and the a = 1 line. As far as I know, hitting n should only run one line.

CameronBieganek avatar Apr 12 '20 22:04 CameronBieganek

n will take you to the next call.

Introducing new local variables is not supported, you can do global asdf =...

KristofferC avatar Apr 12 '20 22:04 KristofferC

Oh, that's interesting. The docs seem to be misleading on that account:

n: step to the next line nc: step to the next call

Thanks for the global asdf tip! I guess that addresses the issue in the title.

CameronBieganek avatar Apr 13 '20 00:04 CameronBieganek

Well, not really the next call but the next call that is on a line greater than the current line.

KristofferC avatar Apr 13 '20 10:04 KristofferC

We should maybe make it more clear that we only ever care about calls, never about assignments etc.

pfitzseb avatar Apr 13 '20 12:04 pfitzseb

Yeah, makes sense

KristofferC avatar Apr 13 '20 12:04 KristofferC