dongli9894 2013-10-15 09:46
浏览 102
已采纳

由于出现错误“没有名为model / page.go的源文件”,因此无法使用Golang在GDB中设置断点

I am trying to debug a Go-program using gdb and setting breakpoints works normally in all packages, except for one. In my src-folder I have 3 subfolders that each contain packages:

  • crawler/
    • crawler.go
  • model/
    • page.go
  • urlutils/
    • urlutils.go

I cannot set a breakpoint in page.go on any line as it gives me the following error:

(gdb) break model/page.go:14
No source file named model/page.go.
Make breakpoint pending on future shared library load? (y or [n])

I do not understand why this is happening with only this one package. "model/page" is also an import in the file that contains the main function and is used when the program runs, so it must be in the executable. Does anyone have an idea?

  • 写回答

1条回答 默认 最新

  • douwen5584 2013-10-15 17:52
    关注

    I found a solution:

    I needed to add a flag to my go build command:

    go build -gcflags "-N -l" launch.go
    

    This disables the code optimization performed by the go compiler which lead to my breakpoint working. The paths were correct and also the absolute path didn't work.

    Nevertheless, thank you tomwilde for pointing me into a direction.

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

报告相同问题?

悬赏问题

  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下