从当前目录加载 .gdbinit 失败,并显示"auto-loading has been declined by your `auto-load safe-path'"



我在加载位于当前目录中的.gdbinit文件时遇到了麻烦。在启动gdb时,我得到这个:

GNU gdb (GDB) 7.5-ubuntu
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
warning: File "/home/user1/test/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load". 

我可以加载.gdbinit文件在当前目录下启动gdb:

gdb -iex 'add-auto-load-safe-path .'

,如下所述。但是有没有办法设置$debugdir来包含当前目录?

$ export debugdir=.
$ gdb

产生与上面相同的警告。

参见http://sourceware.org/gdb/current/onlinedocs/gdb/Startup.html#Init%20File%20in%20the%20Current%20Directory%20during%20Startup

基本上,您想要的是允许从~/.gdbinit加载每个目录的.gdbinit。如果您不担心安全方面的问题,那么可以这样做:

set auto-load safe-path .

或者,如果由于某种原因不能切割它,您也可以允许从系统上的任何地方加载.gdbinit:

set auto-load safe-path /

在我的情况下,我没有~/.gdbinit文件。解决方案是创建包含两行指定自动加载安全路径的文件。

add-auto-load-safe-path <path1>
add-auto-load-safe-path <path2>