greatwolf
greatwolf

Reputation: 20838

How do I load .gdbinit on gdb startup?

This is a seemly trivial question but I can't find a simple way to accomplish this.

I have my .gdbinit file defined in the same directory as where gdb.exe exist -- that is inside my compiler's bin directory. However, when I run gdb I get this:

GNU gdb (GDB) 7.5.50.20120804-cvs
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 "i686-w64-mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
warning: File "g:\Mingw32-4.6.3\bin\.gdbinit" auto-loading has been declined by
your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".

I looked up the manual about auto-loading here but it has nothing about keeping that new safe-path I added saved! Exiting gdb and starting it up again and the safe-paths I added are gone.

My .gdbinit contains settings that I always want loaded upon startup. Loading .gdbinit is probably environment agnostic but what's the simplest way to do this under Windows? There is an addition constraint that .gdbinit cannot reside in my home directory -- it must be in the same path as the gdb.exe executable.

Upvotes: 9

Views: 23705

Answers (5)

pitrz
pitrz

Reputation: 11

For other struggling xtensa toolchain users: xt-gdb is not looking for a file named .gdbinit but rather .xt-gdbinit. Otherwise the mechanics are exactly the same as with standard gdb.

Upvotes: 1

Grzegorz Głowacki
Grzegorz Głowacki

Reputation: 193

None of the above answers worked for me. The problem is that under windows there's no HOME enviroment variable set. So let's set one: Write in command line:

   set HOME=c:\users\user

where the .gdbinit should be, and where You can disable the security protection by setting it content:

set auto-load safe-path /

And from now, Your gdb will load Your local .gdbinit

c:\MinGW\bin\gdb.exe app.exe

Upvotes: 2

AK S
AK S

Reputation: 182

I launch xt-gdb that comes with Xtensa tool chain with -iex -ix parameters as follows:

xt-gdb -iex "set auto-load safe-path Path\to\gdbinit\dir" -ix Path\to\gdbinit\dir.gdbinit

Upvotes: 2

Sarvavyapi
Sarvavyapi

Reputation: 850

I use CodeSourcery arm-none-eabi-gdb.exe on Windows 7. Following the above instructions did not work in my case. Below command worked:

arm-none-eabi-gdb.exe -x D:\CodeSourcery\bin\.gdbinit

Upvotes: 8

Employed Russian
Employed Russian

Reputation: 213526

I have my .gdbinit file defined in the same directory as where gdb.exe exist

Put into your $HOME or into current directory.

Upvotes: 9

Related Questions