Search code examples
gdb

How to set default options for gdb?


I have several options that I set every time I open GDB, for instance:

set print thread-events off

Is there a way to set these options by default, perhaps something like a .gdb_rc file?


Solution

  • The initialization file for gdb is called .gdbinit. You can put your desired options in this file. They'll be automatically executed during gdb's startup.

    Example content:

    # set command line argument to "2"
    set args 2
    

    You may put the .gdbinit file into your $HOME or current directory. The latter overrides the settings in the global $HOME/.gdbinit file.