I am struggling to get this damn delve debugger to run.
It used to work well with older versions of go and dlv and probably vscode (but the same backend to debug).
I want to simply run that dlv debugger together with dap server. Hitting F5 used to do it. It was working with the default "launch package" configuration in vscode, with no extra args of anything.
Here is a copy of the debug console output, upon hitting F5 :
Starting: /home/linuxbrew/.linuxbrew/Cellar/go/1.21.6/bin/dlv dap --listen=127.0.0.1:45303 --log-dest=3 from /home/myuser/Documents/myapp DAP server listening at: 127.0.0.1:45303 Type 'dlv help' for list of commands. Process 112737 has exited with status 1 Detaching
It seems to start the dev server, but then exits right away.
I don't know what's missing. It could be that dlv is now configured to operate differently.
Any help would be appreciated, as this type of tooling issues is frustrating.
Not sure if that is helpful, but this is the output of the debug console, when I add "logOutput": "dap", "showLog": true
to launch.json
:
2024-02-12T10:50:05+11:00 debug layer=dap building from "/home/myuser/Documents/myapp": [go build -o /home/myuser/Documents/myapp/__debug_bin -gcflags all=-N -l .]
2024-02-12T10:50:05+11:00 debug layer=dap launching binary '/home/myuser/Documents/myapp/__debug_bin' with config: {
"mode": "debug",
"program": "/home/myuser/Documents/myapp",
"args": [
"dap"
],
"cwd": "/home/myuser/Documents/myapp",
"output": "/home/myuser/Documents/myapp/__debug_bin",
"dlvCwd": "/home/myuser/Documents/myapp",
"env": {
"GOBIN": "/home/linuxbrew/.linuxbrew/Cellar/[email protected]/1.20.14/bin",
"GOPATH": "/home/linuxbrew/.linuxbrew/Cellar/[email protected]"
},
"backend": "default",
"stackTraceDepth": 50
}
There are a few things here that I don't get. It has to do with how versions of go are managed here. The above tells me [email protected]. However, if I type go version
in the terminal, it tells me I'm on go1.22.0 (which is the latest). I installed gvm, as I thought it would help fix all the error messages I previously had with versions of go and dlv. The console seems to show the go version applied by gvm.
The following : /home/linuxbrew/.linuxbrew/bin/go version
tells me I'm on go1.21.7
What follows are additional outputs of the debug console when hitting F5. They may or may not be useful.
2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"initialized"} 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":2,"success":true,"command":"launch"} 2024-02-12T10:50:05+11:00 debug layer=dap [<- from client]{"seq":3,"type":"request","command":"setFunctionBreakpoints","arguments":{"breakpoints":[]}} 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":3,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}} 2024-02-12T10:50:05+11:00 debug layer=dap [<- from client]{"seq":4,"type":"request","command":"setInstructionBreakpoints","arguments":{"breakpoints":[]}} 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":4,"success":true,"command":"setInstructionBreakpoints","body":{"breakpoints":[]}} 2024-02-12T10:50:05+11:00 debug layer=dap [<- from client]{"seq":5,"type":"request","command":"configurationDone","arguments":{}} 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Type 'dlv help' for list of commands.\n","source":{}}} 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":5,"success":true,"command":"configurationDone"} Type 'dlv help' for list of commands. 2024-02-12T10:50:05+11:00 debug layer=dap [<- from client]{"seq":6,"type":"request","command":"threads"} 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":6,"success":true,"command":"threads","body":{"threads":[{"id":-1,"name":"Current"}]}} 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"terminated","body":{}} 2024-02-12T10:50:05+11:00 debug layer=dap [<- from client]{"seq":7,"type":"request","command":"disconnect","arguments":{}} 2024-02-12T10:50:05+11:00 debug layer=dap halting 2024-02-12T10:50:05+11:00 debug layer=dap process not running 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Process 116383 has exited with status 1\n","source":{}}} 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Detaching\n","source":{}}} 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":7,"success":true,"command":"disconnect"} 2024-02-12T10:50:05+11:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"terminated","body":{}} 2024-02-12T10:50:05+11:00 debug layer=dap DAP server stopping... Process 116383 has exited with status 1 Detaching 2024-02-12T10:50:05+11:00 debug layer=dap DAP server stopped dlv dap (116256) exited with code: 0
This is the output of go env
:
GO111MODULE='auto'
GOARCH='amd64'
GOBIN='/home/linuxbrew/.linuxbrew/Cellar/go/1.21.6/bin'
GOCACHE='/home/myuser/.cache/go-build'
GOENV='/home/myuser/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/linuxbrew/.linuxbrew/Cellar/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/linuxbrew/.linuxbrew/Cellar/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/linuxbrew/.linuxbrew/Cellar/go/1.21.7/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/linuxbrew/.linuxbrew/Cellar/go/1.21.7/libexec/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.7'
GCCGO='gccgo'
GOAMD64='v1' AR='ar' CC='cc' CXX='c++'
CGO_ENABLED='1'
GOMOD=''
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 -m64
-pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3254040920=/tmp/go-build -gno-record-gcc-switches'