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

Unable to step into user-defined functions sometimes

Open nfoti opened this issue 12 years ago • 1 comments

Sometimes I am not able to step into a function I've defined. I'm not sure if this is a bug or a limitation of the current package.

Here's a small example.

@debug begin

function logistic(x)
  return 1./(1+exp(-x))
end

function f()
  s = 0.
  for i in 1:10
    @bp
    tmp = logistic(rand())
    s += tmp
  end
end

end # end debug

f()

Assume the code is in testdbg.jl and run it in the repl with include("testdbg.jl"). The following sequence of commands will not step intologistic, even though it intuitively should:n,s. I would think that this would step over the breakpoint and then into the function. However, the sequences,sdoes step into logistic. It seems that as long as one usesson **both** the@bpand the line to step into then we will enter the function. Maybe the@bpsyntax should be changed to allow code on the same line, e.g.@bp logistic(rand())and theBreakPointnode in the augmented AST can be skipped over so that only ones` is required to step into the code.

If we change the example a bit to

using Debug

@debug begin

function logistic(x)
  return 1./(1+exp(-x))
end

function f()
  @bp
  s = 0.
  for i in 1:10
    tmp = logistic(rand())
    s += tmp
  end
end

end # end debug

f()

and store it in a file testdbg2.jl and run it in the repl with include("testdbg2.jl") then the only way that I can step into the logistic function (or the for-loop) is by always using s. If I ever use n then I cannot step into logistic anymore.

nfoti avatar Jul 03 '13 16:07 nfoti

I will see if I will get some time to look into this.

toivoh avatar Nov 09 '13 09:11 toivoh