Debugging with GDB (February 2008)

Table Of Contents
Chapter 17: Controlling GDB 249
17 Controlling GDB
You can alter the way GDB interacts with you by using the set command. For commands
controlling how GDB displays data, see Section 8.7 [Print settings], page 70. Other settings
are described here.
17.1 Setting the GDB Prompt
GDB indicates its readiness to read a command by printing a string called the prompt.
This string is normally ((gdb))’. You can change the prompt string with the set prompt
command. For instance, when debugging GDB with GDB, it is useful to change the prompt
in one of the GDB sessions so that you can always tell which one you are talking to.
Note: set prompt does not add a space for you after the prompt you set. This allows
you to set a prompt which ends in a space or a prompt that does not.
set prompt newprompt
Directs GDB to use newprompt as its prompt string henceforth.
show prompt
Prints a line of the form: Gdb’s prompt is: your-prompt
17.2 Setting Command Editing Options in GDB
GDB reads its input commands via the readline interface. This gnu library provides
consistent behavior for programs which provide a command line interface to the user. Ad-
vantages are gnu Emacs-style or vi-style inline editing of commands, csh-like history sub-
stitution, and a storage and recall of command history across debugging sessions.
You may control the behavior of command line editing in GDB with the command set.
set editing
set editing on
Enable command line editing (enabled by default).
set editing off
Disable command line editing.
show editing
Show whether command line editing is enabled.
17.3 Setting Command History Feature in GDB
GDB can keep track of the commands you type during your debugging sessions, so that
you can be certain of precisely what happened. Use these commands to manage the GDB
command history facility.
To make command history understand your vi key bindings you need to create a
~/.inputrc file with the following contents: