geth调试遇到的问题

使用goland生成geth

选择go build按照包(Package)或者按照目录(Directory)的编译单位,比如编译geth就是如下目录,如果是evm就是cmd/evm

goland configuration

goland调试无法输入

直接选择debug之后,无法输入,也就是说,虽然这个console可以输入字符,但是没有反应

调试图

这个问题idea其实也有,但是一开始没有反应过来,以为是输入卡住了,后来才反应过来原来是这个console根本没法输入。。

可以看看这个:Unable to read stdin input in debug mode

So far the only supported way to debug a program like this is to start a headless instance in one terminal:

dlv --headless debug yourprogram.go
This will print something like this:

API server listening at: 127.0.0.1:XYZ
then in another terminal do:

dlv connect :XYZ
Input for delve will go in the second terminal, input for your program will go in the first one.

这里使用的是dlv调试,用dlv connect server就可以

我们可直接用geth attach来操作,该命令会启动一个连到节点的交互式JS控制台

attach的地址在启动的时候已经给出了,就是IPC地址:

ipc地址

最终命令geth attach xxxxx/geth.ipc

Bingo! 开始你的调试吧!