vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

Go Debugging using dlv breaks at runtime.gopark instead of proper breakpoint place

Open kmmkwong opened this issue 8 months ago • 15 comments

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

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.23.4 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • Build info

golang.org/x/tools/gopls v0.18.1 golang.org/x/tools/[email protected] h1:2xJBNzdImS5u/kV/ZzqDLSvlBSeZX+pWY9uKVP7Pask= github.com/BurntSushi/[email protected] h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= golang.org/x/exp/[email protected] h1:1xaZTydL5Gsg78QharTwKfA9FY9CZ1VQj6D/AZEvHR0= golang.org/x/[email protected] h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= golang.org/x/[email protected] h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= golang.org/x/[email protected] h1:L2k9GUV2TpQKVRGMjN94qfUMgUwOFimSQ6gipyJIjKw= golang.org/x/[email protected] h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= golang.org/x/[email protected] h1:Ja/5gV5a9Vvho3p2NC/T2TtxhHjrWS/2DvCKMvA0a+Y= golang.org/x/[email protected] h1:NPGnvPOTgnjBc9HTaUx+nj+EaUYxl5SJOWqaDYGaFYw= honnef.co/go/[email protected] h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I= mvdan.cc/[email protected] h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU= mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8= go: go1.23.4

  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • VSCode Version: 1.96.2
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.46.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • Tools Configuration

Environment

GOBIN: undefined toolsGopath: gopath: /Users/mary.wong/go/1.23.4 GOROOT: /Users/mary.wong/.goenv/versions/1.23.4 PATH: /Users/mary.wong/.goenv/versions/1.23.4/bin:/Users/mary.wong/.pyenv/shims:/Users/mary.wong/.goenv/bin:/Users/mary.wong/Library/Python/3.9/bin:/usr/local/bin:/usr/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/mary.wong/.local/bin:/Users/mary.wong/.goenv/shims:/Users/mary.wong/go/1.23.4/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/mary.wong/.local/bin:/Users/mary.wong/src/tua-buf/node_modules/.bin PATH (vscode launched with): /Users/mary.wong/.pyenv/shims:/Users/mary.wong/.goenv/versions/1.23.4/bin:/Users/mary.wong/.goenv/bin:/Users/mary.wong/Library/Python/3.9/bin:/usr/local/bin:/usr/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/mary.wong/.local/bin:/Users/mary.wong/.goenv/shims:/Users/mary.wong/go/1.23.4/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/mary.wong/.local/bin:/Users/mary.wong/src/tua-buf/node_modules/.bin

Tools

go:	/Users/mary.wong/.goenv/versions/1.23.4/bin/go: go version go1.23.4 darwin/arm64

gopls:	/Users/mary.wong/go/1.23.4/bin/gopls	(version: v0.18.1 built with go: go1.23.4)
gotests:	not installed
gomodifytags:	not installed
impl:	not installed
goplay:	not installed
dlv:	/Users/mary.wong/go/1.23.4/bin/dlv	(version: v1.24.1 built with go: go1.23.4)
staticcheck:	/Users/mary.wong/go/1.23.4/bin/staticcheck	(version: v0.6.0 built with go: go1.23.4)

Go env

Workspace Folder (tua-dqa-service): /Users/mary.wong/src/tua-dqa-service

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/mary.wong/Library/Caches/go-build'
GOENV='/Users/mary.wong/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mary.wong/go/1.23.4/pkg/mod'
GONOPROXY='git.soma.salesforce.com'
GONOSUMDB='git.soma.salesforce.com'
GOOS='darwin'
GOPATH='/Users/mary.wong/go/1.23.4'
GOPRIVATE='git.soma.salesforce.com'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/mary.wong/.goenv/versions/1.23.4'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/mary.wong/.goenv/versions/1.23.4/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/mary.wong/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/mary.wong/src/tua-dqa-service/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/14/x057mqns7qvb_j0v_9k26td40000gn/T/go-build3853166858=/tmp/go-build -gno-record-gcc-switches -fno-common'

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.

{ "go.buildFlags": ["-gcflags=all=-N -l"] }

Describe the bug

Go debugger is not able to break at the right place. Instead it keeps breaking on runtime.gopark, and there is no useful info. I tried disabling the go optimization in various ways including updating the settings.json file but no success. Debugger is completely unusable.

Note that it was working before, but at some time, it just stopped working. But I am not sure what has changed to trigger it.

Steps to reproduce the behavior:

Create a launch.json as usual and try to debug:

    // 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": "grpc",
        "type": "go",
        "request": "launch",
        "mode": "auto",
        "program": "cmd/...go",
        "cwd": "${workspaceFolder}",
        // "buildFlags": "-gcflags=all=-N -l",
        // "buildFlags": "-gcflags \"-N -l\"",
        "env": { ...

Screenshots or recordings

Image

kmmkwong avatar Apr 04 '25 22:04 kmmkwong