gdb_15.html   [plain text]


<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.51
     from /mnt/apple/gdb/source/gdb.apple/source/gdb/gdb/doc/gdb.texinfo on 23 November 1999 -->

<TITLE>Debugging with GDB - Controlling GDB</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="gdb_1.html">first</A>, <A HREF="gdb_14.html">previous</A>, <A HREF="gdb_16.html">next</A>, <A HREF="gdb_21.html">last</A> section, <A HREF="gdb_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC149" HREF="gdb_toc.html#TOC149">Controlling GDB</A></H1>

<P>
You can alter the way GDB interacts with you by using
the <CODE>set</CODE> command.  For commands controlling how GDB displays
data, see section <A HREF="gdb_9.html#SEC58">Print settings</A>; other settings are described 
here.

</P>



<H2><A NAME="SEC150" HREF="gdb_toc.html#TOC150">Prompt</A></H2>

<P>
<A NAME="IDX664"></A>

</P>
<P>
GDB indicates its readiness to read a command by printing a string
called the <STRONG>prompt</STRONG>.  This string is normally <SAMP>`(gdb)'</SAMP>.  You
can change the prompt string with the <CODE>set prompt</CODE> 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.

</P>
<P>
<EM>Note:</EM>  <CODE>set prompt</CODE> no longer adds 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.

</P>
<DL COMPACT>

<DT><CODE>set prompt <VAR>newprompt</VAR></CODE>
<DD>
<A NAME="IDX665"></A>
 
Directs GDB to use <VAR>newprompt</VAR> as its prompt string henceforth.

<A NAME="IDX666"></A>
<DT><CODE>show prompt</CODE>
<DD>
Prints a line of the form: <SAMP>`Gdb's prompt is: <VAR>your-prompt</VAR>'</SAMP>
</DL>



<H2><A NAME="SEC151" HREF="gdb_toc.html#TOC151">Command editing</A></H2>
<P>
<A NAME="IDX667"></A>
<A NAME="IDX668"></A>

</P>
<P>
GDB reads its input commands via the <STRONG>readline</STRONG> interface.  This
GNU library provides consistent behavior for programs which provide a
command line interface to the user.  Advantages are GNU Emacs-style
or <STRONG>vi</STRONG>-style inline editing of commands, <CODE>csh</CODE>-like history
substitution, and a storage and recall of command history across
debugging sessions.

</P>
<P>
You may control the behavior of command line editing in GDB with the
command <CODE>set</CODE>.

</P>
<DL COMPACT>

<DT><CODE>set editing</CODE>
<DD>
<A NAME="IDX669"></A>
 <A NAME="IDX670"></A>
 
<DT><CODE>set editing on</CODE>
<DD>
Enable command line editing (enabled by default).

<DT><CODE>set editing off</CODE>
<DD>
Disable command line editing.

<A NAME="IDX671"></A>
<DT><CODE>show editing</CODE>
<DD>
Show whether command line editing is enabled.
</DL>



<H2><A NAME="SEC152" HREF="gdb_toc.html#TOC152">Command history</A></H2>

<P>
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.

</P>
<DL COMPACT>

<DT><CODE>set history filename <VAR>fname</VAR></CODE>
<DD>
<A NAME="IDX672"></A>
 <A NAME="IDX673"></A>
 <A NAME="IDX674"></A>
 <A NAME="IDX675"></A>
 
