[컴] How to set the delve Go debugger for ethereum




Visual Studio Code + delve

Here, I will use the Visual Studio Code, which is forked from Atom Editor. With the Visual Studio Code, you can use delve as GUI debugger and you can use Visual Studio Code on any platform.


Procedure

  1. install Visual Studio Code(VsCode)
  2. install VsCode plugin Go
  3. install other tools for plugin Go : Microsoft/vscode-go: > tools
  4. set PATH and GOPATH
  5. write the launch.json
  6. write the settings.json
  7. Open cmd/geth folder from VsCode
  8. Press F5, Run debugger


Install Visual Studio Code

First we need the Visual Studio Code, you can download and install it here. it's easy to install, so I do not explain much here.


install Visual Studio Code plugin Go

After the Visual Studio Code is installed, then, install the plugin named 'Go' (see the bleow image)




Install other tools for plugin Go 

plugin Go needs some other tools to analyze the .go files. you can see the tools list and how to install at the below page.



PATH and GOPATH

The ehtereum uses "godep go install" to compile. As for delve, you can't use godep, so you should set GOPATH by yourself.

On Linux, I tried the set GOPATH variable through .vscode/launch.json, but it was not possible to set several path at once using ':'. Thus, I should set it on .bashrc

GOPATH=/home/username/go/ethereum:/home/username/go/ethereum/src/github.com/ethereum/go-ethereum/Godeps/_workspace



launch.json

Press F5, then .vscode/launch.json will be showed up. You can edit it with the below codes.
{
 "version": "0.2.0",
 "configurations": [
  {
   "name": "Launch",
   "type": "go",
   "request": "launch",
   "mode": "debug",
   "program": "${workspaceRoot}",
   "env": {

   },
   "args": []
  }
 ]
}


Options, settings.json


You can adjust the option values of the Go plugin with writing the .vscode/settings.json
However, I do not think the below keys are working properly

  • go.goroot
  • go.gopath


{
    "go.buildOnSave": true,
    "go.lintOnSave": true,
    "go.vetOnSave": true,
    "go.buildTags": "",
    "go.buildFlags": [],
    "go.lintFlags": [],
    "go.vetFlags": [],
    "go.coverOnSave": false,
    "go.useCodeSnippetsOnFunctionSuggest": false,
    "go.formatOnSave": true,
    "go.formatTool": "goreturns",
    "go.goroot": "d:/Go",
    "go.gopath": "d:/mine/programming/go/ethereum",
    "go.gocodeAutoBuild": false
}


open cmd/geth

On Visual Studio Code, You should open the "cmd/geth" directory to compile with delve debugger
File ---> Open Folder ---> <ethereum_root>/cmd/geth



Run debbuger

You can run the debugger with pressing the F5 key. You'd better open the debug console windows (Ctrl + Shift + Y) before running. This action takes time to compile the codes.







댓글 없음:

댓글 쓰기