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.

2
  • 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. Commented Jun 26, 2013 at 6: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? Commented Jun 26, 2013 at 6:44

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

but you did put an absolute path in ~/.gdbinit then?
No, I didn't, except for the the auto-load safe-path, which was something along the lines of /home/me/workspaces

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.