-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add terminateDebugger option to disconnect request #175
Comments
@polinasok in #177 (comment) I tried to explain why "debuggers" are not part of the DAP and are not surfaced in the VS Code UI. If we would add it to DAP, we would have to consider a corresponding UI in clients. However, today I do not see a strong need for this in clients or debug extensions: I'm not aware of any client or debug extension asking for such a mechanism. @polinasok Did you consider implementing such a feature in your extension (as an implementation detail of your dlv debugger extension)? Based on such an implementation it would be much easier to "sell" the feature to other clients and debugger extensions, and - if enough interest is sparked - to move it into DAP. |
Yes, if DAP were to add this option, my next issue request would be for vscode to support this in the UI :) @hyangah Just to document this better, I am hoping to implement an equivalent of this:
|
Thanks @polinasok for looking into it. dlv is one of the first attempts that implement DAP natively from the debugger, so we need some creativity. IMO dlv DAP implementation shouldn't bring down the entire dlv server just because the client (vscode) disconnects from the server by default. Rather, I wish dlv's debug adapter implementation was implemented in a layer separate from the protocol server and represented as an internal state whose lifetime is bound to a single client's connection (let's assume we named it Then, whether to exit or not after a For example, if the dlv server has started with According to the spec, Disconnect Request is described as:
I hope my interpretation of the protocol spec isn't too far off from what DAP's Disconnect Request is originally meant for - we will still terminate the debug adapter ( I still don't know how to interpret the Terminate request though - disable it when running in It would be convenient if users are given a choice to terminate the dlv server even when the server is running with the For the dlv server started by the extension, the extension maintains the dlv server's lifetime and we can prompt users, but I still want to understand use cases. Apart from this specific feature request, I think it would be nice if DAP supports a feature equivalent to LSP's |
I'm strongly against this. In many clients there is no appropriate or convenient way to present this to a user and/or interrupt what they are doing to questions like this. It's better for things to just work consistently rather that ask the user lots of questions at arbitrary times (IMO). Even so, in practice these sorts of interfaces become facsimiles of like a user-interface definition paradigm where we expose the concept of the user interface on top of the protocol. I'm not against specific messages that the client might implement by prompting the user, but I am against allowing the debug adapter to instruct the client to perform user-interface operations; that breaks the encapsulation and isolation that the protocol provides. An example of a specific such message is the (custom) |
@puremourning Thanks for sharing your thought. I didn't suggest this be required to be implemented in every adapter/client. In LSP, this capability is enabled only when both client and server can support. DAP also has similar capability negotiation. So I expect debug adapters are free to ignore this if it's not useful for them. There is no concept like |
My point about the other 2 example is that specific requests for specific purposes is good, but generic ‘anything goes’ requests are blunt instruments which are frequently abused. Regarding whether clients can/should implement things: the fact of the matter is that server authors only test with one client. And if another client doesn’t implement something then either it doesn’t work properly or the experience is sub standard. I’m simply advocating that we use specific things like originally proposed, not nebulous generic things like LSP introduced. |
I tried to explain above that DAP does not (yet) have a concept of "(long running) debuggers" and since there is only a single feature request asking for this, I'm not convinced that we want to introduce another concept to DAP without having a full UI story in DAP clients and DAs. The dlv debugger is started by the command line (not VS Code!), so IMO a natural way to stop it is via the command line. If there is a strong need to provide VS Code UI for "debuggers" then the dlv/go extension can implement this first and if this is successful and other debug extensions want to do the same, we can promote the private implementation into DAP (and the VS Code client). For now I will move this request to the backlog. |
If the DA server/debugger is started from the command-line, not VS code (or some other DAP-compatible editor), then, yes, it is a natural way to stop it via the command-line. Having an option to stop it from the client (such as VS code) via a user UI control translated into a setting in a DAP request would be for convenience. And yes, we have considered specifying this as part of the launch/attach request arguments (as @hyangah mentioned above), but that is not the most convenient option because the user might not know if they want to stop the debug server before they completed their debugging task and found what they were looking for. The next question is if we want to allow a user to be able to rely on editor (such as VS Code) to start-up a reusable DA server/debugger for them (instead of starting it externally). Sometimes the users start the server manually not because they have to (e.g. due to remote system permissions), but because that gives them access to additional features. So ultimately we might want to streamline this for them and cut out the extra steps to improve the overall experience. But if they specify at start-up that they want us to launch a reusable server that will accept multiple connections from vscode or other clients, then it would be natural for them to expect different disconnect behavior and different disconnect controls than what they would in other cases. This is, of course, a corner case, and it is very possible that it is unique to Go. I can see how it makes sense to push this to the Backlog and see if more users and implementors would be interested in this feature. In the meantime, I am wondering about the following:
|
For 2, I dont know about vscode, but my client vimspector already provides an out-of-band way to start debuggers (such as gdbserver, debugpy, lldb-server, delve) as part of its remote debugging marshalling features. DAP itself doesn’t need to be involved in this part, it’s done outside the Debugger client-debug adapter interaction. It’s effectively doing the ‘manually from the command line’ parts above, just not manually. Presumably other clients can do the same. |
Couple more thoughts on long-running debuggers. We have the following component with a debugger that is also a DA server, communicating via the DAP protocol:
A long-running debugger/DA can therefore mean:
(B) and (C) are implementation details. The end user nor the client should not normally care if the server survives between the sessions because each session is independent. But (A) is a special case, a feature that the end user might want to request explicitly, so they can rely on the debugger being long-running and connect to it in other ways. So I think in this use case exposing the debugger concept is inevitable and comes with the territory. But, of course, if this is only something that Go debugging cares about, then it is not a critical use case for DAP to support. |
@polinasok I've tried to answer your two questions from above: yes, we can easily add implementation-specific arguments to the Introducing the I think an alternative exists: the dlv/go extension can introduce "private" properties on DAP's disconnect |
@hyangah above you said:
We have tried to improve the documentation for If you do not want to support |
By default dlv debugger terminates itself when the debug session is terminated. However, if it is run with an option to allow multiple client connections, concurrently or sequentially (tracing and debugging the same process), then disconnect issued by a single client does not mean automatic detachment and termination. Instead the cli gives the client a prompt with a choice to terminate the server or keep it running while still attached to the process. This works with both launch and attach, as it is not uncommon for users to launch a remote debugging session and then keep reconnecting to it.
Can such a choice be supported via the DAP protocol? For example, for terminating or not the debuggee, we have
terminateDebuggee
. Can a similarterminateDebugger
option be added as well?The text was updated successfully, but these errors were encountered: