1)下载dlv
git clone https://github.com/go-delve/delve.git $GOPATH/src/github.com/go-delve/delve
或者 go get github.com/derekparker/delve/cmd/dlv
root@cloud:~# go version go version go1.14.10 linux/arm64
2)安装
cd $GOPATH/src/github.com/go-delve/delve
make install
root@cloud:~/delve# make install -j $(nproc) go install "-ldflags=-X main.Build=1b2357092c8fee7406988d8191f71059700c5399" github.com/go-delve/delve/cmd/dlv root@cloud:~/delve# dlv -h Delve is a source level debugger for Go programs. Delve enables you to interact with your program by controlling the execution of the process, evaluating variables, and providing information of thread / goroutine state, CPU register state and more. The goal of this tool is to provide a simple yet powerful interface for debugging Go programs. Pass flags to the program you are debugging using `--`, for example: `dlv exec ./hello -- server --config conf/config.toml`
(dlv) bp Breakpoint runtime-fatal-throw at 0x429a0 for runtime.fatalthrow() GOROOT/src/runtime/panic.go:1162 (0) Breakpoint unrecovered-panic at 0x42a00 for runtime.fatalpanic() GOROOT/src/runtime/panic.go:1189 (0) print runtime.curg._panic.arg Breakpoint 1 at 0x3edc70 for gvisor.dev/gvisor/pkg/sentry/mm.(*MemoryManager).MMap() pkg/sentry/mm/syscalls.go:75 (1) (dlv) clear 1 Breakpoint 1 cleared at 0x3edc70 for gvisor.dev/gvisor/pkg/sentry/mm.(*MemoryManager).MMap() pkg/sentry/mm/syscalls.go:75 (dlv) bp Breakpoint runtime-fatal-throw at 0x429a0 for runtime.fatalthrow() GOROOT/src/runtime/panic.go:1162 (0) Breakpoint unrecovered-panic at 0x42a00 for runtime.fatalpanic() GOROOT/src/runtime/panic.go:1189 (0) print runtime.curg._panic.arg (dlv) quit Would you like to kill the process? [Y/n] n root@cloud:~/delve#
原文:https://www.cnblogs.com/dream397/p/14277763.html