Mode-Options.html 16 KB

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