blob: 9651d000efa39e400f0fb7a85307b4480e09b0eb [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2015 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software" and "Free Software Needs
Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom." -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Debugging with GDB: File Options</title>
<meta name="description" content="Debugging with GDB: File Options">
<meta name="keywords" content="Debugging with GDB: File Options">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Invoking-GDB.html#Invoking-GDB" rel="up" title="Invoking GDB">
<link href="Mode-Options.html#Mode-Options" rel="next" title="Mode Options">
<link href="Invoking-GDB.html#Invoking-GDB" rel="prev" title="Invoking GDB">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="File-Options"></a>
<div class="header">
<p>
Next: <a href="Mode-Options.html#Mode-Options" accesskey="n" rel="next">Mode Options</a>, Up: <a href="Invoking-GDB.html#Invoking-GDB" accesskey="u" rel="up">Invoking GDB</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Choosing-Files"></a>
<h4 class="subsection">2.1.1 Choosing Files</h4>
<p>When <small>GDB</small> 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 &lsquo;<samp>-se</samp>&rsquo; and
&lsquo;<samp>-c</samp>&rsquo; (or &lsquo;<samp>-p</samp>&rsquo;) options respectively. (<small>GDB</small> reads the
first argument that does not have an associated option flag as
equivalent to the &lsquo;<samp>-se</samp>&rsquo; option followed by that argument; and the
second argument that does not have an associated option flag, if any, as
equivalent to the &lsquo;<samp>-c</samp>&rsquo;/&lsquo;<samp>-p</samp>&rsquo; option followed by that argument.)
If the second argument begins with a decimal digit, <small>GDB</small> 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 <small>GDB</small> from treating it as a pid by
prefixing it with <samp>./</samp>, e.g. <samp>./12345</samp>.
</p>
<p>If <small>GDB</small> 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. <small>GDB</small> 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 &lsquo;<samp>--</samp>&rsquo; rather
than &lsquo;<samp>-</samp>&rsquo;, though we illustrate the more usual convention.)
</p>
<dl compact="compact">
<dt><code>-symbols <var>file</var></code></dt>
<dt><code>-s <var>file</var></code></dt>
<dd><a name="index-_002d_002dsymbols"></a>
<a name="index-_002ds"></a>
<p>Read symbol table from file <var>file</var>.
</p>
</dd>
<dt><code>-exec <var>file</var></code></dt>
<dt><code>-e <var>file</var></code></dt>
<dd><a name="index-_002d_002dexec"></a>
<a name="index-_002de"></a>
<p>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>
</dd>
<dt><code>-se <var>file</var></code></dt>
<dd><a name="index-_002d_002dse"></a>
<p>Read symbol table from file <var>file</var> and use it as the executable
file.
</p>
</dd>
<dt><code>-core <var>file</var></code></dt>
<dt><code>-c <var>file</var></code></dt>
<dd><a name="index-_002d_002dcore"></a>
<a name="index-_002dc"></a>
<p>Use file <var>file</var> as a core dump to examine.
</p>
</dd>
<dt><code>-pid <var>number</var></code></dt>
<dt><code>-p <var>number</var></code></dt>
<dd><a name="index-_002d_002dpid"></a>
<a name="index-_002dp"></a>
<p>Connect to process ID <var>number</var>, as with the <code>attach</code> command.
</p>
</dd>
<dt><code>-command <var>file</var></code></dt>
<dt><code>-x <var>file</var></code></dt>
<dd><a name="index-_002d_002dcommand"></a>
<a name="index-_002dx"></a>
<p>Execute commands from file <var>file</var>. The contents of this file is
evaluated exactly as the <code>source</code> command would.
See <a href="Command-Files.html#Command-Files">Command files</a>.
</p>
</dd>
<dt><code>-eval-command <var>command</var></code></dt>
<dt><code>-ex <var>command</var></code></dt>
<dd><a name="index-_002d_002deval_002dcommand"></a>
<a name="index-_002dex"></a>
<p>Execute a single <small>GDB</small> command.
</p>
<p>This option may be used multiple times to call multiple commands. It may
also be interleaved with &lsquo;<samp>-command</samp>&rsquo; as required.
</p>
<div class="smallexample">
<pre class="smallexample">gdb -ex 'target sim' -ex 'load' \
-x setbreakpoints -ex 'run' a.out
</pre></div>
</dd>
<dt><code>-init-command <var>file</var></code></dt>
<dt><code>-ix <var>file</var></code></dt>
<dd><a name="index-_002d_002dinit_002dcommand"></a>
<a name="index-_002dix"></a>
<p>Execute commands from file <var>file</var> before loading the inferior (but
after loading gdbinit files).
See <a href="Startup.html#Startup">Startup</a>.
</p>
</dd>
<dt><code>-init-eval-command <var>command</var></code></dt>
<dt><code>-iex <var>command</var></code></dt>
<dd><a name="index-_002d_002dinit_002deval_002dcommand"></a>
<a name="index-_002diex"></a>
<p>Execute a single <small>GDB</small> command before loading the inferior (but
after loading gdbinit files).
See <a href="Startup.html#Startup">Startup</a>.
</p>
</dd>
<dt><code>-directory <var>directory</var></code></dt>
<dt><code>-d <var>directory</var></code></dt>
<dd><a name="index-_002d_002ddirectory"></a>
<a name="index-_002dd"></a>
<p>Add <var>directory</var> to the path to search for source and script files.
</p>
</dd>
<dt><code>-r</code></dt>
<dt><code>-readnow</code></dt>
<dd><a name="index-_002d_002dreadnow"></a>
<a name="index-_002dr"></a>
<p>Read each symbol file&rsquo;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>
</dd>
</dl>
<hr>
<div class="header">
<p>
Next: <a href="Mode-Options.html#Mode-Options" accesskey="n" rel="next">Mode Options</a>, Up: <a href="Invoking-GDB.html#Invoking-GDB" accesskey="u" rel="up">Invoking GDB</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>