golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.84k stars 735 forks source link

debugging does not work on darwin #3086

Closed tuningMaster closed 8 months ago

tuningMaster commented 9 months ago

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

Version Information
* Run `go version` - go version go1.21.5 darwin/amd64 * Run `gopls -v version` - Build info ---------- golang.org/x/tools/gopls v0.14.2 golang.org/x/tools/gopls@v0.14.2 h1:sIw6vjZiuQ9S7s0auUUkHlWgsCkKZFWDHmrge8LYsnc= github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y= golang.org/x/mod@v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/sync@v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= golang.org/x/sys@v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/telemetry@v0.0.0-20231114163143-69313e640400 h1:brbkEFfGwNGAEkykUOcryE/JiHUMMJouzE0fWWmz/QU= golang.org/x/text@v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/tools@v0.14.1-0.20231114185516-c9d3e7de13fd h1:Oku7E+OCrXHyst1dG1z10etCTxewCHXNFLRlyMPbh3w= golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU= honnef.co/go/tools@v0.4.5 h1:YGD4H+SuIOOqsyoLOpZDWcieM28W47/zRO7f+9V3nvo= mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc= go: go1.21.5 * Run `code -v` or `code-insiders -v` . - Version: 1.85.0 (Universal) Commit: af28b32d7e553898b2a91af498b1fb666fdebe0c Date: 2023-12-06T18:18:04.614Z Electron: 25.9.7 ElectronBuildId: 25551756 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin x64 23.1.0 * Check your installed extensions to get the version of the VS Code Go extension - v0.40.0 `func TestTemplate1(t *testing.T) { var me string = "hello world" fmt.Println(me) }` when debug this test demo, but it does not work. like this: ![image](https://github.com/golang/vscode-go/assets/153407390/3a67161e-5bfb-4db1-ac27-222ec32ed728) how can I resolve this?
hyangah commented 9 months ago

Thanks for the report. @tuningMaster

We need more details for triaging, but I suspect if this is another case of https://github.com/golang/vscode-go/issues/3081 caused by a xcode command line tool bug. Can you try to run this and see if it helps?

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Otherwise, please capture detailed logs (from Debug Console) after setting this in settings.json

    "go.delveConfig": {
        "showLog": true,
        "logOutput": "dap,gdbwire"
    },
tuningMaster commented 8 months ago

Thanks for the report. @tuningMaster

We need more details for triaging, but I suspect if this is another case of #3081 caused by a xcode command line tool bug. Can you try to run this and see if it helps?

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Otherwise, please capture detailed logs (from Debug Console) after setting this in settings.json

    "go.delveConfig": {
        "showLog": true,
        "logOutput": "dap,gdbwire"
    },
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

I tried this method and it works well now. What is the specific reason for this?

hyangah commented 8 months ago

Good to hear that reinstalling xcode cli tool fixed it. From https://github.com/go-delve/delve/issues/3519, https://github.com/go-delve/delve/issues/3538, and https://youtrack.jetbrains.com/issue/GO-15541 it was caused by messed up xcode cli tool installation. It was often reported from users after os upgrade, or other xcode-related changes. The go debugger delve relies on xcode cli tools on mac.

tuningMaster commented 8 months ago

Good to hear that reinstalling xcode cli tool fixed it. From go-delve/delve#3519, go-delve/delve#3538, and https://youtrack.jetbrains.com/issue/GO-15541 it was caused by messed up xcode cli tool installation. It was often reported from users after os upgrade, or other xcode-related changes. The go debugger delve relies on xcode cli tools on mac.

get, thanks a lot ~