You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

345 lines
16KB

  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-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Mode Options (Debugging with GDB)</title>
  17. <meta name="description" content="Mode Options (Debugging with GDB)">
  18. <meta name="keywords" content="Mode Options (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Invoking-GDB.html#Invoking-GDB" rel="up" title="Invoking GDB">
  26. <link href="Startup.html#Startup" rel="next" title="Startup">
  27. <link href="File-Options.html#File-Options" rel="prev" title="File Options">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style: oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Mode-Options"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Startup.html#Startup" accesskey="n" rel="next">Startup</a>, Previous: <a href="File-Options.html#File-Options" accesskey="p" rel="prev">File 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>
  61. </div>
  62. <hr>
  63. <a name="Choosing-Modes"></a>
  64. <h4 class="subsection">2.1.2 Choosing Modes</h4>
  65. <p>You can run <small>GDB</small> in various alternative modes&mdash;for example, in
  66. batch mode or quiet mode.
  67. </p>
  68. <dl compact="compact">
  69. <dd><a name="g_t_002dnx"></a></dd>
  70. <dt><code>-nx</code></dt>
  71. <dt><code>-n</code></dt>
  72. <dd><a name="index-_002d_002dnx"></a>
  73. <a name="index-_002dn"></a>
  74. <p>Do not execute commands found in any initialization file.
  75. There are three init files, loaded in the following order:
  76. </p>
  77. <dl compact="compact">
  78. <dt><code><samp>system.gdbinit</samp></code></dt>
  79. <dd><p>This is the system-wide init file.
  80. Its location is specified with the <code>--with-system-gdbinit</code>
  81. configure option (see <a href="System_002dwide-configuration.html#System_002dwide-configuration">System-wide configuration</a>).
  82. It is loaded first when <small>GDB</small> starts, before command line options
  83. have been processed.
  84. </p></dd>
  85. <dt><code><samp>system.gdbinit.d</samp></code></dt>
  86. <dd><p>This is the system-wide init directory.
  87. Its location is specified with the <code>--with-system-gdbinit-dir</code>
  88. configure option (see <a href="System_002dwide-configuration.html#System_002dwide-configuration">System-wide configuration</a>).
  89. Files in this directory are loaded in alphabetical order immediately after
  90. system.gdbinit (if enabled) when <small>GDB</small> starts, before command line
  91. options have been processed. Files need to have a recognized scripting
  92. language extension (<samp>.py</samp>/<samp>.scm</samp>) or be named with a <samp>.gdb</samp>
  93. extension to be interpreted as regular <small>GDB</small> commands. <small>GDB</small>
  94. will not recurse into any subdirectories of this directory.
  95. </p></dd>
  96. <dt><code><samp>~/.gdbinit</samp></code></dt>
  97. <dd><p>This is the init file in your home directory.
  98. It is loaded next, after <samp>system.gdbinit</samp>, and before
  99. command options have been processed.
  100. </p></dd>
  101. <dt><code><samp>./.gdbinit</samp></code></dt>
  102. <dd><p>This is the init file in the current directory.
  103. It is loaded last, after command line options other than <code>-x</code> and
  104. <code>-ex</code> have been processed. Command line options <code>-x</code> and
  105. <code>-ex</code> are processed last, after <samp>./.gdbinit</samp> has been loaded.
  106. </p></dd>
  107. </dl>
  108. <p>For further documentation on startup processing, See <a href="Startup.html#Startup">Startup</a>.
  109. For documentation on how to write command files,
  110. See <a href="Command-Files.html#Command-Files">Command Files</a>.
  111. </p>
  112. <a name="g_t_002dnh"></a></dd>
  113. <dt><code>-nh</code></dt>
  114. <dd><a name="index-_002d_002dnh"></a>
  115. <p>Do not execute commands found in <samp>~/.gdbinit</samp>, the init file
  116. in your home directory.
  117. See <a href="Startup.html#Startup">Startup</a>.
  118. </p>
  119. </dd>
  120. <dt><code>-quiet</code></dt>
  121. <dt><code>-silent</code></dt>
  122. <dt><code>-q</code></dt>
  123. <dd><a name="index-_002d_002dquiet"></a>
  124. <a name="index-_002d_002dsilent"></a>
  125. <a name="index-_002dq"></a>
  126. <p>&ldquo;Quiet&rdquo;. Do not print the introductory and copyright messages. These
  127. messages are also suppressed in batch mode.
  128. </p>
  129. </dd>
  130. <dt><code>-batch</code></dt>
  131. <dd><a name="index-_002d_002dbatch"></a>
  132. <p>Run in batch mode. Exit with status <code>0</code> after processing all the
  133. command files specified with &lsquo;<samp>-x</samp>&rsquo; (and all commands from
  134. initialization files, if not inhibited with &lsquo;<samp>-n</samp>&rsquo;). Exit with
  135. nonzero status if an error occurs in executing the <small>GDB</small> commands
  136. in the command files. Batch mode also disables pagination, sets unlimited
  137. terminal width and height see <a href="Screen-Size.html#Screen-Size">Screen Size</a>, and acts as if <kbd>set confirm
  138. off</kbd> were in effect (see <a href="Messages_002fWarnings.html#Messages_002fWarnings">Messages/Warnings</a>).
  139. </p>
  140. <p>Batch mode may be useful for running <small>GDB</small> as a filter, for
  141. example to download and run a program on another computer; in order to
  142. make this more useful, the message
  143. </p>
  144. <div class="smallexample">
  145. <pre class="smallexample">Program exited normally.
  146. </pre></div>
  147. <p>(which is ordinarily issued whenever a program running under
  148. <small>GDB</small> control terminates) is not issued when running in batch
  149. mode.
  150. </p>
  151. </dd>
  152. <dt><code>-batch-silent</code></dt>
  153. <dd><a name="index-_002d_002dbatch_002dsilent"></a>
  154. <p>Run in batch mode exactly like &lsquo;<samp>-batch</samp>&rsquo;, but totally silently. All
  155. <small>GDB</small> output to <code>stdout</code> is prevented (<code>stderr</code> is
  156. unaffected). This is much quieter than &lsquo;<samp>-silent</samp>&rsquo; and would be useless
  157. for an interactive session.
  158. </p>
  159. <p>This is particularly useful when using targets that give &lsquo;<samp>Loading section</samp>&rsquo;
  160. messages, for example.
  161. </p>
  162. <p>Note that targets that give their output via <small>GDB</small>, as opposed to
  163. writing directly to <code>stdout</code>, will also be made silent.
  164. </p>
  165. </dd>
  166. <dt><code>-return-child-result</code></dt>
  167. <dd><a name="index-_002d_002dreturn_002dchild_002dresult"></a>
  168. <p>The return code from <small>GDB</small> will be the return code from the child
  169. process (the process being debugged), with the following exceptions:
  170. </p>
  171. <ul>
  172. <li> <small>GDB</small> exits abnormally. E.g., due to an incorrect argument or an
  173. internal error. In this case the exit code is the same as it would have been
  174. without &lsquo;<samp>-return-child-result</samp>&rsquo;.
  175. </li><li> The user quits with an explicit value. E.g., &lsquo;<samp>quit 1</samp>&rsquo;.
  176. </li><li> The child process never runs, or is not allowed to terminate, in which case
  177. the exit code will be -1.
  178. </li></ul>
  179. <p>This option is useful in conjunction with &lsquo;<samp>-batch</samp>&rsquo; or &lsquo;<samp>-batch-silent</samp>&rsquo;,
  180. when <small>GDB</small> is being used as a remote program loader or simulator
  181. interface.
  182. </p>
  183. </dd>
  184. <dt><code>-nowindows</code></dt>
  185. <dt><code>-nw</code></dt>
  186. <dd><a name="index-_002d_002dnowindows"></a>
  187. <a name="index-_002dnw"></a>
  188. <p>&ldquo;No windows&rdquo;. If <small>GDB</small> comes with a graphical user interface
  189. (GUI) built in, then this option tells <small>GDB</small> to only use the command-line
  190. interface. If no GUI is available, this option has no effect.
  191. </p>
  192. </dd>
  193. <dt><code>-windows</code></dt>
  194. <dt><code>-w</code></dt>
  195. <dd><a name="index-_002d_002dwindows"></a>
  196. <a name="index-_002dw"></a>
  197. <p>If <small>GDB</small> includes a GUI, then this option requires it to be
  198. used if possible.
  199. </p>
  200. </dd>
  201. <dt><code>-cd <var>directory</var></code></dt>
  202. <dd><a name="index-_002d_002dcd"></a>
  203. <p>Run <small>GDB</small> using <var>directory</var> as its working directory,
  204. instead of the current directory.
  205. </p>
  206. </dd>
  207. <dt><code>-data-directory <var>directory</var></code></dt>
  208. <dt><code>-D <var>directory</var></code></dt>
  209. <dd><a name="index-_002d_002ddata_002ddirectory"></a>
  210. <a name="index-_002dD"></a>
  211. <p>Run <small>GDB</small> using <var>directory</var> as its data directory.
  212. The data directory is where <small>GDB</small> searches for its
  213. auxiliary files. See <a href="Data-Files.html#Data-Files">Data Files</a>.
  214. </p>
  215. </dd>
  216. <dt><code>-fullname</code></dt>
  217. <dt><code>-f</code></dt>
  218. <dd><a name="index-_002d_002dfullname"></a>
  219. <a name="index-_002df"></a>
  220. <p><small>GNU</small> Emacs sets this option when it runs <small>GDB</small> as a
  221. subprocess. It tells <small>GDB</small> to output the full file name and line
  222. number in a standard, recognizable fashion each time a stack frame is
  223. displayed (which includes each time your program stops). This
  224. recognizable format looks like two &lsquo;<samp>\032</samp>&rsquo; characters, followed by
  225. the file name, line number and character position separated by colons,
  226. and a newline. The Emacs-to-<small>GDB</small> interface program uses the two
  227. &lsquo;<samp>\032</samp>&rsquo; characters as a signal to display the source code for the
  228. frame.
  229. </p>
  230. </dd>
  231. <dt><code>-annotate <var>level</var></code></dt>
  232. <dd><a name="index-_002d_002dannotate"></a>
  233. <p>This option sets the <em>annotation level</em> inside <small>GDB</small>. Its
  234. effect is identical to using &lsquo;<samp>set annotate <var>level</var></samp>&rsquo;
  235. (see <a href="Annotations.html#Annotations">Annotations</a>). The annotation <var>level</var> controls how much
  236. information <small>GDB</small> prints together with its prompt, values of
  237. expressions, source lines, and other types of output. Level 0 is the
  238. normal, level 1 is for use when <small>GDB</small> is run as a subprocess of
  239. <small>GNU</small> Emacs, level 3 is the maximum annotation suitable for programs
  240. that control <small>GDB</small>, and level 2 has been deprecated.
  241. </p>
  242. <p>The annotation mechanism has largely been superseded by <small>GDB/MI</small>
  243. (see <a href="GDB_002fMI.html#GDB_002fMI">GDB/MI</a>).
  244. </p>
  245. </dd>
  246. <dt><code>--args</code></dt>
  247. <dd><a name="index-_002d_002dargs"></a>
  248. <p>Change interpretation of command line so that arguments following the
  249. executable file are passed as command line arguments to the inferior.
  250. This option stops option processing.
  251. </p>
  252. </dd>
  253. <dt><code>-baud <var>bps</var></code></dt>
  254. <dt><code>-b <var>bps</var></code></dt>
  255. <dd><a name="index-_002d_002dbaud"></a>
  256. <a name="index-_002db"></a>
  257. <p>Set the line speed (baud rate or bits per second) of any serial
  258. interface used by <small>GDB</small> for remote debugging.
  259. </p>
  260. </dd>
  261. <dt><code>-l <var>timeout</var></code></dt>
  262. <dd><a name="index-_002dl"></a>
  263. <p>Set the timeout (in seconds) of any communication used by <small>GDB</small>
  264. for remote debugging.
  265. </p>
  266. </dd>
  267. <dt><code>-tty <var>device</var></code></dt>
  268. <dt><code>-t <var>device</var></code></dt>
  269. <dd><a name="index-_002d_002dtty"></a>
  270. <a name="index-_002dt"></a>
  271. <p>Run using <var>device</var> for your program&rsquo;s standard input and output.
  272. </p>
  273. </dd>
  274. <dt><code>-tui</code></dt>
  275. <dd><a name="index-_002d_002dtui"></a>
  276. <p>Activate the <em>Text User Interface</em> when starting. The Text User
  277. Interface manages several text windows on the terminal, showing
  278. source, assembly, registers and <small>GDB</small> command outputs
  279. (see <a href="TUI.html#TUI"><small>GDB</small> Text User Interface</a>). Do not use this
  280. option if you run <small>GDB</small> from Emacs (see <a href="Emacs.html#Emacs">Using <small>GDB</small> under <small>GNU</small> Emacs</a>).
  281. </p>
  282. </dd>
  283. <dt><code>-interpreter <var>interp</var></code></dt>
  284. <dd><a name="index-_002d_002dinterpreter"></a>
  285. <p>Use the interpreter <var>interp</var> for interface with the controlling
  286. program or device. This option is meant to be set by programs which
  287. communicate with <small>GDB</small> using it as a back end.
  288. See <a href="Interpreters.html#Interpreters">Command Interpreters</a>.
  289. </p>
  290. <p>&lsquo;<samp>--interpreter=mi</samp>&rsquo; (or &lsquo;<samp>--interpreter=mi3</samp>&rsquo;) causes
  291. <small>GDB</small> to use the <em><small>GDB/MI</small> interface</em> version 3 (see <a href="GDB_002fMI.html#GDB_002fMI">The <small>GDB/MI</small> Interface</a>) included since <small>GDB</small> version 9.1. <small>GDB/MI</small>
  292. version 2 (<code>mi2</code>), included in <small>GDB</small> 6.0 and version 1 (<code>mi1</code>),
  293. included in <small>GDB</small> 5.3, are also available. Earlier <small>GDB/MI</small>
  294. interfaces are no longer supported.
  295. </p>
  296. </dd>
  297. <dt><code>-write</code></dt>
  298. <dd><a name="index-_002d_002dwrite"></a>
  299. <p>Open the executable and core files for both reading and writing. This
  300. is equivalent to the &lsquo;<samp>set write on</samp>&rsquo; command inside <small>GDB</small>
  301. (see <a href="Patching.html#Patching">Patching</a>).
  302. </p>
  303. </dd>
  304. <dt><code>-statistics</code></dt>
  305. <dd><a name="index-_002d_002dstatistics"></a>
  306. <p>This option causes <small>GDB</small> to print statistics about time and
  307. memory usage after it completes each command and returns to the prompt.
  308. </p>
  309. </dd>
  310. <dt><code>-version</code></dt>
  311. <dd><a name="index-_002d_002dversion"></a>
  312. <p>This option causes <small>GDB</small> to print its version number and
  313. no-warranty blurb, and exit.
  314. </p>
  315. </dd>
  316. <dt><code>-configuration</code></dt>
  317. <dd><a name="index-_002d_002dconfiguration"></a>
  318. <p>This option causes <small>GDB</small> to print details about its build-time
  319. configuration parameters, and then exit. These details can be
  320. important when reporting <small>GDB</small> bugs (see <a href="GDB-Bugs.html#GDB-Bugs">GDB Bugs</a>).
  321. </p>
  322. </dd>
  323. </dl>
  324. <hr>
  325. <div class="header">
  326. <p>
  327. Next: <a href="Startup.html#Startup" accesskey="n" rel="next">Startup</a>, Previous: <a href="File-Options.html#File-Options" accesskey="p" rel="prev">File 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>
  328. </div>
  329. </body>
  330. </html>