Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading .gdbinit from current directory fails with "auto-loading has been declined by your `auto-load safe-path'"

Tags:

I'm having trouble loading a .gdbinit file located in the current directory. On starting gdb, I get this:

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". 

I can load the .gdbinit file in the current directory by starting gdb with:

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

as described here. but is there a way set $debugdir to include the current directory?

Trying

$ export debugdir=.
$ gdb

yields the same warning as above.

like image 636
fragapanagos Avatar asked May 16 '13 19:05

fragapanagos


People also ask

What is auto load safe path?

GDB provides the ' set auto-load safe-path ' setting to list directories trusted for loading files not explicitly requested by user. Each directory can also be a shell wildcard pattern.

Where do I put .gdbinit files?

gdbinit - put it in your home directory. Now every time gdb starts it will execute the commands in this file. ". gdbinit" is a file you can drop in your home directory that gdb will parse when gdb launches, either from the command line or from within Xcode.


2 Answers

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

Basically, what you want is to allow loading the per-directory .gdbinit from your ~/.gdbinit. If you are not worried about the security aspects, then this works:

set auto-load safe-path .

Or, if that doesn't cut it for some reason, you can also allow loading the .gdbinit from anywhere on the system:

set auto-load safe-path /
like image 171
Tom Tromey Avatar answered Sep 20 '22 12:09

Tom Tromey


In my case I had no ~/.gdbinit file. The solution was creating this file containing two lines specifying auto-load-safe-path(s).

add-auto-load-safe-path <path1>
add-auto-load-safe-path <path2>
like image 27
Flaviu Avatar answered Sep 22 '22 12:09

Flaviu