New debugger?

Hello all, now that this has matured a little, I’m wondering if there is a best practice for handling Debugger.jl as a dependency. Currently, becuase using Debugger is needed to set breakpoints, it seems one needs to include Debugger as a dependency in just about every package to really use it. Is this really what I should be doing, or is there a better way?

Don’t you just get a warning when you load it if it is not in Project.toml, but available in your general environment?

I’d recommend setting breakpoints with breakpoint after loading Debugger in the REPL (or by using Juno, of course :stuck_out_tongue: ) – that way you don’t have to use any @bp annotations.

1 Like

I actually forgot about that because lately I’ve been working in the environment of one of my packages. I also don’t want to live with that warning, because I’m afraid that I’ll build my docker image and it won’t run because it crashes when tyring to import the debugger somewhere.

So, if that’s what we’re doing, I’ll just include it as a dependency for now.

breakpoint is indeed very handy, but often I just want to set a breakpoint at a particular line.

breakpoint is indeed very handy, but often I just want to set a breakpoint at a particular line.

That’s supported though – there’s a breakpoint(file, line) method.

If you want to debug using that image, I guess the best solution is to bake it in. But if it is just for CI, isn’t trying to use a debugger a wart that you would rather catch?

I know at this point I’m just being difficult, but nothing quite gives me the satisfaction of just putting in a breakpoint :laughing:

Yes, but I would have to remove all using Debugger statements before I build. I’m not currently aware of any good automated way of doing this.

It seems to me that in order to really solve this issue, breakpoints would need to be added to Base.

What about this macro:

macro mybp()
    Main.eval(:(breakpoint, @__FILE__, @__LINE__))
end

So then as long as you’ve done using Debugger in the REPL you could sprinkle the macro in your code.

Of course then you need the package code to be able to call that macro, but maybe you just copy-paste it into the package you’re working on.

edit: note I haven’t actually tested this and haven’t used Debugger.jl much, so it might not work.

1 Like