2019-08-19 使用vscode对hera代码调试

2019-08-19  本文已影响0人  oracle3

参考2018-11-26 ewasm在以太坊私有链测试搭建开发环境
1、修改hera
修改文件CMakeLists.txt,在尾部增加

SET(CMAKE_BUILD_TYPE "Debug")  
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")  
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")  

修改文件cmake/ProjectBinaryen.cmake,找到

DCMAKE_BUILD_TYPE=Release

修改为

DCMAKE_BUILD_TYPE=Debug

然后重新编译

cd build
rm -rfd *
cmake ..
make

2、配置vscode
安装vscode后,需要安装插件
C/C++ 0.24.1
C++ Intellisense 0.2.2
我们这里手动配置make的编译,因此不需要用到cmake插件
使用vscode打开目录hera,在debug页面,选择配置,生成launch.json,修改内容如下:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/elikong/testnet/geth",
            "args": ["--vm.ewasm=/home/elikong/testnet/hera/build/src/libhera.so,metering=true,fallback=true",
                "--datadir",
                "/home/elikong/testnet/ewasm-testnet-data",
                "--rpc",
                "--rpcapi",
                "web3,net,eth,debug",
                "--rpcvhosts=*",
                "--rpcaddr",
                "0.0.0.0",
                "--nodiscover",
                "--networkid",
                "66",
                "--ipcpath",
                "geth1.ipc",
                "console"
                ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "preLaunchTask": "build",
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

其中program,args里面的内容需要根据你实际的路径配置
点击运行后,确定配置tasks.json,内容如下:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "make"
            "options": {
                "cwd": "${workspaceRoot}/build"
            },
        }
    ]
}

通过这两个配置,就可以调试hera了

上一篇下一篇

猜你喜欢

热点阅读