Set the name of the GDB command history file to <VAR>fname</VAR>.
This is the file where GDB reads an initial command history
list, and where it writes the command history from this session when it
exits.  You can access this list through history expansion or through
the history command editing characters listed below.  This file defaults
to the value of the environment variable <CODE>GDBHISTFILE</CODE>, or to
<TT>`./.gdb_history'</TT> if this variable is not set.

<A NAME="IDX676"></A>
<A NAME="IDX677"></A>
<DT><CODE>set history save</CODE>
<DD>
<DT><CODE>set history save on</CODE>
<DD>
Record command history in a file, whose name may be specified with the
<CODE>set history filename</CODE> command.  By default, this option is disabled.

<DT><CODE>set history save off</CODE>
<DD>
Stop recording command history in a file.

<A NAME="IDX678"></A>
<A NAME="IDX679"></A>
<DT><CODE>set history size <VAR>size</VAR></CODE>
<DD>
Set the number of commands which GDB keeps in its history list.
This defaults to the value of the environment variable
<CODE>HISTSIZE</CODE>, or to 256 if this variable is not set.
</DL>

<P>
<A NAME="IDX680"></A>
History expansion assigns special meaning to the character <KBD>!</KBD>.

</P>
<P>
Since <KBD>!</KBD> is also the logical not operator in C, history expansion
is off by default. If you decide to enable history expansion with the
<CODE>set history expansion on</CODE> command, you may sometimes need to
follow <KBD>!</KBD> (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
<KBD>!=</KBD> and <KBD>!(</KBD>, even when history expansion is enabled.

</P>
<P>
The commands to control history expansion are:

</P>
<DL COMPACT>

<DT><CODE>set history expansion on</CODE>
<DD>
<A NAME="IDX681"></A>
 
<DT><CODE>set history expansion</CODE>
<DD>
Enable history expansion.  History expansion is off by default.

<DT><CODE>set history expansion off</CODE>
<DD>
Disable history expansion.

The readline code comes with more complete documentation of
editing and history expansion features.  Users unfamiliar with GNU Emacs
or <CODE>vi</CODE> may wish to read it.

<A NAME="IDX682"></A>
<DT><CODE>show history</CODE>
<DD>
<DT><CODE>show history filename</CODE>
<DD>
<DT><CODE>show history save</CODE>
<DD>
<DT><CODE>show history size</CODE>
<DD>
<DT><CODE>show history expansion</CODE>
<DD>
These commands display the state of the GDB history parameters.
<CODE>show history</CODE> by itself displays all four states.
</DL>

<DL COMPACT>

<DT><CODE>show commands</CODE>
<DD>
<A NAME="IDX683"></A>
 
Display the last ten commands in the command history.

<DT><CODE>show commands <VAR>n</VAR></CODE>
<DD>
Print ten commands centered on command number <VAR>n</VAR>.

<DT><CODE>show commands +</CODE>
<DD>
Print ten commands just after the commands last printed.
</DL>



<H2><A NAME="SEC153" HREF="gdb_toc.html#TOC153">Screen size</A></H2>
<P>
<A NAME="IDX684"></A>
<A NAME="IDX685"></A>

</P>
<P>
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 <KBD>RET</KBD> when you want to continue the output, or <KBD>q</KBD>
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.

</P>
<P>
Normally GDB knows the size of the screen from the termcap data base
together with the value of the <CODE>TERM</CODE> environment variable and the
<CODE>stty rows</CODE> and <CODE>stty cols</CODE> settings. If this is not correct,
you can override it with the <CODE>set height</CODE> and <CODE>set
width</CODE> commands:

</P>
<DL COMPACT>

<DT><CODE>set height <VAR>lpp</VAR></CODE>
<DD>
<A NAME="IDX686"></A>
 <A NAME="IDX687"></A>
 <A NAME="IDX688"></A>
 <A NAME="IDX689"></A>
 
<DT><CODE>show height</CODE>
<DD>
<DT><CODE>set width <VAR>cpl</VAR></CODE>
<DD>
<DT><CODE>show width</CODE>
<DD>
These <CODE>set</CODE> commands specify a screen height of <VAR>lpp</VAR> lines and
a screen width of <VAR>cpl</VAR> characters.  The associated <CODE>show</CODE>
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 <SAMP>`set width 0'</SAMP> to prevent GDB
from wrapping its output.
</DL>



<H2><A NAME="SEC154" HREF="gdb_toc.html#TOC154">Numbers</A></H2>
<P>
<A NAME="IDX690"></A>
<A NAME="IDX691"></A>

</P>
<P>
You can always enter numbers in octal, decimal, or hexadecimal in GDB by
the usual conventions: octal numbers begin with <SAMP>`0'</SAMP>, decimal
numbers end with <SAMP>`.'</SAMP>, and hexadecimal numbers begin with <SAMP>`0x'</SAMP>.
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 <CODE>set radix</CODE> command.

