Go to the previous, next section.
You can alter the way GDB interacts with you by using
the set
command. For commands controlling how GDB displays
data, see section Print settings; other settings are described here.
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.
set prompt newprompt
show prompt
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. Advantages are emacs
-style
or vi
-style inline editing of commands, csh
-like history
substitution, 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
set editing off
show editing
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.
set history filename fname
GDBHISTFILE
, or to
`./.gdb_history' if this variable is not set.
set history save
set history save on
set history filename
command. By default, this option is disabled.
set history save off
set history size size
HISTSIZE
, or to 256 if this variable is not set.
History expansion assigns special meaning to the character !.
Since ! is also the logical not operator in C, history expansion
is off by default. If you decide to enable history expansion with the
set history expansion on
command, you may sometimes need to
follow ! (when it is used as logical not, in an expression) with
a space or a tab to prevent it from being expanded. The readline
history facilities do not attempt substitution on the strings
!= and !(, even when history expansion is enabled.
The commands to control history expansion are:
set history expansion on
set history expansion
set history expansion off
The readline code comes with more complete documentation of
editing and history expansion features. Users unfamiliar with emacs
or vi
may wish to read it.
show history
show history filename
show history save
show history size
show history expansion
show history
by itself displays all four states.
show commands
show commands n
show commands +
Certain commands to GDB may produce large amounts of information output to the screen. To help you read all of it, GDB pauses and asks you for input at the end of each page of output. Type RET when you want to continue the output, or q to discard the remaining output. Also, the screen width setting determines when to wrap lines of output. Depending on what is being printed, GDB tries to break the line at a readable place, rather than simply letting it overflow onto the following line.
Normally GDB knows the size of the screen from the termcap data base
together with the value of the TERM
environment variable and the
stty rows
and stty cols
settings. If this is not correct,
you can override it with the set height
and set
width
commands:
set height lpp
show height
set width cpl
show width
set
commands specify a screen height of lpp lines and
a screen width of cpl characters. The associated show
commands display the current settings.
If you specify a height of zero lines, GDB does not pause during output no matter how long the output is. This is useful if output is to a file or to an editor buffer.
Likewise, you can specify `set width 0' to prevent GDB from wrapping its output.
You can always enter numbers in octal, decimal, or hexadecimal in GDB by
the usual conventions: octal numbers begin with `0', decimal
numbers end with `.', and hexadecimal numbers begin with `0x'.
Numbers that begin with none of these are, by default, entered in base
10; likewise, the default display for numbers--when no particular
format is specified--is base 10. You can change the default base for
both input and output with the set radix
command.
set radix base
set radix 012 set radix 10. set radix 0xa
sets the base to decimal. On the other hand, `set radix 10' leaves the radix unchanged no matter what it was.
show radix
By default, GDB is silent about its inner workings. If you are running
on a slow machine, you may want to use the set verbose
command.
It makes GDB tell you when it does a lengthy internal operation, so
you will not think it has crashed.
Currently, the messages controlled by set verbose
are those
which announce that the symbol table for a source file is being read;
see symbol-file
in section Commands to specify files.
set verbose on
set verbose off
show verbose
set verbose
is on or off.
By default, if GDB encounters bugs in the symbol table of an object file, it is silent; but if you are debugging a compiler, you may find this information useful (see section Errors reading symbol files).
set complaints limit
show complaints
By default, GDB is cautious, and asks what sometimes seems to be a lot of stupid questions to confirm certain commands. For example, if you try to run a program which is already running:
(gdb) run The program being debugged has been started already. Start it from the beginning? (y or n)
If you are willing to unflinchingly face the consequences of your own commands, you can disable this "feature":
set confirm off
set confirm on
show confirm
Some systems allow individual object files that make up your program to be replaced without stopping and restarting your program. For example, in VxWorks you can simply recompile a defective object file and keep on running. If you are running on one of these systems, you can allow GDB to reload the symbols for automatically relinked modules:
set symbol-reloading on
set symbol-reloading off
symbol-reloading
off, since otherwise GDB may discard symbols
when linking large programs, that may contain several modules (from
different directories or libraries) with the same name.
show symbol-reloading
on
or off
setting.
Go to the previous, next section.