Debugger.jl: feature suggestion: Couldn't we make @bp work in compiled mode?

In python it’s extremely easy to set a breakpoint. You just import pdb and then write pdb.set_trace() in your code. Once you hit a breakpoint you can single set with n / s etc.

Debugger.jl has the @bp macro to programmatically insert a breakpoint, but for some reason, this doesn’t work in compiled mode, and my code is too slow when interpreted. Why can’t this (or something like it) work in compiled mode given that you are changing the code to insert the breakpoint? It’s ok if breakpoints added with “bp add” only work in interpreted mode, but surely if I’m editing my code to add @bp, that could break into the debugger even in compiled mode because @bp (or something like it) gets to insert stuff into the compiled code.

How hard would this be to add to Debugger.jl? This would dramatically improve the debugabilty of Julia code since you can have it run fast until you hit a breakpoint you’ve manually added and then single step in interpreted mode until you’ve worked out the issue.

This isn’t an answer to your question, but a partial solution to your problem is to use the @infiltrate macro from the Inflitrator package. It opens a debug like environment at the line you call it and works in compiled code.

3 Likes

Cool! Thanks for pointing that out. I hadn’t seen this before and I have an internal version of something like this. Now, if you can just make it single step once you’ve @infiltrated the code my life will be complete…

Thanks, this thing works flawlessly!