</P>
<DL COMPACT>

<DT><CODE>set input-radix <VAR>base</VAR></CODE>
<DD>
<A NAME="IDX692"></A>
 
Set the default base for numeric input.  Supported choices
for <VAR>base</VAR> are decimal 8, 10, or 16.  <VAR>base</VAR> must itself be
specified either unambiguously or using the current default radix; for
example, any of


<PRE>
set radix 012
set radix 10.
set radix 0xa
</PRE>

sets the base to decimal.  On the other hand, <SAMP>`set radix 10'</SAMP>
leaves the radix unchanged no matter what it was.

<A NAME="IDX693"></A>
<DT><CODE>set output-radix <VAR>base</VAR></CODE>
<DD>
Set the default base for numeric display.  Supported choices
for <VAR>base</VAR> are decimal 8, 10, or 16.  <VAR>base</VAR> must itself be
specified either unambiguously or using the current default radix.

<A NAME="IDX694"></A>
<DT><CODE>show input-radix</CODE>
<DD>
Display the current default base for numeric input.

<A NAME="IDX695"></A>
<DT><CODE>show output-radix</CODE>
<DD>
Display the current default base for numeric display.
</DL>



<H2><A NAME="SEC155" HREF="gdb_toc.html#TOC155">Optional warnings and messages</A></H2>

<P>
By default, GDB is silent about its inner workings.  If you are running
on a slow machine, you may want to use the <CODE>set verbose</CODE> command.
This makes GDB tell you when it does a lengthy internal operation, so
you will not think it has crashed.

</P>
<P>
Currently, the messages controlled by <CODE>set verbose</CODE> are those
which announce that the symbol table for a source file is being read;
see <CODE>symbol-file</CODE> in section <A HREF="gdb_13.html#SEC110">Commands to specify files</A>.

</P>
<DL COMPACT>

<DT><CODE>set verbose on</CODE>
<DD>
<A NAME="IDX696"></A>
 
Enables GDB output of certain informational messages.

<DT><CODE>set verbose off</CODE>
<DD>
Disables GDB output of certain informational messages.

<A NAME="IDX697"></A>
<DT><CODE>show verbose</CODE>
<DD>
Displays whether <CODE>set verbose</CODE> is on or off.
</DL>

<P>
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 <A HREF="gdb_13.html#SEC111">Errors reading symbol files</A>).

</P>
<DL COMPACT>

<DT><CODE>set complaints <VAR>limit</VAR></CODE>
<DD>
<A NAME="IDX698"></A>
 
Permits GDB to output <VAR>limit</VAR> complaints about each type of unusual
symbols before becoming silent about the problem.  Set <VAR>limit</VAR> to
zero to suppress all complaints; set it to a large number to prevent
complaints from being suppressed.

<A NAME="IDX699"></A>
<DT><CODE>show complaints</CODE>
<DD>
Displays how many symbol complaints GDB is permitted to produce.
</DL>

<P>
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:

</P>

<PRE>
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n)
</PRE>

<P>
If you are willing to unflinchingly face the consequences of your own
commands, you can disable this "feature":

</P>
<DL COMPACT>

<DT><CODE>set confirm off</CODE>
<DD>
<A NAME="IDX700"></A>
 <A NAME="IDX701"></A>
 <A NAME="IDX702"></A>
 <A NAME="IDX703"></A>
 
Disables confirmation requests.

<DT><CODE>set confirm on</CODE>
<DD>
Enables confirmation requests (the default).

<A NAME="IDX704"></A>
<DT><CODE>show confirm</CODE>
<DD>
Displays state of confirmation requests.
</DL>

<P><HR><P>
Go to the <A HREF="gdb_1.html">first</A>, <A HREF="gdb_14.html">previous</A>, <A HREF="gdb_16.html">next</A>, <A HREF="gdb_21.html">last</A> section, <A HREF="gdb_toc.html">table of contents</A>.
</BODY>
</HTML>