# GDB Configuration **GDB init file** (`~/.gdbinit`) auto-loads on startup. Use it to set options, define commands, and configure debugging defaults. ```bash # ~/.gdbinit set print pretty on # pretty-print structures set pagination off # no paging (useful for scripts) set print address off # hide memory addresses in output set confirm off # no confirmation prompts set history save on # save command history set history size 10000 # keep 10k commands in history break main # set breakpoint at startup directory /path/to/sources # add source path define mycommand # define custom command print x print y backtrace end ``` `set print pretty on` formats structures with indentation, making them easier to read. Especially useful for nested structures or large arrays. `set pagination off` disables paging—GDB no longer stops output with `-- more --` prompts. Useful when running GDB in scripts or remote sessions. `set print address off` hides memory addresses in output. Makes output cleaner when addresses are not needed for debugging. `set confirm off` removes confirmation prompts (e.g., "Really delete all breakpoints?"). Useful for automation, but risk losing data if you accidentally delete something. `directory` adds source search paths. GDB uses these to find source files for display. If GDB can't find `main.c`, add `directory /path/to/project`. `define` creates custom commands. Define reusable debugging sequences. Commands defined in `~/.gdbinit` are available at every GDB session. Define debugging shortcuts for your project (e.g., `dumpstate` might print key variables and backtrace). History saves your commands across sessions. `history size` controls how many to keep (default 256). Useful for recalling previous debugging sessions. Create `~/.gdbinit` for your preferred settings. Start fresh sessions with your configuration automatically loaded.