1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Copyright (C) 1988-2021 Free Software Foundation, Inc.
4
5Permission is granted to copy, distribute and/or modify this document
6under the terms of the GNU Free Documentation License, Version 1.3 or
7any later version published by the Free Software Foundation; with the
8Invariant Sections being "Free Software" and "Free Software Needs
9Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
10and with the Back-Cover Texts as in (a) below.
11
12(a) The FSF's Back-Cover Text is: "You are free to copy and modify
13this GNU Manual.  Buying copies from GNU Press supports the FSF in
14developing GNU and promoting software freedom." -->
15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
16<head>
17<title>Debugging with GDB: File Options</title>
18
19<meta name="description" content="Debugging with GDB: File Options">
20<meta name="keywords" content="Debugging with GDB: File Options">
21<meta name="resource-type" content="document">
22<meta name="distribution" content="global">
23<meta name="Generator" content="makeinfo">
24<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
25<link href="index.html#Top" rel="start" title="Top">
26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
28<link href="Invoking-GDB.html#Invoking-GDB" rel="up" title="Invoking GDB">
29<link href="Mode-Options.html#Mode-Options" rel="next" title="Mode Options">
30<link href="Invoking-GDB.html#Invoking-GDB" rel="previous" title="Invoking GDB">
31<style type="text/css">
32<!--
33a.summary-letter {text-decoration: none}
34blockquote.smallquotation {font-size: smaller}
35div.display {margin-left: 3.2em}
36div.example {margin-left: 3.2em}
37div.indentedblock {margin-left: 3.2em}
38div.lisp {margin-left: 3.2em}
39div.smalldisplay {margin-left: 3.2em}
40div.smallexample {margin-left: 3.2em}
41div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
42div.smalllisp {margin-left: 3.2em}
43kbd {font-style:oblique}
44pre.display {font-family: inherit}
45pre.format {font-family: inherit}
46pre.menu-comment {font-family: serif}
47pre.menu-preformatted {font-family: serif}
48pre.smalldisplay {font-family: inherit; font-size: smaller}
49pre.smallexample {font-size: smaller}
50pre.smallformat {font-family: inherit; font-size: smaller}
51pre.smalllisp {font-size: smaller}
52span.nocodebreak {white-space:nowrap}
53span.nolinebreak {white-space:nowrap}
54span.roman {font-family:serif; font-weight:normal}
55span.sansserif {font-family:sans-serif; font-weight:normal}
56ul.no-bullet {list-style: none}
57-->
58</style>
59
60
61</head>
62
63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
64<a name="File-Options"></a>
65<div class="header">
66<p>
67Next: <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>
68</div>
69<hr>
70<a name="Choosing-Files"></a>
71<h4 class="subsection">2.1.1 Choosing Files</h4>
72
73<p>When <small>GDB</small> starts, it reads any arguments other than options as
74specifying an executable file and core file (or process ID).  This is
75the same as if the arguments were specified by the &lsquo;<samp>-se</samp>&rsquo; and
76&lsquo;<samp>-c</samp>&rsquo; (or &lsquo;<samp>-p</samp>&rsquo;) options respectively.  (<small>GDB</small> reads the
77first argument that does not have an associated option flag as
78equivalent to the &lsquo;<samp>-se</samp>&rsquo; option followed by that argument; and the
79second argument that does not have an associated option flag, if any, as
80equivalent to the &lsquo;<samp>-c</samp>&rsquo;/&lsquo;<samp>-p</samp>&rsquo; option followed by that argument.)
81If the second argument begins with a decimal digit, <small>GDB</small> will
82first attempt to attach to it as a process, and if that fails, attempt
83to open it as a corefile.  If you have a corefile whose name begins with
84a digit, you can prevent <small>GDB</small> from treating it as a pid by
85prefixing it with <samp>./</samp>, e.g. <samp>./12345</samp>.
86</p>
87<p>If <small>GDB</small> has not been configured to included core file support,
88such as for most embedded targets, then it will complain about a second
89argument and ignore it.
90</p>
91<p>Many options have both long and short forms; both are shown in the
92following list.  <small>GDB</small> also recognizes the long forms if you truncate
93them, so long as enough of the option is present to be unambiguous.
94(If you prefer, you can flag option arguments with &lsquo;<samp>--</samp>&rsquo; rather
95than &lsquo;<samp>-</samp>&rsquo;, though we illustrate the more usual convention.)
96</p>
97
98<dl compact="compact">
99<dt><code>-symbols <var>file</var></code></dt>
100<dt><code>-s <var>file</var></code></dt>
101<dd><a name="index-_002d_002dsymbols"></a>
102<a name="index-_002ds"></a>
103<p>Read symbol table from file <var>file</var>.
104</p>
105</dd>
106<dt><code>-exec <var>file</var></code></dt>
107<dt><code>-e <var>file</var></code></dt>
108<dd><a name="index-_002d_002dexec"></a>
109<a name="index-_002de"></a>
110<p>Use file <var>file</var> as the executable file to execute when appropriate,
111and for examining pure data in conjunction with a core dump.
112</p>
113</dd>
114<dt><code>-se <var>file</var></code></dt>
115<dd><a name="index-_002d_002dse"></a>
116<p>Read symbol table from file <var>file</var> and use it as the executable
117file.
118</p>
119</dd>
120<dt><code>-core <var>file</var></code></dt>
121<dt><code>-c <var>file</var></code></dt>
122<dd><a name="index-_002d_002dcore"></a>
123<a name="index-_002dc"></a>
124<p>Use file <var>file</var> as a core dump to examine.
125</p>
126</dd>
127<dt><code>-pid <var>number</var></code></dt>
128<dt><code>-p <var>number</var></code></dt>
129<dd><a name="index-_002d_002dpid"></a>
130<a name="index-_002dp"></a>
131<p>Connect to process ID <var>number</var>, as with the <code>attach</code> command.
132</p>
133</dd>
134<dt><code>-command <var>file</var></code></dt>
135<dt><code>-x <var>file</var></code></dt>
136<dd><a name="index-_002d_002dcommand"></a>
137<a name="index-_002dx"></a>
138<p>Execute commands from file <var>file</var>.  The contents of this file is
139evaluated exactly as the <code>source</code> command would.
140See <a href="Command-Files.html#Command-Files">Command files</a>.
141</p>
142</dd>
143<dt><code>-eval-command <var>command</var></code></dt>
144<dt><code>-ex <var>command</var></code></dt>
145<dd><a name="index-_002d_002deval_002dcommand"></a>
146<a name="index-_002dex"></a>
147<p>Execute a single <small>GDB</small> command.
148</p>
149<p>This option may be used multiple times to call multiple commands.  It may
150also be interleaved with &lsquo;<samp>-command</samp>&rsquo; as required.
151</p>
152<div class="smallexample">
153<pre class="smallexample">gdb -ex 'target sim' -ex 'load' \
154   -x setbreakpoints -ex 'run' a.out
155</pre></div>
156
157</dd>
158<dt><code>-init-command <var>file</var></code></dt>
159<dt><code>-ix <var>file</var></code></dt>
160<dd><a name="index-_002d_002dinit_002dcommand"></a>
161<a name="index-_002dix"></a>
162<p>Execute commands from file <var>file</var> before loading the inferior (but
163after loading gdbinit files).
164See <a href="Startup.html#Startup">Startup</a>.
165</p>
166</dd>
167<dt><code>-init-eval-command <var>command</var></code></dt>
168<dt><code>-iex <var>command</var></code></dt>
169<dd><a name="index-_002d_002dinit_002deval_002dcommand"></a>
170<a name="index-_002diex"></a>
171<p>Execute a single <small>GDB</small> command before loading the inferior (but
172after loading gdbinit files).
173See <a href="Startup.html#Startup">Startup</a>.
174</p>
175</dd>
176<dt><code>-directory <var>directory</var></code></dt>
177<dt><code>-d <var>directory</var></code></dt>
178<dd><a name="index-_002d_002ddirectory"></a>
179<a name="index-_002dd"></a>
180<p>Add <var>directory</var> to the path to search for source and script files.
181</p>
182</dd>
183<dt><code>-r</code></dt>
184<dt><code>-readnow</code></dt>
185<dd><a name="index-_002d_002dreadnow"></a>
186<a name="index-_002dr"></a>
187<p>Read each symbol file&rsquo;s entire symbol table immediately, rather than
188the default, which is to read it incrementally as it is needed.
189This makes startup slower, but makes future operations faster.
190</p>
191</dd>
192<dt><code>--readnever</code></dt>
193<dd><a name="g_t_002d_002dreadnever"></a><a name="index-_002d_002dreadnever_002c-command_002dline-option"></a>
194<p>Do not read each symbol file&rsquo;s symbolic debug information.  This makes
195startup faster but at the expense of not being able to perform
196symbolic debugging.  DWARF unwind information is also not read,
197meaning backtraces may become incomplete or inaccurate.  One use of
198this is when a user simply wants to do the following sequence: attach,
199dump core, detach.  Loading the debugging information in this case is
200an unnecessary cause of delay.
201</p></dd>
202</dl>
203
204<hr>
205<div class="header">
206<p>
207Next: <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>
208</div>
209
210
211
212</body>
213</html>
214