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: the variables was lost #1450

Closed
Aisuko opened this issue Apr 23, 2021 · 10 comments
Closed

debug: the variables was lost #1450

Aisuko opened this issue Apr 23, 2021 · 10 comments
Assignees
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Milestone

Comments

@Aisuko
Copy link

Aisuko commented Apr 23, 2021

For asking questions, see:

Before filing an issue, please review our troubleshooting guides

Please answer these questions before submitting your issue. Thanks!

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

  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.16 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
➜  postgres-operator git:(master) ✗ /home/aisuko/go/bin/gopls -v version 
Build info
----------
golang.org/x/tools/gopls v0.6.10
    golang.org/x/tools/gopls@v0.6.10 h1:8Ebz8PymS2umcuCFhoz67unyJfWsipjTIrkBUF9kypg=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY=
    golang.org/x/sync@v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
    golang.org/x/sys@v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
    golang.org/x/tools@v0.1.1-0.20210408155258-593413344da1 h1:B+9Jhwu5uM+kDMAkoQH6IUoIoS48VbRqwLyceNdpRK8=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.1.3 h1:qTakTkI6ni6LFD5sBwwsdSO+AQqbSIxOauHTTQKZ/7o=
    mvdan.cc/gofumpt@v0.1.1 h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
1.55.2
3c4e3df9e89829dce27b7b5c24508306b151f30d
x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.24.2
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
Checking configured tools....
GOBIN: undefined
toolsGopath: 
gopath: /home/aisuko/go
GOROOT: /usr/local/go
PATH: /home/aisuko/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/bin:/home/aisuko/.rbenv/shims:/home/aisuko/.rbenv/bin:/home/aisuko/gems/bin:/home/aisuko/bin:/usr/local/bin:/usr/local/go/bin:/home/aisuko/.vscode-server/bin/3c4e3df9e89829dce27b7b5c24508306b151f30d/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/share/rvm/bin

   gopkgs: /home/aisuko/go/bin/gopkgs installed
   go-outline: /home/aisuko/go/bin/go-outline installed
   gotests: /home/aisuko/go/bin/gotests installed
   gomodifytags: /home/aisuko/go/bin/gomodifytags installed
   impl: /home/aisuko/go/bin/impl installed
   goplay: /home/aisuko/go/bin/goplay installed
   dlv: /home/aisuko/go/bin/dlv installed
   dlv-dap: /home/aisuko/go/bin/dlv-dap installed
   staticcheck: /home/aisuko/go/bin/staticcheck installed
   gopls: /home/aisuko/go/bin/gopls installed

go env
Workspace Folder (postgres-operator): /home/aisuko/Documents/postgres-operator
	GO111MODULE="on"
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/home/aisuko/.cache/go-build"
	GOENV="/home/aisuko/.config/go/env"
	GOEXE=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="linux"
	GOINSECURE=""
	GOMODCACHE="/home/aisuko/go/pkg/mod"
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="linux"
	GOPATH="/home/aisuko/go"
	GOPRIVATE=""
	GOPROXY="https://goproxy.cn,direct"
	GOROOT="/usr/local/go"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
	GOVCS=""
	GOVERSION="go1.16"
	GCCGO="gccgo"
	AR="ar"
	CC="gcc"
	CXX="g++"
	CGO_ENABLED="1"
	GOMOD="/home/aisuko/Documents/postgres-operator/go.mod"
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1833826342=/tmp/go-build -gno-record-gcc-switches"

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.

Describe the bug

A clear and concise description of what the bug.

The value of variable which named AdditionalSuperuserTeams, AdditionalTeams and AdditionalMembers was lost.

Screen Shot 2021-04-22 at 11 50 03 AM

A clear and concise description of what you expected to happen.

The expectation of the stack like below

Screenshot from 2021-04-22 11-51-54

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. See error

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

@gopherbot gopherbot added this to the Untriaged milestone Apr 23, 2021
@findleyr findleyr added the Debug Issues related to the debugging functionality of the extension. label Apr 23, 2021
@findleyr findleyr changed the title [debug]: the variables was lost debug: the variables was lost Apr 23, 2021
@hyangah
Copy link
Contributor

hyangah commented Apr 23, 2021

@Aisuko Can you try a new debug adapter if it handles variables better? Based on my experience, the new adapter handles nested, complex data structure better, but it's still experimental.

