Files
2024-02-19 00:21:47 -05:00

647 lines
26 KiB
HTML

<HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Created on November, 11 2002 by texi2html 1.64 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
-->
<HEAD>
<TITLE>Debugging with GDB: Invocation</TITLE>
<META NAME="description" CONTENT="Debugging with GDB: Invocation">
<META NAME="keywords" CONTENT="Debugging with GDB: Invocation">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.64">
</HEAD>
<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<A NAME="SEC6"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_2.html#SEC5"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC7"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_4.html#SEC12"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_4.html#SEC12"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_35.html#SEC643">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H1> 2. Getting In and Out of GDB </H1>
<!--docid::SEC6::-->
<P>
This chapter discusses how to start GDB, and how to get out of it.
The essentials are:
<UL>
<LI>
type <SAMP>`gdb'</SAMP> to start GDB.
<LI>
type <KBD>quit</KBD> or <KBD>C-d</KBD> to exit.
</UL>
<P>
<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_3.html#SEC7">2.1 Invoking GDB</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to start GDB</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_3.html#SEC10">2.2 Quitting GDB</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to quit GDB</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_3.html#SEC11">2.3 Shell commands</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to use shell commands inside GDB</TD></TR>
</TABLE></BLOCKQUOTE>
<P>
<A NAME="Invoking GDB"></A>
<HR SIZE="6">
<A NAME="SEC7"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC6"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC8"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC6"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC6"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC10"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_35.html#SEC643">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 2.1 Invoking GDB </H2>
<!--docid::SEC7::-->
<P>
Invoke GDB by running the program <CODE>gdb</CODE>. Once started,
GDB reads commands from the terminal until you tell it to exit.
</P><P>
You can also run <CODE>gdb</CODE> with a variety of arguments and options,
to specify more of your debugging environment at the outset.
</P><P>
The command-line options described here are designed
to cover a variety of situations; in some environments, some of these
options may effectively be unavailable.
</P><P>
The most usual way to start GDB is with one argument,
specifying an executable program:
</P><P>
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>gdb <VAR>program</VAR>
</FONT></pre></td></tr></table></P><P>
You can also start with both an executable program and a core file
specified:
</P><P>
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>gdb <VAR>program</VAR> <VAR>core</VAR>
</FONT></pre></td></tr></table></P><P>
You can, instead, specify a process ID as a second argument, if you want
to debug a running process:
</P><P>
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>gdb <VAR>program</VAR> 1234
</FONT></pre></td></tr></table></P><P>
would attach GDB to process <CODE>1234</CODE> (unless you also have a file
named <TT>`1234'</TT>; GDB does check for a core file first).
</P><P>
Taking advantage of the second command-line argument requires a fairly
complete operating system; when you use GDB as a remote
debugger attached to a bare board, there may not be any notion of
"process", and there is often no way to get a core dump. GDB
will warn you if it is unable to attach or to read core dumps.
</P><P>
You can optionally have <CODE>gdb</CODE> pass any arguments after the
executable file to the inferior using <CODE>--args</CODE>. This option stops
option processing.
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>gdb --args gcc -O2 -c foo.c
</FONT></pre></td></tr></table>This will cause <CODE>gdb</CODE> to debug <CODE>gcc</CODE>, and to set
<CODE>gcc</CODE>'s command-line arguments (see section <A HREF="gdb_5.html#SEC19">4.3 Your program's arguments</A>) to <SAMP>`-O2 -c foo.c'</SAMP>.
</P><P>
You can run <CODE>gdb</CODE> without printing the front material, which describes
GDB's non-warranty, by specifying <CODE>-silent</CODE>:
</P><P>
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>gdb -silent
</FONT></pre></td></tr></table></P><P>
You can further control how GDB starts up by using command-line
options. GDB itself can remind you of the options available.
</P><P>
Type
</P><P>
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>gdb -help
</FONT></pre></td></tr></table></P><P>
to display all available options and briefly describe their use
(<SAMP>`gdb -h'</SAMP> is a shorter equivalent).
</P><P>
All options and command line arguments you give are processed
in sequential order. The order makes a difference when the
<SAMP>`-x'</SAMP> option is used.
</P><P>
<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_3.html#SEC8">2.1.1 Choosing files</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_3.html#SEC9">2.1.2 Choosing modes</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
</TABLE></BLOCKQUOTE>
<P>
<A NAME="File Options"></A>
<HR SIZE="6">
<A NAME="SEC8"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC7"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC9"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC6"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC7"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC10"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_35.html#SEC643">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 2.1.1 Choosing files </H3>
<!--docid::SEC8::-->
<P>
When GDB starts, it reads any arguments other than options as
specifying an executable file and core file (or process ID). This is
the same as if the arguments were specified by the <SAMP>`-se'</SAMP> and
<SAMP>`-c'</SAMP> (or <SAMP>`-p'</SAMP> options respectively. (GDB reads the
first argument that does not have an associated option flag as
equivalent to the <SAMP>`-se'</SAMP> option followed by that argument; and the
second argument that does not have an associated option flag, if any, as
equivalent to the <SAMP>`-c'</SAMP>/<SAMP>`-p'</SAMP> option followed by that argument.)
If the second argument begins with a decimal digit, GDB will
first attempt to attach to it as a process, and if that fails, attempt
to open it as a corefile. If you have a corefile whose name begins with
a digit, you can prevent GDB from treating it as a pid by
prefixing it with <TT>`./'</TT>, eg. <TT>`./12345'</TT>.
</P><P>
If GDB has not been configured to included core file support,
such as for most embedded targets, then it will complain about a second
argument and ignore it.
</P><P>
Many options have both long and short forms; both are shown in the
following list. GDB also recognizes the long forms if you truncate
them, so long as enough of the option is present to be unambiguous.
(If you prefer, you can flag option arguments with <SAMP>`--'</SAMP> rather
than <SAMP>`-'</SAMP>, though we illustrate the more usual convention.)
</P><P>
<DL COMPACT>
<DT><CODE>-symbols <VAR>file</VAR></CODE>
<DD><DT><CODE>-s <VAR>file</VAR></CODE>
<DD><A NAME="IDX4"></A>
<A NAME="IDX5"></A>
Read symbol table from file <VAR>file</VAR>.
<P>
<DT><CODE>-exec <VAR>file</VAR></CODE>
<DD><DT><CODE>-e <VAR>file</VAR></CODE>
<DD><A NAME="IDX6"></A>
<A NAME="IDX7"></A>
Use file <VAR>file</VAR> as the executable file to execute when appropriate,
and for examining pure data in conjunction with a core dump.
<P>
<DT><CODE>-se <VAR>file</VAR></CODE>
<DD><A NAME="IDX8"></A>
Read symbol table from file <VAR>file</VAR> and use it as the executable
file.
<P>
<DT><CODE>-core <VAR>file</VAR></CODE>
<DD><DT><CODE>-c <VAR>file</VAR></CODE>
<DD><A NAME="IDX9"></A>
<A NAME="IDX10"></A>
Use file <VAR>file</VAR> as a core dump to examine.
<P>
<DT><CODE>-c <VAR>number</VAR></CODE>
<DD><DT><CODE>-pid <VAR>number</VAR></CODE>
<DD><DT><CODE>-p <VAR>number</VAR></CODE>
<DD><A NAME="IDX11"></A>
<A NAME="IDX12"></A>
Connect to process ID <VAR>number</VAR>, as with the <CODE>attach</CODE> command.
If there is no such process, GDB will attempt to open a core
file named <VAR>number</VAR>.
<P>
<DT><CODE>-command <VAR>file</VAR></CODE>
<DD><DT><CODE>-x <VAR>file</VAR></CODE>
<DD><A NAME="IDX13"></A>
<A NAME="IDX14"></A>
Execute GDB commands from file <VAR>file</VAR>. See section <A HREF="gdb_21.html#SEC195">Command files</A>.
<P>
<DT><CODE>-directory <VAR>directory</VAR></CODE>
<DD><DT><CODE>-d <VAR>directory</VAR></CODE>
<DD><A NAME="IDX15"></A>
<A NAME="IDX16"></A>
Add <VAR>directory</VAR> to the path to search for source files.
<P>
<DT><CODE>-m</CODE>
<DD><DT><CODE>-mapped</CODE>
<DD><A NAME="IDX17"></A>
<A NAME="IDX18"></A>
<EM>Warning: this option depends on operating system facilities that are not
supported on all systems.</EM><BR>
If memory-mapped files are available on your system through the <CODE>mmap</CODE>
system call, you can use this option
to have GDB write the symbols from your
program into a reusable file in the current directory. If the program you are debugging is
called <TT>`/tmp/fred'</TT>, the mapped symbol file is <TT>`/tmp/fred.syms'</TT>.
Future GDB debugging sessions notice the presence of this file,
and can quickly map in symbol information from it, rather than reading
the symbol table from the executable program.
<P>
The <TT>`.syms'</TT> file is specific to the host machine where GDB
is run. It holds an exact image of the internal GDB symbol
table. It cannot be shared across multiple host platforms.
</P><P>
<DT><CODE>-r</CODE>
<DD><DT><CODE>-readnow</CODE>
<DD><A NAME="IDX19"></A>
<A NAME="IDX20"></A>
Read each symbol file's entire symbol table immediately, rather than
the default, which is to read it incrementally as it is needed.
This makes startup slower, but makes future operations faster.
<P>
</DL>
<P>
You typically combine the <CODE>-mapped</CODE> and <CODE>-readnow</CODE> options in
order to build a <TT>`.syms'</TT> file that contains complete symbol
information. (See section <A HREF="gdb_16.html#SEC128">Commands to specify files</A>, for information
on <TT>`.syms'</TT> files.) A simple GDB invocation to do nothing
but build a <TT>`.syms'</TT> file for future use is:
</P><P>
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>gdb -batch -nx -mapped -readnow programname
</FONT></pre></td></tr></table></P><P>
<A NAME="Mode Options"></A>
<HR SIZE="6">
<A NAME="SEC9"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC8"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC10"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC6"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC7"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC10"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_35.html#SEC643">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H3> 2.1.2 Choosing modes </H3>
<!--docid::SEC9::-->
<P>
You can run GDB in various alternative modes--for example, in
batch mode or quiet mode.
</P><P>
<DL COMPACT>
<DT><CODE>-nx</CODE>
<DD><DT><CODE>-n</CODE>
<DD><A NAME="IDX21"></A>
<A NAME="IDX22"></A>
Do not execute commands found in any initialization files. Normally,
GDB executes the commands in these files after all the command
options and arguments have been processed. See section <A HREF="gdb_21.html#SEC195">Command files</A>.
<P>
<DT><CODE>-quiet</CODE>
<DD><DT><CODE>-silent</CODE>
<DD><DT><CODE>-q</CODE>
<DD><A NAME="IDX23"></A>
<A NAME="IDX24"></A>
<A NAME="IDX25"></A>
"Quiet". Do not print the introductory and copyright messages. These
messages are also suppressed in batch mode.
<P>
<DT><CODE>-batch</CODE>
<DD><A NAME="IDX26"></A>
Run in batch mode. Exit with status <CODE>0</CODE> after processing all the
command files specified with <SAMP>`-x'</SAMP> (and all commands from
initialization files, if not inhibited with <SAMP>`-n'</SAMP>). Exit with
nonzero status if an error occurs in executing the GDB commands
in the command files.
<P>
Batch mode may be useful for running GDB as a filter, for
example to download and run a program on another computer; in order to
make this more useful, the message
</P><P>
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>Program exited normally.
</FONT></pre></td></tr></table></P><P>
(which is ordinarily issued whenever a program running under
GDB control terminates) is not issued when running in batch
mode.
</P><P>
<DT><CODE>-nowindows</CODE>
<DD><DT><CODE>-nw</CODE>
<DD><A NAME="IDX27"></A>
<A NAME="IDX28"></A>
"No windows". If GDB comes with a graphical user interface
(GUI) built in, then this option tells GDB to only use the command-line
interface. If no GUI is available, this option has no effect.
<P>
<DT><CODE>-windows</CODE>
<DD><DT><CODE>-w</CODE>
<DD><A NAME="IDX29"></A>
<A NAME="IDX30"></A>
If GDB includes a GUI, then this option requires it to be
used if possible.
<P>
<DT><CODE>-cd <VAR>directory</VAR></CODE>
<DD><A NAME="IDX31"></A>
Run GDB using <VAR>directory</VAR> as its working directory,
instead of the current directory.
<P>
<DT><CODE>-fullname</CODE>
<DD><DT><CODE>-f</CODE>
<DD><A NAME="IDX32"></A>
<A NAME="IDX33"></A>
GNU Emacs sets this option when it runs GDB as a
subprocess. It tells GDB to output the full file name and line
number in a standard, recognizable fashion each time a stack frame is
displayed (which includes each time your program stops). This
recognizable format looks like two <SAMP>`\032'</SAMP> characters, followed by
the file name, line number and character position separated by colons,
and a newline. The Emacs-to-GDB interface program uses the two
<SAMP>`\032'</SAMP> characters as a signal to display the source code for the
frame.
<P>
<DT><CODE>-epoch</CODE>
<DD><A NAME="IDX34"></A>
The Epoch Emacs-GDB interface sets this option when it runs
GDB as a subprocess. It tells GDB to modify its print
routines so as to allow Epoch to display values of expressions in a
separate window.
<P>
<DT><CODE>-annotate <VAR>level</VAR></CODE>
<DD><A NAME="IDX35"></A>
This option sets the <EM>annotation level</EM> inside GDB. Its
effect is identical to using <SAMP>`set annotate <VAR>level</VAR>'</SAMP>
(see section <A HREF="gdb_24.html#SEC204">23. GDB Annotations</A>).
Annotation level controls how much information does GDB print
together with its prompt, values of expressions, source lines, and other
types of output. Level 0 is the normal, level 1 is for use when
GDB is run as a subprocess of GNU Emacs, level 2 is the
maximum annotation suitable for programs that control GDB.
<P>
<DT><CODE>-async</CODE>
<DD><A NAME="IDX36"></A>
Use the asynchronous event loop for the command-line interface.
GDB processes all events, such as user keyboard input, via a
special event loop. This allows GDB to accept and process user
commands in parallel with the debugged process being
run<A NAME="DOCF1" HREF="gdb_fot.html#FOOT1">(1)</A>, so you don't need to wait for
control to return to GDB before you type the next command.
(<EM>Note:</EM> as of version 5.1, the target side of the asynchronous
operation is not yet in place, so <SAMP>`-async'</SAMP> does not work fully
yet.)
<P>
When the standard input is connected to a terminal device, GDB
uses the asynchronous event loop by default, unless disabled by the
<SAMP>`-noasync'</SAMP> option.
</P><P>
<DT><CODE>-noasync</CODE>
<DD><A NAME="IDX37"></A>
Disable the asynchronous event loop for the command-line interface.
<P>
<DT><CODE>--args</CODE>
<DD><A NAME="IDX38"></A>
Change interpretation of command line so that arguments following the
executable file are passed as command line arguments to the inferior.
This option stops option processing.
<P>
<DT><CODE>-baud <VAR>bps</VAR></CODE>
<DD><DT><CODE>-b <VAR>bps</VAR></CODE>
<DD><A NAME="IDX39"></A>
<A NAME="IDX40"></A>
Set the line speed (baud rate or bits per second) of any serial
interface used by GDB for remote debugging.
<P>
<DT><CODE>-tty <VAR>device</VAR></CODE>
<DD><DT><CODE>-t <VAR>device</VAR></CODE>
<DD><A NAME="IDX41"></A>
<A NAME="IDX42"></A>
Run using <VAR>device</VAR> for your program's standard input and output.
<P>
<DT><CODE>-tui</CODE>
<DD><A NAME="IDX43"></A>
Activate the Terminal User Interface when starting.
The Terminal User Interface manages several text windows on the terminal,
showing source, assembly, registers and GDB command outputs
(see section <A HREF="gdb_22.html#SEC197">GDB Text User Interface</A>).
Do not use this option if you run GDB from Emacs
(see section <A HREF="gdb_23.html#SEC203">Using GDB under GNU Emacs</A>).
<P>
<DT><CODE>-interpreter <VAR>interp</VAR></CODE>
<DD><A NAME="IDX44"></A>
Use the interpreter <VAR>interp</VAR> for interface with the controlling
program or device. This option is meant to be set by programs which
communicate with GDB using it as a back end.
<P>
<SAMP>`--interpreter=mi'</SAMP> (or <SAMP>`--interpreter=mi2'</SAMP>) causes
GDB to use the current <EM>GDB/MI interface</EM>
(see section <A HREF="gdb_25.html#SEC217">The GDB/MI Interface</A>). The previous GDB/MI
interface, included in GDB version 5.3, can be selected with
<SAMP>`--interpreter=mi1'</SAMP>. Earlier GDB/MI interfaces
are not supported.
</P><P>
<DT><CODE>-write</CODE>
<DD><A NAME="IDX45"></A>
Open the executable and core files for both reading and writing. This
is equivalent to the <SAMP>`set write on'</SAMP> command inside GDB
(see section <A HREF="gdb_15.html#SEC126">14.6 Patching programs</A>).
<P>
<DT><CODE>-statistics</CODE>
<DD><A NAME="IDX46"></A>
This option causes GDB to print statistics about time and
memory usage after it completes each command and returns to the prompt.
<P>
<DT><CODE>-version</CODE>
<DD><A NAME="IDX47"></A>
This option causes GDB to print its version number and
no-warranty blurb, and exit.
<P>
</DL>
<P>
<A NAME="Quitting GDB"></A>
<HR SIZE="6">
<A NAME="SEC10"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC9"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC11"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC11"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC6"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_4.html#SEC12"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_35.html#SEC643">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 2.2 Quitting GDB </H2>
<!--docid::SEC10::-->
<P>
<DL COMPACT>
<A NAME="IDX48"></A>
<A NAME="IDX49"></A>
<DT><CODE>quit [<VAR>expression</VAR>]</CODE>
<DD><DT><CODE>q</CODE>
<DD>To exit GDB, use the <CODE>quit</CODE> command (abbreviated
<CODE>q</CODE>), or type an end-of-file character (usually <KBD>C-d</KBD>). If you
do not supply <VAR>expression</VAR>, GDB will terminate normally;
otherwise it will terminate using the result of <VAR>expression</VAR> as the
error code.
</DL>
<P>
<A NAME="IDX50"></A>
An interrupt (often <KBD>C-c</KBD>) does not exit from GDB, but rather
terminates the action of any GDB command that is in progress and
returns to GDB command level. It is safe to type the interrupt
character at any time because GDB does not allow it to take effect
until a time when it is safe.
</P><P>
If you have been using GDB to control an attached process or
device, you can release it with the <CODE>detach</CODE> command
(see section <A HREF="gdb_5.html#SEC23">Debugging an already-running process</A>).
</P><P>
<A NAME="Shell Commands"></A>
<HR SIZE="6">
<A NAME="SEC11"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC10"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_4.html#SEC12"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC6"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC6"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_4.html#SEC12"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_35.html#SEC643">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 2.3 Shell commands </H2>
<!--docid::SEC11::-->
<P>
If you need to execute occasional shell commands during your
debugging session, there is no need to leave or suspend GDB; you can
just use the <CODE>shell</CODE> command.
</P><P>
<DL COMPACT>
<A NAME="IDX51"></A>
<A NAME="IDX52"></A>
<DT><CODE>shell <VAR>command string</VAR></CODE>
<DD>Invoke a standard shell to execute <VAR>command string</VAR>.
If it exists, the environment variable <CODE>SHELL</CODE> determines which
shell to run. Otherwise GDB uses the default shell
(<TT>`/bin/sh'</TT> on Unix systems, <TT>`COMMAND.COM'</TT> on MS-DOS, etc.).
</DL>
<P>
The utility <CODE>make</CODE> is often needed in development environments.
You do not have to use the <CODE>shell</CODE> command for this purpose in
GDB:
</P><P>
<DL COMPACT>
<A NAME="IDX53"></A>
<A NAME="IDX54"></A>
<DT><CODE>make <VAR>make-args</VAR></CODE>
<DD>Execute the <CODE>make</CODE> program with the specified
arguments. This is equivalent to <SAMP>`shell make <VAR>make-args</VAR>'</SAMP>.
</DL>
<P>
<A NAME="Commands"></A>
<HR SIZE="6">
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_3.html#SEC6"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_4.html#SEC12"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_35.html#SEC643">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
<address>
<p>Please send FSF &amp; GNU inquiries &amp; questions to <a
href="mailto:gnu@gnu.org">gnu@gnu.org</a>. There are also <a
href="http://www.gnu.org/home.html#ContactInfo">other ways to
contact</a> the FSF.</p>
<p>These pages are maintained by <a
href="http://www.gnu.org/software/gdb/">the GDB developers</a>.</p>
<p>Copyright Free Software Foundation, Inc., 59 Temple Place - Suite
330, Boston, MA 02111, USA.</p>
<p>Verbatim copying and distribution of this entire article is
permitted in any medium, provided this notice is preserved.</p>
</address>
This document was generated
by <I>GDB Administrator</I> on <I>November, 11 2002</I>
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
</BODY>
</HTML>