go-delve / delve

Delve is a debugger for the Go programming language.
MIT License
23.04k stars 2.14k forks source link

feature request: option to disable unrecovered panic breakpoint #3653

Closed twpayne closed 9 months ago

twpayne commented 9 months ago

Delve version 1.21.0, Go version 1.21.6, linux/amd64.

I'm using Delve through go-pls with VS Code.

Firstly, thank you for your incredible software! Delve has helped me so much as a Go developer.

Delve creates a breakpoint for unrecoverable panics that cannot be disabled.

This is often annoying when debugging because it forces the user to interact with the debugger even when they have no interest in the panic itself.

It would be fantastic if there were an option to disable this, and other obligatory breakpoints.

I could not find an existing issue for this, although it has been requested in JetBrains.

I would be happy to contribute a PR to implement this configurability (presumably via a command line flag). Would you accept such a PR?

aarzilli commented 9 months ago

The default breakpoints for unrecovered panics and fatal errors aren't special they can be disabled (with toggle/AmendBreakpoint) or removed (clear/RemoveBreakpoint) like any other breakpoint.

It seems a pretty niche feature request, to me, for someone to want to debug a program but also be completely uninterested in actually investigating unrecovered panics (and that these happen often enough that it is inconvenient).

DAP already has an option (noDebug) to launch the program disabling the debugger.

The fact that JetBrains has a feature request for this but they haven't implemented it is further evidence that this feature is requested only rarely.

Furthermore we are probably not going to add an option to disable the creation of these breakpoints on startups even on headless mode.

Because of the above reasons, I don't think we should do this.

TomK commented 7 months ago

@aarzilli Summary: In headless mode, with no active connections, delve produces no output whatsoever that it has paused on a panic breakpoint. This has caused a headache for our development environment.

Proposed change: If delve server is running headless and has no active connections, please do NOT pause execution on the panic.

Details: We run our software suite in tilt to closely represent a production environment, with the addition of compiling the binaries with symbols and attaching a delve headless server onto the process.

Developers (mainly running Jetbrains Goland), can debug their tasks by connecting to delve using the UI.

If they hit a panic and are not currently connected to the delve server (because they are not debugging, this is an unexpected panic), delve hits the startpanic breakpoint, stopping the process from even logging anything. Leaving the dev with no idea what's going on, and having to manually kill the container. Often brushing it off as a dev environment problem.

The only way to get the output is to attempt to connect to delve, which immediately skips the breakpoint, logs the panic, and restarts the container anyway.

I appreciate there may be some way to get Jetbrains to actually stop (looking for stopOnEntry equivalent for jetbrains, no luck so far), but we still wouldn't be aware that it had actually paused execution.

EDIT: related #3469, https://github.com/go-delve/delve/pull/3632 seems to be pretty close to what we're looking for