在使用Go-ethereum 進行開發時,需要進行測試調試geth時,由於官方默認Makefile編譯版本是經過優化版本,不管用gdb,
還是dlv調試工具,都會出現不方便調試的時候,經過自己整理摸索,實現了Go-ethereum的調試版本編譯,
總結步驟如下:
0. 使用官方的makefile生產環境:
cd /path/to/go-ethereum
make geth
1. 導出GO工作環境環境變量: export GOBIN= /path/to/go-ethereum/build/bin
export GOPATH= /path/to/go-ethereum/build/_workspace
2. 強制重新編譯
go install -a -gcflags=all='-N -l' -v ./cmd/geth
3. 編譯或者下載dlv,推薦使用dlv調試工具,相比GDB, dlv對於Golang有更好的支持。
dlv exec geth