mac m4 dlve breakpoint is invalid
mac m4
go env: GO111MODULE='on' GOARCH='arm64' GOBIN='' GOCACHE='/Users/xxx/Library/Caches/go-build' GOENV='/Users/xxx/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/xxx/go/1.16.15/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users/xxx/go/1.16.15' GOPRIVATE='' GOPROXY='https://goproxy.cn,direct' GOROOT='/Users/xxx/.goenv/versions/1.22.0' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/Users/xxxx/.goenv/versions/1.22.0/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.22.0' GCCGO='gccgo' AR='ar' CC='clang' CXX='clang++' CGO_ENABLED='1' GOMOD='/Users/xxxx/program/goProject/leetCode/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/ll/rjzz8jfn3vz14sm88crxnnmh0000gn/T/go-build3667064099=/tmp/go-build -gno-record-gcc-switches -fno-common'
dlve version: 1.6.0 and 1.6.1, i have tried these 2 version, but neither of them is useful
my simple file.go:
package main
import "fmt"
func main() {
a, b := 1, 3
c := a + b
fmt.Print(c)
}
my breakpoint line is c := a + b, but it didn't stop at that line, it just run to end and print 4
the simple program run log: panic: runtime error: index out of range [7542] with length 7542
goroutine 1 [running]: github.com/go-delve/delve/pkg/proc/gdbserial.(*gdbConn).readRegisters(0x1400014e790, 0x14000028148, 0x5, 0x140009c0000, 0x1d76, 0x1d76, 0x1400011ae38, 0x100612f2c) /Users/cailyn/Downloads/delve-1.6.1/pkg/proc/gdbserial/gdbserver_conn.go:461 +0x294 github.com/go-delve/delve/pkg/proc/gdbserial.(*gdbThread).reloadRegisters(0x140000a80d0, 0x100609abc, 0x127e366d0) /Users/cailyn/Downloads/delve-1.6.1/pkg/proc/gdbserial/gdbserver.go:1558 +0x310 github.com/go-delve/delve/pkg/proc/gdbserial.(*gdbThread).Registers(0x140000a80d0, 0x127e366d0, 0xb0, 0x101120130, 0x1400011af98) /Users/cailyn/Downloads/delve-1.6.1/pkg/proc/gdbserial/gdbserver.go:1413 +0x54 github.com/go-delve/delve/pkg/proc/gdbserial.(*gdbThread).Location(0x140000a80d0, 0x140000a8178, 0x1400011afc8, 0x1008ada90) /Users/cailyn/Downloads/delve-1.6.1/pkg/proc/gdbserial/gdbserver.go:1386 +0x28 github.com/go-delve/delve/pkg/proc.GetG(0x100c504d8, 0x140000a80d0, 0x1400014e780, 0x1282002c0, 0x1400014e780) /Users/cailyn/Downloads/delve-1.6.1/pkg/proc/variables.go:246 +0x50 github.com/go-delve/delve/pkg/proc.NewTarget(0x100c51458, 0x1400014e780, 0x100c504d8, 0x140000a80d0, 0x16f803696, 0x5a, 0x14000120400, 0x1, 0x1, 0x10101, ...) /Users/cailyn/Downloads/delve-1.6.1/pkg/proc/target.go:173 +0x1d0 github.com/go-delve/delve/pkg/proc/gdbserial.(*gdbProcess).initialize(0x1400014e780, 0x16f803696, 0x5a, 0x14000120400, 0x1, 0x1, 0x1, 0x3, 0x3, 0x0) /Users/cailyn/Downloads/delve-1.6.1/pkg/proc/gdbserial/gdbserver.go:685 +0x188 github.com/go-delve/delve/pkg/proc/gdbserial.(*gdbProcess).Connect(0x1400014e780, 0x100c4f790, 0x14000010018, 0x16f803696, 0x5a, 0x0, 0x14000120400, 0x1, 0x1, 0x1, ...) /Users/cailyn/Downloads/delve-1.6.1/pkg/proc/gdbserial/gdbserver.go:344 +0x1b8 github.com/go-delve/delve/pkg/proc/gdbserial.(*gdbProcess).Listen(0x1400014e780, 0x100c48a50, 0x1400011e270, 0x16f803696, 0x5a, 0x0, 0x14000120400, 0x1, 0x1, 0x1, ...) /Users/cailyn/Downloads/delve-1.6.1/pkg/proc/gdbserial/gdbserver.go:284 +0x14c github.com/go-delve/delve/pkg/proc/gdbserial.LLDBLaunch(0x1400015e4d0, 0x1, 0x7, 0x100a74cc2, 0x1, 0x100609a01, 0x14000120400, 0x1, 0x1, 0x0, ...) /Users/cailyn/Downloads/delve-1.6.1/pkg/proc/gdbserial/gdbserver.go:540 +0x9e0 github.com/go-delve/delve/service/debugger.(*Debugger).Launch(0x14000288000, 0x1400015e4d0, 0x1, 0x7, 0x100a74cc2, 0x1, 0x1, 0x1006000e0, 0x10112f270) /Users/cailyn/Downloads/delve-1.6.1/service/debugger/debugger.go:298 +0x4a0 github.com/go-delve/delve/service/debugger.New(0x14000286000, 0x1400015e4d0, 0x1, 0x7, 0x0, 0x0, 0x0) /Users/cailyn/Downloads/delve-1.6.1/service/debugger/debugger.go:188 +0x4c8 github.com/go-delve/delve/service/rpccommon.(*ServerImpl).Run(0x14000112540, 0x14000112540, 0x140001542a0) /Users/cailyn/Downloads/delve-1.6.1/service/rpccommon/server.go:115 +0xb8 github.com/go-delve/delve/cmd/dlv/cmds.execute(0x0, 0x1400015e4d0, 0x1, 0x7, 0x1400012ed00, 0x0, 0x0, 0x0, 0x1400015e4d0, 0x1, ...) /Users/cailyn/Downloads/delve-1.6.1/cmd/dlv/cmds/commands.go:864 +0x688 github.com/go-delve/delve/cmd/dlv/cmds.New.func4(0x1400013f200, 0x1400015e4d0, 0x1, 0x7) /Users/cailyn/Downloads/delve-1.6.1/cmd/dlv/cmds/commands.go:229 +0x78 github.com/spf13/cobra.(*Command).execute(0x1400013f200, 0x1400014d540, 0x7, 0xa, 0x1400013f200, 0x1400014d540) /Users/cailyn/go/1.16.15/pkg/mod/github.com/spf13/[email protected]/command.go:647 +0x18c github.com/spf13/cobra.(*Command).ExecuteC(0x1400013e6c0, 0x1400013e6c0, 0x100a77530, 0x6) /Users/cailyn/go/1.16.15/pkg/mod/github.com/spf13/[email protected]/command.go:733 +0x208 github.com/spf13/cobra.(*Command).Execute(...) /Users/cailyn/go/1.16.15/pkg/mod/github.com/spf13/[email protected]/command.go:692 main.main() /Users/cailyn/Downloads/delve-1.6.1/cmd/dlv/main.go:24 +0xc0 4 Debugger finished with the exit code 2
if you need more information, please let me known
Version 1.6 of delve is old for go 1.22, you should first update delve to at least 1.22.0.
If updating doesn't work please post the output with --log --log-output=gdbwire.
Version 1.6 of delve is old for go 1.22, you should first update delve to at least 1.22.0.
i installed 2 versions of go, go 1.16 and go 1.22. Version 1.6 of delve is for go 1.16
Version 1.6 of delve is old for go 1.22, you should first update delve to at least 1.22.0.
i installed 2 versions of go, go 1.16 and go 1.22. Version 1.6 of delve is for go 1.16
oh, i copied the env of go 1.22 in the previouse comment, the env of go 1.6 is below:
GO111MODULE="" GOARCH="arm64" GOBIN="" GOCACHE="/Users/xxxx/Library/Caches/go-build" GOENV="/Users/xxxxx/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/xxxx/go/1.16.15/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/xxxx/go/1.16.15" GOPRIVATE="" GOPROXY="https://goproxy.cn,direct" GOROOT="/Users/xxxx/.goenv/versions/1.16.15" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/Users/xxxxx/.goenv/versions/1.16.15/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.16.15" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ll/rjzz8jfn3vz14sm88crxnnmh0000gn/T/go-build1189950019=/tmp/go-build -gno-record-gcc-switches -fno-common"
Neither go 1.16 nor delve 1.6 are supported any longer.
If i have to use go 1.16, how can i debug my program?
Go very rarely breaks backwards compatibility, I think it would be worth revisiting your assumption that you have to use go 1.16.
You can use a more recent version of delve with the version check disabled, we don't test it but it probably works anyway. Or you can use an operating system that breaks backwards compatibility less. Or you can track down the patches to the debugserver backend (they are the ones that touch pkg/proc/gdbserial and make your own version of delve).
Go very rarely breaks backwards compatibility, I think it would be worth revisiting your assumption that you have to use go 1.16.
You can use a more recent version of delve with the version check disabled, we don't test it but it probably works anyway. Or you can use an operating system that breaks backwards compatibility less. Or you can track down the patches to the debugserver backend (they are the ones that touch pkg/proc/gdbserial and make your own version of delve).
Thank you! I will try it.