前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >2019-02-26 在ubuntu上调试go-ethereum

2019-02-26 在ubuntu上调试go-ethereum

作者头像
oracle3
发布2022-05-13 08:30:31
5540
发布2022-05-13 08:30:31
举报
文章被收录于专栏:oracle3技术大杂烩

参考2018-11-22 Debug以太坊go-ethereum实战 这个在windows上调试挺方便的,但是放到ubuntu上死活debug出错,goland到底存在啥问题呢,实在找不到原因,就想到一个折中的方法来解决:使用goland启动go-ethereum,然后使用dlv调试,方法如下:

1、用su修改文件,然后重启

使用dlv attach的时候回出现类似下面的错误

代码语言:javascript
复制
Could not attach to process.  If your uid matches the uid of the target process

需要修改文件/etc/sysctl.d/10-ptrace.conf,将此文件下的kernel.yama.ptrace_scope = 1 改为0, 允许普通用户调试。但必须重启生效。

2、goland启动go-ethereum

参考2018-11-22 Debug以太坊go-ethereum实战配置,然后启动,当然如果选择debug一定退出

3、使用dlv调试

启动一个终端,执行ps

代码语言:javascript
复制
ps aux | grep geth
elikong   2504  0.9  4.8 960080 194284 pts/0   Sl+  10:58   0:00 /tmp/___go_build_github_com_ethereum_go_ethereum_cmd_geth --datadir /home/elikong/temp/geth-data0 --networkid 1314 --nodiscover --rpcport 6001 --port 30001 --ipcpath /home/elikong/temp/geth-data0/geth1.ipc console
elikong   2543  0.0  0.0  21536  1036 pts/1    S+   10:59   0:00 grep --color=auto geth

然后使用dlv

代码语言:javascript
复制
dlv attach 2504
Successfully moved config from: /home/elikong/.dlv to: /home/elikong/.config/dlv/config.yml
Type 'help' for list of commands.
(dlv) funcs SendTransaction
github.com/ethereum/go-ethereum/eth.(*peer).AsyncSendTransactions
github.com/ethereum/go-ethereum/eth.(*peer).SendTransactions
github.com/ethereum/go-ethereum/ethclient.(*Client).SendTransaction
github.com/ethereum/go-ethereum/internal/ethapi.(*PrivateAccountAPI).SendTransaction
github.com/ethereum/go-ethereum/internal/ethapi.(*PrivateAccountAPI).SignAndSendTransaction
github.com/ethereum/go-ethereum/internal/ethapi.(*PublicTransactionPoolAPI).SendTransaction
(dlv) b ethapi.(*PublicTransactionPoolAPI).SendTransaction
Breakpoint 1 set at 0xa0a77b for github.com/ethereum/go-ethereum/internal/ethapi.(*PublicTransactionPoolAPI).SendTransaction() ./go/src/github.com/ethereum/go-ethereum/internal/ethapi/api.go:1278
(dlv) c

然后回到goland的run窗口里面输入

代码语言:javascript
复制
personal.unlockAccount(eth.accounts[0])
eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[1],value:web3.toWei(10,"ether")})

回车后,返回到dlv的终端,这个时候看到断点断下来了,剩下的就是参考使用Delve进行Golang代码的调试进行代码调试了

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-05-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、用su修改文件,然后重启
  • 2、goland启动go-ethereum
  • 3、使用dlv调试
相关产品与服务
区块链
云链聚未来,协同无边界。腾讯云区块链作为中国领先的区块链服务平台和技术提供商,致力于构建技术、数据、价值、产业互联互通的区块链基础设施,引领区块链底层技术及行业应用创新,助力传统产业转型升级,推动实体经济与数字经济深度融合。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档