From 5459034a98090c303617cee43f571dd34dde52a6 Mon Sep 17 00:00:00 2001 From: polinasok <51177946+polinasok@users.noreply.github.com> Date: Fri, 16 Jul 2021 09:49:16 -0700 Subject: [PATCH] cmd/dap: server - always headless, target - always foregrounded (#2589) Co-authored-by: Polina Sokolova --- Documentation/usage/dlv.md | 2 +- Documentation/usage/dlv_dap.md | 6 +++--- cmd/dlv/cmds/commands.go | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Documentation/usage/dlv.md b/Documentation/usage/dlv.md index fdd3ca33..999ef679 100644 --- a/Documentation/usage/dlv.md +++ b/Documentation/usage/dlv.md @@ -41,7 +41,7 @@ Pass flags to the program you are debugging using `--`, for example: * [dlv attach](dlv_attach.md) - Attach to running process and begin debugging. * [dlv connect](dlv_connect.md) - Connect to a headless debug server. * [dlv core](dlv_core.md) - Examine a core dump. -* [dlv dap](dlv_dap.md) - [EXPERIMENTAL] Starts a TCP server communicating via Debug Adaptor Protocol (DAP). +* [dlv dap](dlv_dap.md) - [EXPERIMENTAL] Starts a headless TCP server communicating via Debug Adaptor Protocol (DAP). * [dlv debug](dlv_debug.md) - Compile and begin debugging main package in current directory, or the package specified. * [dlv exec](dlv_exec.md) - Execute a precompiled binary, and begin a debug session. * [dlv replay](dlv_replay.md) - Replays a rr trace. diff --git a/Documentation/usage/dlv_dap.md b/Documentation/usage/dlv_dap.md index 3a87a251..8fc171f3 100644 --- a/Documentation/usage/dlv_dap.md +++ b/Documentation/usage/dlv_dap.md @@ -1,13 +1,13 @@ ## dlv dap -[EXPERIMENTAL] Starts a TCP server communicating via Debug Adaptor Protocol (DAP). +[EXPERIMENTAL] Starts a headless TCP server communicating via Debug Adaptor Protocol (DAP). ### Synopsis -[EXPERIMENTAL] Starts a TCP server communicating via Debug Adaptor Protocol (DAP). +[EXPERIMENTAL] Starts a headless TCP server communicating via Debug Adaptor Protocol (DAP). -The server is headless and requires a DAP client like vscode to connect and request a binary +The server is always headless and requires a DAP client like vscode to connect and request a binary to be launched or process to be attached to. The following modes are supported: - launch + exec (executes precompiled binary, like 'dlv exec') - launch + debug (builds and launches, like 'dlv debug') diff --git a/cmd/dlv/cmds/commands.go b/cmd/dlv/cmds/commands.go index e063c728..2f8ec18d 100644 --- a/cmd/dlv/cmds/commands.go +++ b/cmd/dlv/cmds/commands.go @@ -174,10 +174,10 @@ option to let the process continue or kill it. // 'dap' subcommand. dapCommand := &cobra.Command{ Use: "dap", - Short: "[EXPERIMENTAL] Starts a TCP server communicating via Debug Adaptor Protocol (DAP).", - Long: `[EXPERIMENTAL] Starts a TCP server communicating via Debug Adaptor Protocol (DAP). + Short: "[EXPERIMENTAL] Starts a headless TCP server communicating via Debug Adaptor Protocol (DAP).", + Long: `[EXPERIMENTAL] Starts a headless TCP server communicating via Debug Adaptor Protocol (DAP). -The server is headless and requires a DAP client like vscode to connect and request a binary +The server is always headless and requires a DAP client like vscode to connect and request a binary to be launched or process to be attached to. The following modes are supported: - launch + exec (executes precompiled binary, like 'dlv exec') - launch + debug (builds and launches, like 'dlv debug') @@ -188,6 +188,7 @@ While --continue is not supported, stopOnEntry launch/attach attribute can be us execution is resumed at the start of the debug session.`, Run: dapCmd, } + // TODO(polina): support --tty when dlv dap allows to launch a program from command-line rootCommand.AddCommand(dapCommand) // 'debug' subcommand. @@ -409,7 +410,7 @@ func dapCmd(cmd *cobra.Command, args []string) { } defer logflags.Close() - if headless { + if cmd.Flag("headless").Changed { fmt.Fprintf(os.Stderr, "Warning: dap mode is always headless\n") } if acceptMulti { @@ -446,10 +447,9 @@ func dapCmd(cmd *cobra.Command, args []string) { DisconnectChan: disconnectChan, Debugger: debugger.Config{ Backend: backend, - Foreground: headless && tty == "", + Foreground: true, // server always runs without terminal client DebugInfoDirectories: conf.DebugInfoDirectories, CheckGoVersion: checkGoVersion, - TTY: tty, }, CheckLocalConnUser: checkLocalConnUser, })