20

我在加载位于当前目录中的 .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". 

我可以通过以下方式启动 gdb 来加载当前目录中的 .gdbinit 文件:

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

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

$ export debugdir=.
$ gdb

产生与上述相同的警告。

4

2 回答 2

26

请参阅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 /
于 2013-05-24T19:08:28.337 回答
1

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

add-auto-load-safe-path <path1>
add-auto-load-safe-path <path2>
于 2020-09-02T08:39:22.720 回答