delve
delve copied to clipboard
Send DAP OutputEvents on stdout/stderr of debugged process when console is `internalConsole`
Go Version: 1.18 Delve Version: 1.8.2
Current status
DAP allows sending stdout/stderr outputs back to the DAP client, by which it is shown on the debug console of the IDE. Delve spawns the debuggees with its own stdout/stderr, so the output is missing from the normal debug console. This is the desired behavior in case the terminal being used is either integratedTerminal or externalTerminal, but in the case of internalConsole, in order to allow showing the output to the user, clients required to somehow still redirect output (For example, nvim-dap-go).
Desired status
Delve would send OutputEvents of data from the debuggee's stdout/stderr if the console given is internalConsole, which would allow the DAP client to easily present it.
The problem with this is that some program will behave differently if their stdout/stderr is not a tty. It is unfortunate that DAP was designed like this.
@aarzilli Yet, other debug adapters do the same, even if running with a tty - debugpy for instance. Also, this can be configurable, and not necessarily the default behaviour.
Moreover, DAP supports runInTerminal requests by which the adapter can tell the client how to execute the debuggee, so it would have a TTY.
The specific case in debugpy can be seen here:
redirecting = arguments.get("console") == "internalConsole"
Redirection is decided in case the user specifies internalConsole as its terminal - by which this means that the user requested output to be redirected in the console. I agree this shouldn't be default behavior unless the user requested internalConsole, so perhaps updating this issue with "redirect output when console defined as internalConsole` suffices? @aarzilli
I revised the issue to only send such OutputEvent's when launch configuration is internalConsole.