9

And should it be called .gdbinit or gdb.ini?

I thought that I would try this file.

I am testing with Vectorcast, which uses MinGw. I copied the file with both names (.gdbinit and gdb.ini) to both the Vectorcast directory and it's MinGW bin directory, where gdb.exe is, as I was unsure which is the current working directory, but don't see anything which I would expect from that file.

So, where should I put it, and what should I call it?

Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551

2 Answers2

10

You should put it into your $HOME directory or into current directory, see How do I load .gdbinit on gdb startup?.

You can know your home directory from gdb shell with either

(gdb) show environment HOME

or

(gdb) shell echo $HOME

You can know current directory with

(gdb) shell pwd

And should it be called .gdbini or gdb.ini?

No, it should be called .gdbinit.

ks1322
  • 33,961
  • 14
  • 109
  • 164
  • 1
    Alas, none of those GDB commands work in Windows. You did, however, notice a bad typo in my question (upvote for that). I had used `.gdbini` in my question, when it ought to have been `.gdbinit`. I have updated the question. The file was correctly named in both the Vectorcast directory and it's MinGW bin directory, and won't work when using that `.gdbinit` file which I linked in the question, so I am still stuck – Mawg says reinstate Monica Jul 16 '18 at 10:54
  • Looks like you will get the bounty by default in a few days, but I still can't get it to work. I don't care about the bounty, no more do you, I imagine, but can you help me to get it working? Thanks – Mawg says reinstate Monica Jul 20 '18 at 07:15
  • 1
    Does `.gdbinit` loading without Vectorcast? I guess it is worth to make it load without Vectorcast first. Try to set `HOME` variable to `%USERPROFILE%` and place `.gdbinit` in "C:\Users\Firstname Lastname" as suggested in mingw howto: http://www.mingw.org/wiki/HOWTO_Set_the_HOME_variable_for_cmd_exe. – ks1322 Jul 21 '18 at 10:06
  • Good idea. I don't mind running GDB standalone, as opposed to launching it from Vectorcast. I will try this first thing Monday – Mawg says reinstate Monica Jul 21 '18 at 11:32
  • D'oh! For some reason, "`.gdbinit:1567: Error in sourced command file: Python scripting is not supported in this copy of GDB.`" I guess that I won't be using that `.gdbinit`; maybe I'll look for another (but what I am really looking for is [a Windows GDB GIU](https://softwarerecs.stackexchange.com/questions/51063/gratis-portable-gdb-gui-for-windows)) Thanks for your help (gdb) – Mawg says reinstate Monica Jul 23 '18 at 06:29
  • When Creating the HOME variable in windows you may need to restart the command prompt for it to propegate. – AspinBlack Nov 07 '22 at 14:41
2

On Windows, create a directory called anything you fancy in c:/users/yourusername where yourusername is your Windows username.

(Doesn't have to be here but it's a safe place.)

Now from the control panel invoke the environment variables dialog and create a new environment variable called HOME. Set that variable to the above folder by clicking browse for folder and navigating there.

Put .gdbinit in there and use it to set any autoload or other behaviour as you choose.

When GDB starts it will now look in that folder for a .gdbinit file and load it.

ARAT
  • 884
  • 1
  • 14
  • 35