Skip to content
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

Reading user input loops the program without debugging capability #1718

Closed
aleksandr-shevchenko opened this issue Aug 25, 2021 · 2 comments
Closed
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Milestone

Comments

@aleksandr-shevchenko
Copy link

aleksandr-shevchenko commented Aug 25, 2021

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
    reader := bufio.NewScanner(os.Stdin)

    for reader.Scan() {
        s := reader.Text()
        if s == "" {
            break
        }
        fmt.Println(s)
    }
}

debug console:
Starting: d:\Go\bin\dlv-dap.exe dap --listen=127.0.0.1:59530
DAP server listening at: 127.0.0.1:59530
123
Unable to process evaluate: debuggee is running
eee
Unable to process evaluate: debuggee is running
-- I press Enter only --
Unable to process evaluate: debuggee is running
-- stop execute by Shift-F5 --
Detaching and terminating target process
dlv dap (1060) exited with code: 0

Stop program only by Shift-F5.
Debug not working.

Golang, VSCode and go plugin latest version.
OS Win10 Pro

@gopherbot gopherbot added this to the Untriaged milestone Aug 25, 2021
@polinasok
Copy link
Contributor

polinasok commented Aug 25, 2021

Debug Console is not designed for entering stdin. It's not a terminal, where your process is foregrounded and can read stdin. It's a REPL environment for evaluating expressions, which is only possible when the target is not running (otherwise you get an error message).

Here is what you can do instead:

  1. Run dlv server in a separate server terminal, where it will foreground your process, so you can enter stdin into that terminal.
$ dlv-dap dap --listen=:54321
DAP server listening at: [::]:54321
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1205.0.27
 for x86_64.
Got a connection, launched process /Users/polina/delve/__debug_bin (pid = 8737).
123
read from stdin: 123

Exiting.
  1. Use launch.json configuration to connect to this server. Essentially this means taking any existing launch configuration that already works for you and adding debugServer to it to tell it use an external server instead of launching one for you inside of vscode extension. For example,
{
            "name": "Launch file via external dlv-dap",
            "type": "go",
            "request": "launch",
            "mode":"debug",
            "program": "${file}",
            "debugServer":54321, 
}

We know this is not ideal. Please see this issue for what else we are exploring in the long term: #124 (comment).

@polinasok polinasok added the Debug Issues related to the debugging functionality of the extension. label Aug 25, 2021
@aleksandr-shevchenko
Copy link
Author

Thanks!

@golang golang locked and limited conversation to collaborators Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

3 participants