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

Simple post mortem debugger

Open toivoh opened this issue 12 years ago • 2 comments

E.g. save scope or call stack from the last trap point, allow to step around in the scopes and evaluate expressions. Hopefully, after an unhandled error in instrumented code, it would be enough to invoke Debug.pm() to activate post-mortem debugging.

Saving away scopes like this might keep some objects alive longer than otherwise intended, but most julia code should hopefully not depend on gc cleanup? Eventually, there could be an option whether to allow keeping scopes that have been exited.

toivoh avatar Dec 14 '12 18:12 toivoh

I think a post-mortem feature would be very useful. How hard do you think it is to add? It seems like the state of the last trap could just be saved in the Debug module, however, I'm not sure how to reconstruct the program state. If you have some time I'd be willing to put some effort into this to make julia development easier.

nfoti avatar Jun 29 '13 17:06 nfoti

This would indeed be a very welcome feature. I don't think that it should be so hard to add. I think that a reasonable first step would be to save the scope from the last trap. Then the pm-debugger could then do everything that the regular debugger can do without access to a node.

Going forward, it might be interesting to

  • attach some position information to scopes
  • save not just the last scope, but a whole call stack of scopes. Otherwise we only get the lexically enclosing ones (as parents of the innermost one)

I don't have great amounts of time right now, but if you want to give it a try, I am willing to discuss design and review changes.

toivoh avatar Jun 29 '13 19:06 toivoh