3

~/.gdbinit is loaded when I start a remote debugging session from Qt Creator.

How can I force gdb to load a project specific .gdbinit file?

I've added this line to ~/.gdbinit

set auto-load local-gdbinit on

and added an additional .gdbinit file to my project directory and to the build output directory, but gdb seems to ignore both.

The manual for local-gdbinit says, that when set to on, gdb will look for a .gdbinit in the current directory. But I can't even figure out what the current directory is once Qt Creator starts gdb, so I'm pretty lost.

In another failed attempt (as found in this answer) I've added this to ~/.gdbinit

set auto-load safe-path /

Qt Creator version is 2.7.1, gdb version is 7.4-2012.04.

Community
  • 1
  • 1
huysentruitw
  • 27,376
  • 9
  • 90
  • 133
  • I guess the directory from where the debugger is run is set under "Projects", "Run" configuration in "Working directory" field. You should be able to find that out with `pwd` command in "Debugger Log" view in Qt Creator. – hluk Jun 26 '13 at 06:01
  • Since I'm remote debugging, "Working directory" points to a directory on the remote machine, so impossible gdb would load .gdbinit from there. `pwd` results in `/home/user/Documents` which is not project specific, any ideas on how I can tell Qt Creator to start gdb from the build output directory? – huysentruitw Jun 26 '13 at 06:44

1 Answers1

3

I'm doing remote debugging as well, and I looked at the "Debugger Log" view's output from pwd and the working directory was set to the directory I specified in the "Attach to Remote Debugger" dialog. I don't think the local working directory has anything to do with the remote working directory in this case.

I then just set up my ~/.gdbinit to add my source directory to the auto-load safe-path and auto-load local-gdbinit on, then put my project-specific custom .gdbinit in my source directory and it just worked, at least for me.

Lou
  • 31
  • 3