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

debug: expose --only-same-user in debug configuration #810

Closed
snigle opened this issue Oct 19, 2020 · 6 comments
Closed

debug: expose --only-same-user in debug configuration #810

snigle opened this issue Oct 19, 2020 · 6 comments
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@snigle
Copy link

snigle commented Oct 19, 2020

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • go version go1.15 linux/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • 1.49.1 58bb7b2331731bf72587010e943852e13e6fd3cf x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.17.2
  • Run go env to get the go development environment details
    • not needed ?

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

launch.json

{
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}",
            "env": {},
            "args": [ ],
            "showLog": true,
            "logOutput":"rpc,debugger",
            "trace": "verbose"
        },

Describe the bug

Hello, we used to start vscode with remote ssh plugin in a docker container.
But we don't have access to cat /proc/self/net/tcp.
So delve crash and extension don't display error message.

To avoid the error we need to pass the parameter only-same-user to false. But I didn't find any way to pass this param in the go extension.
I found a workaround by patching delve code directly to force the default value to false :

diff --git a/cmd/dlv/cmds/commands.go b/cmd/dlv/cmds/commands.go
index e28a0a16..ea08d462 100644
--- a/cmd/dlv/cmds/commands.go
+++ b/cmd/dlv/cmds/commands.go
@@ -127,7 +127,7 @@ func New(docCall bool) *cobra.Command {
        rootCommand.PersistentFlags().StringVar(&buildFlags, "build-flags", buildFlagsDefault, "Build flags, to be passed to the compiler.")
        rootCommand.PersistentFlags().StringVar(&workingDir, "wd", "", "Working directory for running the program.")
        rootCommand.PersistentFlags().BoolVarP(&checkGoVersion, "check-go-version", "", true, "Checks that the version of Go in use is compatible with Delve.")
-       rootCommand.PersistentFlags().BoolVarP(&checkLocalConnUser, "only-same-user", "", true, "Only connections from the same user that started this instance of Delve are allowed to connect.")
+       rootCommand.PersistentFlags().BoolVarP(&checkLocalConnUser, "only-same-user", "", false, "Only connections from the same user that started this instance of Delve are allowed to connect.")

Steps to reproduce the behavior:

Create docker container
Open vscode in remote ssh on the container
cat /proc/self/net/tcp should return forbidden
Try to debug a simple test

@polinasok
Copy link
Contributor

polinasok commented Oct 20, 2020

Do I understand correctly that delve gets started by vscode in your setup? What configuration do you use in your launch.json? In general, it always helps if your bug report includes the details of your configuration as well as detailed logs that you can obtain by adding the following to launch.json:

            "showLog": true,
            "logOutput":"rpc,debugger",
            "trace": "verbose",

Have you tried starting an instance of headless delve (dlv --headless --listen=12345) separately with whatever flags you need and then use a debug configuration in vscode that would connect to this delve server ("request": "attach", "mode": "remote", "port": 12345)?

@polinasok polinasok added Debug Issues related to the debugging functionality of the extension. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Oct 20, 2020
@snigle
Copy link
Author

snigle commented Oct 20, 2020

Hi thanks for reply, I added the launch.json in my first post.
I only have this output in my debug view : API server listening at: 127.0.0.1:34914

I will try by running my own instance of delve

@polinasok
Copy link
Contributor

polinasok commented Oct 20, 2020

The "API server" string is an indiciation that delve server was started successfully for you. With logging enabled, you should have more noise under DEBUG CONSOLE thought. (If you start delve separately then instead of showLog and logOutput add --log' and --log-output` to the dlv command).

If no error message is displayed when delve crashes, how do you know that it crashed?

@polinasok polinasok changed the title delve issue in docker container debug: delve issue in docker container Nov 30, 2020
@polinasok
Copy link
Contributor

polinasok commented Nov 30, 2020

@snigle
--only-same-user is a fairly recent addition to dlv (go-delve/delve#1835) and vscode-go doesn't have a matching flag for it to set in launch.json. If there isn't a deeper underlying issue here (such as an obscure dlv crash that is not properly reported) and using this flag is sufficient for you, then please do use the workaround of starting your own headless instance of dlv on the command-line with the needed flags and then using launch.json to connect to it.

I am going to change the title of this bug to add the same-user flag to our build configuration.

@polinasok polinasok changed the title debug: delve issue in docker container debug: expose --only-same-user in debug configuration Nov 30, 2020
@polinasok polinasok added NeedsFix The path to resolution is known, but the work has not been done. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Nov 30, 2020
@hyangah
Copy link
Contributor

hyangah commented Dec 1, 2020

Another option is to shell out dlv as dlv --only-same-user and set "go.alternateTools": { "dlv": <path to the shell> }.
But yes, it's less desirable than native support from the extension.

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/280697 mentions this issue: src/debugAdapter: add dlvFlags to accept arbitrary delve flags

@hyangah hyangah added this to the v0.21.0 milestone Jan 14, 2021
@golang golang locked and limited conversation to collaborators Jan 14, 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 NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants