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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值