have gdb read automatically ./.gdbinit

With the pristine gdb (Debian 8.2.1-2) while debugging RefPerSys (GPLv3+, on gitlab) commit ec4ab756d302056cace0b on my Linux/x86-64/Debian Sid AMD2970WX desktop, I am reproducibly getting

rimski.x86_64 ~/refpersys 14:39 .0 % gdb --args ./refpersys --object-tinybenchmark1
GNU gdb (Debian 8.2.1-2) 8.2.1
Copyright (C) 2018 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".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./refpersys...done.
warning: File "/home/basile/refpersys/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
    add-auto-load-safe-path /home/basile/refpersys/.gdbinit
line to your configuration file "/home/basile/.gdbinit".
To completely disable this security protection add
    set auto-load safe-path /
line to your configuration file "/home/basile/.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"

What is the magic to have my ./.gdbinit digested by such a gdb invocation without diagnostics? That .gdbinit contains:

# file refpersys/.gdbinit 
# GPLv3+ licensed 
add-auto-load-safe-path ./.gdbinit 
break abort 
break rps_fatal_stop_at 
set max-value-size 67108864

I could (and did that in the past) rebuild gdb from its source code. But today, I am lame, and prefer focusing on my bugs.

FWIW

(gdb) show configuration 
This GDB was configured as follows:
   configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu
             --with-auto-load-dir=$debugdir:$datadir/auto-load
             --with-auto-load-safe-path=$debugdir:$datadir/auto-load
             --with-expat
             --with-gdb-datadir=/usr/share/gdb (relocatable)
             --with-jit-reader-dir=/usr/lib/gdb (relocatable)
             --without-libunwind-ia64
             --with-lzma
             --with-babeltrace
             --with-intel-pt
             --disable-libmcheck
             --without-mpfr
             --with-python=/usr (relocatable)
             --without-guile
             --with-separate-debug-dir=/usr/lib/debug (relocatable)
             --with-system-gdbinit=/etc/gdb/gdbinit

Upvotes: 2

Views: 2232

Answers (1)

borizzzzz
borizzzzz

Reputation: 620

Just as the warning says when you launch gdb:

To enable execution of this file add
    add-auto-load-safe-path /home/basile/refpersys/.gdbinit
line to your configuration file "/home/basile/.gdbinit".

It seems like you've misunderstood and added the line into the .gdbinit file within your repo but it needs to go into your home directory.

If the .gdbinit file doesn't yet exist in your home directory, you can create it and only add the needed line above, and it should work.

Upvotes: 1

Related Questions