英文:
cannot load runtime-gdb.py
问题
我正在尝试在Eclipse中调试使用Go编写的程序。我可以设置和命中断点,但无法查看变量的内容。当我开始调试程序时,我总是在控制台上收到以下错误信息。
警告:文件"/usr/local/go/src/pkg/runtime/runtime-gdb.py"的自动加载已被您的"auto-load safe-path"设置拒绝。
要启用对该文件的执行,请将以下行添加到您的配置文件"/home/johnlawrie/.gdbinit"中:
add-auto-load-safe-path /usr/local/go/src/pkg/runtime/runtime-gdb.py
要完全禁用此安全保护,请将以下行添加到您的配置文件"/home/johnlawrie/.gdbinit"中:
set auto-load safe-path /
有关此安全保护的更多信息,请参阅GDB手册中的"Auto-loading safe path"部分。例如,从shell中运行:
info "(gdb)Auto-loading safe path"
考虑到问题可能是由错误消息引起的,我按照指示将条目放入了我的.gdbinit文件中。然而,每次运行时我都收到相同的消息,就好像我什么都没做一样。这是我的/home/johnlawrie/.gdbinit文件的内容:
add-auto-load-safe-path /usr/local/go/src/pkg/runtime/runtime-gdb.py
有什么想法可以让这个更改生效吗?我已经尝试过注销并重新登录。
谢谢,
John Lawrie
英文:
I'm trying to debug a program written using Go inside eclipse. I can set and hit breakpoints pretty consistently, but I cannot view the contents of my variables. When I start debugging the program, I always get the following error on my console.
warning: File "/usr/local/go/src/pkg/runtime/runtime-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path /usr/local/go/src/pkg/runtime/runtime-gdb.py
line to your configuration file "/home/johnlawrie/.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/home/johnlawrie/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
info "(gdb)Auto-loading safe path"
Thinking that the problem might be due to the error message, I put the entry into my .gdbinit file as instructed. However, I get the same message every time I run as if I did nothing at all. This is the contents of my /home/johnlawrie/.gdbinit file
add-auto-load-safe-path /usr/local/go/src/pkg/runtime/runtime-gdb.py
Any ideas what I need to do to make this change take effect? I have tried logged off and back in.
Thanks,
John Lawrie
答案1
得分: 1
它确实了解发生了什么。当从Eclipse/CDT启动gdb时,它会使用选项-nx启动,这意味着它不会加载主目录中的.gdbinit文件。
我通过在我的工作空间的src、bin和pkg目录旁边创建一个.gdbinit文件,并在其中添加以下行来使其工作:
set auto-load safe-path /usr/local/go/
英文:
It did learn what was happening. When gdb is started from Eclipse/CDT, it is started with option -nx, which means it doesn't load .gdbinit in the home directory.
I was able to get this to work by creating a .gdbinit file as a peer to the src, bin, and pkg directories in my workspace and adding the following line to it
set auto-load safe-path /usr/local/go/
答案2
得分: 0
应该是 add-auto-load-safe-path /usr/local/go/src/pkg/
,而不是脚本的路径。
此外,请记住,gdb 对 Go 的支持并不好,特别是 v1.3。
来自 http://golang.org/doc/gdb 的说明:
> GDB 对 Go 程序的理解能力有限。 栈管理、线程和运行时包含的方面与 GDB 期望的执行模型有足够的差异,这可能会使调试器混淆,即使程序是使用 gccgo 编译的。因此,尽管 GDB 在某些情况下可能有用,但它不是 Go 程序的可靠调试器,特别是在涉及大量并发的情况下。此外,解决这些问题对于 Go 项目来说并不是优先事项,因为这些问题很难解决。简而言之,下面的说明只应作为在 GDB 可用时如何使用它的指南,而不是成功的保证。
英文:
It should be add-auto-load-safe-path /usr/local/go/src/pkg/
, not the path to the script.
Also keep in mind that gdb doesn't really work with Go, specially v1.3.
From http://golang.org/doc/gdb:
> GDB does not understand Go programs well. The stack management,
> threading, and runtime contain aspects that differ enough from the
> execution model GDB expects that they can confuse the debugger, even
> when the program is compiled with gccgo. As a consequence, although
> GDB can be useful in some situations, it is not a reliable debugger
> for Go programs, particularly heavily concurrent ones. Moreover, it is
> not a priority for the Go project to address these issues, which are
> difficult. In short, the instructions below should be taken only as a
> guide to how to use GDB when it works, not as a guarantee of success.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论