@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 23, 2021
@Aisuko
Copy link
Author

Aisuko commented Apr 24, 2021

Thanks for quickly reply, hard to say the new debug adapter is working well for this situation,the same breakpoint location
Screen Shot 2021-04-24 at 2 46 18 PM

@polinasok
Copy link
Contributor

Thank you for giving dlv-dap a try!

Delve debugger has limited evaluation depth for nested variables. You would see the same limitation if you use the command-line dlv client. In the legacy adapter, this looks like a level where you no longer able to expand the variables further, even though you know the variable is nested. In the new adapter, we are planning to add requests for additional loading behind the scenes in response to user clicks to expand the parent variable (this is already working for interfaces, but not for other types yet). In the meantime, we labeled such unloaded cases with labels like "loaded 0/3", which means that 0 out of 3 children were loaded by default. At this point the workaround would be to right click on the variable and either use "Add to watch" to add these variables to the WATCH panel or "Copy Expression" to get an expression that you can type into the DEBUG CONSOLE. And please stay tune for new features which are coming shortly.

@polinasok
Copy link
Contributor

Before:
image
With the most recent change:
image

@Aisuko Could you please update dlv-dap to the very latest top-of-the tree version and give this a try with your original use case? Thank you.

@Aisuko
Copy link
Author

Aisuko commented May 5, 2021

Before:
image
With the most recent change:
image

@Aisuko Could you please update dlv-dap to the very latest top-of-the tree version and give this a try with your original use case? Thank you.

Thanks, will do and feedback.

@Aisuko
Copy link
Author

Aisuko commented May 5, 2021

The version below looks like work for me(on my remote Ubuntu server), thanks for your guys patient

➜  postgres-operator git:(feat/manifest) /home/aisuko/go/bin/dlv-dap version
Delve Debugger
Version: 1.6.0
Build: $Id: 8cc9751909843dd55a46e8ea2a561544f70db34d $

Screen Shot 2021-05-05 at 12 21 16 PM

But I have another question(maybe a new feature request or a bug), please look at the picture below, I believe that go: Debug Test At Cursor start running debug service without using my configuration.

So, is there any way can reload configuration to this feature?

My configurations:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        // {
        //     "name": "Launch file",
        //     "type": "go",
        //     "request": "launch",
        //     "mode": "debug",
        //     "program": "${workspaceFolder}/pkg/teams/postgres_team_test.go",
        //     "debugAdapter": "dlv-dap",
        //     "showLog": true
        // },
        {
            "name": "Test",
            "type": "go",
            "request": "launch",
            "mode": "test",
            "program": "${workspaceFolder}/pkg/teams",
            "debugAdapter": "dlv-dap",
            "showLog": true,
            "logOutput": "dap",
            "trace": "verbose"
        }
    ]
}

Screen Shot 2021-05-05 at 12 40 52 PM

Debug: Select and Start Debugging works well but the scope of the test file. I'd like to just run the specific functions in the test file.

Screen Shot 2021-05-05 at 12 32 59 PM

@polinasok
Copy link
Contributor

Closing this since the main fix has been verified. Thank you.

To answer your unrelated question, if I remember correctly, "Go: Debug Test at Cursor" command is equivalent to using "debug test" codelens (link above your test function). There is a known limitation that launch.json configuration would not be used in this case. And that's also why dlv-dap (enabled by a launch.json flag) is currently not usable with "debug test" as well. Please see #855.

Enable Delve DAP automation moved this from In Progress to Closed May 5, 2021
@polinasok polinasok added FixedInDlvDapOnly and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels May 5, 2021
@Aisuko
Copy link
Author

Aisuko commented May 5, 2021

@polinasok Thanks

@hyangah
Copy link
Contributor

hyangah commented May 5, 2021

@Aisuko you can configure the dlv-dap to be the default debug adapter, which works for "debug test" codelens and "Go: Debug Test At Cursor" by using go.delveConfig setting.

Reference: https://github.com/golang/vscode-go/blob/master/docs/dlv-dap.md#getting-started

@Aisuko
Copy link
Author

Aisuko commented May 6, 2021

@hyangah thanks

@golang golang locked and limited conversation to collaborators May 6, 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
No open projects
Development

No branches or pull requests

5 participants