gdb加载当前目录下.gdbinit不成功

学习使用GDB时说可以通过编辑.gdbinit文件来方便下次调试相同的程序,于是直接在当前目录下编辑了一个.gdbinit的文件,如下所示:

[root@bogon base]# ll -a
total 28
drwxr-xr-x. 2 root root 4096 Jun 26 04:48 .
drwxr-xr-x. 3 root root 4096 Jun 26 02:16 ..
-rwxr-xr-x. 1 root root   16 Jun 26 04:48 .gdbinit
-rw-r--r--. 1 root root  865 Jun 26 04:32 ins.c
-rwxr-xr-x. 1 root root 9486 Jun 26 04:32 insert_sort

运行GDB,提示加载不成功:

[root@bogon base]# gdb
warning: File "/home/xyy/debug_test/base/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "/usr/share/gdb/auto-load:/usr/lib/debug:/usr/bin/mono-gdb.py".
To enable execution of this file add
	add-auto-load-safe-path /home/xyy/debug_test/base/.gdbinit
line to your configuration file "/root/.gdbinit".
To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/root/.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"

根据上面的提示可知,加载不成功是由于

warning: File "/home/xyy/debug_test/base/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "/usr/share/gdb/auto-load:/usr/lib/debug:/usr/bin/mono-gdb.py".
可以通过

1、添加“add-auto-load-safe-path /home/xyy/debug_test/base/.gdbinit”到/root/.gdbinit文件中,使该文件可以被加载;

To enable execution of this file add
	add-auto-load-safe-path /home/xyy/debug_test/base/.gdbinit
line to your configuration file "/root/.gdbinit".

或者

2、添加“set auto-load safe-path /”到/root/.gdbinit文件中,相当于禁用了安全路径的保护;

To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/root/.gdbinit".


3、也可以先运行GDB在给出上面的提示后,运行gdb命令“source .gdbinit”,临时导入.gdbinit文件。

[root@bogon base]# gdb insert_sort 
...
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"
(gdb) source .gdbinit 
Breakpoint 1 at 0x4006a7: file ins.c, line 62.
Breakpoint 2 at 0x4005b7: file ins.c, line 29.
(gdb) 

4、调用GDB时指定启动文件。

[root@bogon base]# gdb -command=.gdbinit insert_sort 

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在你提供的引用中,有一个问题是关于在Eclipse中遇到“eclips .gdbinit: No such file or directory”的错误。这个错误通常是由于找不到.gdbinit文件导致的。在你的引用中,你尝试在当前工程根目录下创建一个.gdbinit文件,但是没有起作用。根据你提供的引用内容,有一种方法可以解决这个问题。 首先,你需要确认你的.gdbinit文件是否位于正确的位置,并且文件名是否正确。通常情况下,.gdbinit文件应该位于当前用户的主目录下。你可以使用`ls -a`命令来查看是否存在.gdbinit文件。如果不存在,你可以使用`touch .gdbinit`命令在主目录下创建一个空的.gdbinit文件。 接下来,你可以尝试在.gdbinit文件中添加设置架构的语句。根据你提供的引用内容,这个语句可能类似于`set architecture [architecture_name]`。请确保你在语句中替换[architecture_name]为你想要设置的架构名称。 如果你已经按照上述步骤进行了操作,但是仍然遇到“eclips .gdbinit: No such file or directory”的错误。你可以考虑尝试以下方法: 1. 确保你的Eclipse和GDB的版本兼容。根据你提供的引用内容,你使用的是Eclipse Kepler版本和GDB 7.7版本。确保这两个版本是兼容的,可以避免可能出现的问题。 2. 检查你的Eclipse的配置。根据你提供的引用内容,你已经安装了CDT插件。确保你已经正确配置了CDT插件,并且将GDB debugger设置为你编译的GDB的路径。 3. 检查你的系统环境变量。确保你已经将GDB的路径添加到系统的PATH变量中。这样可以确保Eclipse能够正确找到GDB的位置。 总结一下,如果你在Eclipse中遇到“eclips .gdbinit: No such file or directory”的错误,你可以尝试以下方法: 1. 确认.gdbinit文件是否位于正确位置,并且文件名正确。 2. 在.gdbinit文件中添加设置架构的语句。 3. 确认Eclipse和GDB的版本兼容。 4. 检查Eclipse的配置,确保CDT插件正确配置,并且设置了正确的GDB debugger路径。 5. 检查系统环境变量,确保GDB的路径已添加到系统的PATH变量中。 希望这些方法可以帮助你解决问题。如果还有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值