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

Attach mode hang forever when cwd is empty #1608

Closed
icexin opened this issue Jul 5, 2021 · 3 comments
Closed

Attach mode hang forever when cwd is empty #1608

icexin opened this issue Jul 5, 2021 · 3 comments
Labels
debug/legacy legacy debug adapter related issues - new issues won't be fixed Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Milestone

Comments

@icexin
Copy link

icexin commented Jul 5, 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.13.8 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
----------
golang.org/x/tools/gopls v0.7.0
    golang.org/x/tools/gopls@v0.7.0 h1:JQBHW81Gsyim6iDjUwGoPeSpXrSqwen3isPJLfDf=
    github.com/google/go-cmp@v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlr=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+e=
    golang.org/x/mod@v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
    golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bw=
    golang.org/x/sys@v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S=
    golang.org/x/tools@v0.1.3-0.20210608163600-9ed039809d4c h1:Pv9gNyJFYVdpUAVZ=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8c=
    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.57.1
    507ce72a4466fbb27b715c3722558bb15afa9f48
    x64
    
  • Check your installed extensions to get the version of the VS Code Go extension

    • 0.26.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

Checking configured tools....
GOBIN: undefined
toolsGopath: 
gopath: /Users/fanbingxin/go
GOROOT: /Users/fanbingxin/local/go
PATH: /Users/fanbingxin/bin:/Users/fanbingxin/go/bin:/Users/fanbingxin/local/go/bin:/Users/fanbingxin/local/maven/bin:/Users/fanbingxin/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/go/bin:/Applications/Wireshark.app/Contents/MacOS

   gopkgs: /Users/fanbingxin/go/bin/gopkgs installed
   go-outline: /Users/fanbingxin/go/bin/go-outline installed
   gotests: gotests not installed
   gomodifytags: gomodifytags not installed
   impl: /Users/fanbingxin/go/bin/impl installed
   goplay: goplay not installed
   dlv: /Users/fanbingxin/go/bin/dlv installed
   dlv-dap: dlv-dap not installed
   staticcheck: staticcheck not installed
   gopls: /Users/fanbingxin/go/bin/gopls installed

go env
Workspace Folder (eggos): /Users/fanbingxin/go/src/github.com/icexin/eggos
	GO111MODULE="on"
	GOARCH="386"
	GOBIN=""
	GOCACHE="/Users/fanbingxin/Library/Caches/go-build"
	GOENV="/Users/fanbingxin/Library/Application Support/go/env"
	GOEXE=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="darwin"
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="linux"
	GOPATH="/Users/fanbingxin/go"
	GOPRIVATE=""
	GOPROXY="https://goproxy.cn"
	GOROOT="/Users/fanbingxin/local/go"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/Users/fanbingxin/local/go/pkg/tool/darwin_amd64"
	GCCGO="gccgo"
	GO386="sse2"
	AR="ar"
	CC="clang"
	CXX="clang++"
	CGO_ENABLED="0"
	GOMOD="/Users/fanbingxin/go/src/github.com/icexin/eggos/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 -m32 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f8/0879kt7j4791j6lrfz2ydb4h0000gp/T/go-build350734622=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

{
    "go.toolsEnvVars": {
        "GOOS": "linux",
        "GOARCH": "386",
    },
}

Describe the bug

In debug mode, if I select the request field as attach and the cwd field is empty, vscode will not respond after clicking the debug button.

Steps to reproduce the behavior:

configuration of debug:

 {
            "name": "dlv-gdb",
            "type": "go",
            "request": "attach",
            "mode": "local",
            //"cwd": "${workspaceFolder}",
            "debugAdapter": "legacy",
            "processId": 1234,
            "backend": "lldb",
            "dlvFlags": [
                "${workspaceRoot}/kernel.elf",
            ],
            "trace": "log",
        },
@gopherbot gopherbot added this to the Untriaged milestone Jul 5, 2021
@icexin
Copy link
Author

icexin commented Jul 5, 2021

I debugged it and found it stopped on dirname, because program is empty.

let dlvCwd = path.dirname(program);

@findleyr findleyr added the Debug Issues related to the debugging functionality of the extension. label Jul 7, 2021
@hyangah
Copy link
Contributor

hyangah commented Jul 9, 2021

Thanks for the report @icexin

@suzmue It looks like we should've set 'cwd' even for the 'local' attach mode for legacy mode.

if (
debugAdapter !== 'dlv-dap' &&
debugConfiguration.request === 'attach' &&
debugConfiguration.mode === 'remote' &&
!debugConfiguration['cwd']
) {
debugConfiguration['cwd'] = '${workspaceFolder}';
if (vscode.workspace.workspaceFolders?.length > 1) {
debugConfiguration['cwd'] = '${fileWorkspaceFolder}';
}
}
if (debugConfiguration['cwd']) {
// expand 'cwd' folder path containing '~', which would cause dlv to fail
debugConfiguration['cwd'] = resolveHomeDir(debugConfiguration['cwd']);
}

And, I think even for the dlv-dap mode, we can set this - currently we launch dlv dap from

let dir = getWorkspaceFolderPath();
.

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/334111 mentions this issue: src/goDebugConfiguration: always set cwd in attach mode & legacy adapter

@polinasok polinasok added the debug/legacy legacy debug adapter related issues - new issues won't be fixed label Jul 15, 2021
@hyangah hyangah modified the milestones: Untriaged, v0.27.0 Aug 3, 2021
@golang golang locked and limited conversation to collaborators Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug/legacy legacy debug adapter related issues - new issues won't be fixed Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

5 participants