Debugging with GDB (September 2007)
Chapter 17: Controlling GDB 247
show commands
Display the last ten commands in the command history.
show commands n
Print ten commands centered on command number n.
show commands +
Print ten commands just after the commands last printed.
17.4 Setting the GDB Screen Size
Certain commands to GDB may produce large amounts of information output to the
screen. To help you read all of it, GDB pauses and as ks you for input at the end of each
page of output. Type
h
RET
i
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 terminal driver software. For
example, on Unix, GDB uses 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
These 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.
17.5 Supported Number Formats
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
numb e rs 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 input-radix base
Set the default base for numeric input. Supported choices for base are decimal
8, 10, or 16. base must itself be specified either unambiguously or using the
current default radix; for example, any of