forked from go-delve/delve
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dap: handle reverse request flow (e.g. RunInTerminal)
This PR adds support for reverse requests that are sent from the debug adapter to the client. Currently, RunInTerminal is the only such reverse request. This is a pre-work for the 'console' support (golang/vscode-go#124) - we plan to use RunInTerminal to ask the editor to run a command in the integrated or external terminal while handling a launch request with the console attribute. Launch request was classified as a synchronous request and was blocking ServeDAPCodec loop, which means the response message from the client couldn't be read until onLaunchRequest returns. This PR adds two goroutines - one to handle requests from the client (loopHandleRequests), and another to handle responses (loopHandleResponses). serveDAPCodec will keep read DAP messages from the net.Conn, but delegate message handling to the goroutines through buffered channels. Alternatively, I tried to avoid introducing goroutines by making onLaunchRequest asynchronously complete the launch if integrated or external console mode is chosen. I.e., make onLaunchRequest return without sending LaunchResponse, free the ServeDAPCodec loop, and return LaunchResponse (or ErrorResponse) when RunInTerminal response is received. But it was hard to follow, didn't look like a typical go program, and wasn't extensible when DAP adds more reverse requests or we ever want to utilize RunInTerminal while handling other requests. For reverse requests, we maintain a pendingReverseReq map for requests sent to the client. When response messages arrive we look up the map, and notify the waiters using a buffered channel. onLaunchRequest uses RunInTerminal if the launch request has "integrated" or "external" console attribute and asks the client to run a bogus command - this is for testing. The follow up PRs will implement the real command that starts a delve and use the command from the integrated or external terminal.
- Loading branch information
Showing
3 changed files
with
281 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.