Reputation: 11
I want to use VSCode with WSL for development. I have problems debugging my Go applications and I don't know why. I dont see the things in the call stack, no variables and also the buttons to jumping from breakpoint to breakpoint are greyed out. My DEBUG Console log is clean, no erros (see details below) I try to follow these articles to set up my environment:
https://github.com/Microsoft/vscode-go/wiki/GOPATH-in-the-VS-Code-Go-extension https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code
So what I do in detail:
First I tell VSCode to set my GOPATH dynamacly from the current Workspace and also seperate the GooTools Installation from my GOPATH via go.toolsGopath. My settings.json looks like this:
{
"go.inferGopath": true,
"go.toolsGopath": "/mnt/c/Users/cloudnaut/gospace/gotools",
}
So my GoTools are installed to /mnt/c/Users/cloudnaut/gospace/gotools. I have installed also the dlv debugger. Also My working directory for go is instead /mnt/c/Users/cloudnaut/gospace/go
It haves the common go project structure:
.
├── bin
├── pkg
└── src
└── github.com
└── cloudnaut
└── project1
└── main.go
Everything seems fine. Go:Install/Update Tools
are installed in my separate path. And my GOPATH structure also works. I use GO:Current GOPATH
it shows my the correct GOPATH i want and go install
also creates the go binary from my main.go in /bin. Perfect ...
Now I want to start to debbuging. I just use a simple launch.json file directly point to my main.go
{
// 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",
"showLog": true,
"type": "go",
"request": "launch",
"mode": "auto",
"program": "/mnt/c/Users/cloudnaut/gospace/go/src/github.com/cloudnaut/project1/main.go",
"env": {},
"args": []
}
]
}
So and when I start now the debugging (breakpoints are set and shown under BREAKPOINTS) he creates in the folder a __debug_bin
. But in my vscode debuger interface, I see no variables and stacktrace. The Problem is, I see also now errors or something. My Debug Console with the showLog: true
option is nearly clean. It only contains the following lines:
API server listening at: 127.0.0.1:34477
2019-12-19T13:55:52+01:00 info layer=debugger launching process with args: [/mnt/c/Users/cloudnaut/gospace/go/src/github.com/cloudnaut/project1/__debug_bin]
Nothing else. The "step over/step info/Step out" buttons from the debugger are greyed out. I only can press pause, restart and stop.
See:
Picture VS Code Debugger Problem
Upvotes: 0
Views: 5816
Reputation: 11
I bring the solution for my own question:
The problem is that the Go dlv debugger dont works with WSL 1 because of some unsupported system calls. It only works with WSL 2, wich is included only in the Microsoft insider build.
See: https://github.com/microsoft/vscode-go/issues/2505
Upvotes: 1