doubipeng1336 2019-03-23 07:35
浏览 192
已采纳

如何使用gdb或delve将断点置于go方法中

I want to debug a go code. I want to put breakpoint on a method (belonging to a named type) in a imported package. I went through a lot of online materials where they only put breakpoints on a line number in file (eg:breakpoint a.go:15).

I have done a lot of debugging in 'C' where I put breakpoints on functions. Is this kind of debugging possible in go??

I have the following code in my main package.

clientContext := sdk.Context(fabsdk.WithUser("Admin"), fabsdk.WithOrg("ordererorg")).

I want to put breakpoints to

1) function WithUser() which belongs to package fabsdk in file github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/context.go.
2) method Context() belonging to type FabricSDK in file github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/fabsdk.go in package fabsdk.

Is it possible to put breakpoints to method WithUser() and context() or Isbreakpoints only allowed at a line number in a file?? I could use either gdb or delve or any other debugger as well.

  • 写回答

1条回答 默认 最新

  • dqyy38265 2019-03-24 10:03
    关注

    If you have the version of github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/context.go that was used to build your Go binary — for example, in your src or vendor directory — then just open that file, find the WithUser function, and put a breakpoint on its first line.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题