1<html lang="en"> 2<head> 3<title>Mode Options - Debugging with GDB</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Debugging with GDB"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Invoking-GDB.html#Invoking-GDB" title="Invoking GDB"> 9<link rel="prev" href="File-Options.html#File-Options" title="File Options"> 10<link rel="next" href="Startup.html#Startup" title="Startup"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13Copyright (C) 1988-2013 Free Software Foundation, Inc. 14 15Permission is granted to copy, distribute and/or modify this document 16under the terms of the GNU Free Documentation License, Version 1.3 or 17any later version published by the Free Software Foundation; with the 18Invariant Sections being ``Free Software'' and ``Free Software Needs 19Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,'' 20and with the Back-Cover Texts as in (a) below. 21 22(a) The FSF's Back-Cover Text is: ``You are free to copy and modify 23this GNU Manual. Buying copies from GNU Press supports the FSF in 24developing GNU and promoting software freedom.'' 25--> 26<meta http-equiv="Content-Style-Type" content="text/css"> 27<style type="text/css"><!-- 28 pre.display { font-family:inherit } 29 pre.format { font-family:inherit } 30 pre.smalldisplay { font-family:inherit; font-size:smaller } 31 pre.smallformat { font-family:inherit; font-size:smaller } 32 pre.smallexample { font-size:smaller } 33 pre.smalllisp { font-size:smaller } 34 span.sc { font-variant:small-caps } 35 span.roman { font-family:serif; font-weight:normal; } 36 span.sansserif { font-family:sans-serif; font-weight:normal; } 37--></style> 38<link rel="stylesheet" type="text/css" href="../cs.css"> 39</head> 40<body> 41<div class="node"> 42<a name="Mode-Options"></a> 43<p> 44Next: <a rel="next" accesskey="n" href="Startup.html#Startup">Startup</a>, 45Previous: <a rel="previous" accesskey="p" href="File-Options.html#File-Options">File Options</a>, 46Up: <a rel="up" accesskey="u" href="Invoking-GDB.html#Invoking-GDB">Invoking GDB</a> 47<hr> 48</div> 49 50<h4 class="subsection">2.1.2 Choosing Modes</h4> 51 52<p>You can run <span class="sc">gdb</span> in various alternative modes—for example, in 53batch mode or quiet mode. 54 55 <dl> 56<a name="g_t_002dnx"></a><dt><code>-nx</code><dt><code>-n</code><dd><a name="index-g_t_0040code_007b_002d_002dnx_007d-25"></a><a name="index-g_t_0040code_007b_002dn_007d-26"></a>Do not execute commands found in any initialization file. 57There are three init files, loaded in the following order: 58 59 <dl> 60<dt><samp><span class="file">system.gdbinit</span></samp><dd>This is the system-wide init file. 61Its location is specified with the <code>--with-system-gdbinit</code> 62configure option (see <a href="System_002dwide-configuration.html#System_002dwide-configuration">System-wide configuration</a>). 63It is loaded first when <span class="sc">gdb</span> starts, before command line options 64have been processed. 65<br><dt><samp><span class="file">~/.gdbinit</span></samp><dd>This is the init file in your home directory. 66It is loaded next, after <samp><span class="file">system.gdbinit</span></samp>, and before 67command options have been processed. 68<br><dt><samp><span class="file">./.gdbinit</span></samp><dd>This is the init file in the current directory. 69It is loaded last, after command line options other than <code>-x</code> and 70<code>-ex</code> have been processed. Command line options <code>-x</code> and 71<code>-ex</code> are processed last, after <samp><span class="file">./.gdbinit</span></samp> has been loaded. 72</dl> 73 74 <p>For further documentation on startup processing, See <a href="Startup.html#Startup">Startup</a>. 75For documentation on how to write command files, 76See <a href="Command-Files.html#Command-Files">Command Files</a>. 77 78 <p><a name="g_t_002dnh"></a><br><dt><code>-nh</code><dd><a name="index-g_t_0040code_007b_002d_002dnh_007d-27"></a>Do not execute commands found in <samp><span class="file">~/.gdbinit</span></samp>, the init file 79in your home directory. 80See <a href="Startup.html#Startup">Startup</a>. 81 82 <br><dt><code>-quiet</code><dt><code>-silent</code><dt><code>-q</code><dd><a name="index-g_t_0040code_007b_002d_002dquiet_007d-28"></a><a name="index-g_t_0040code_007b_002d_002dsilent_007d-29"></a><a name="index-g_t_0040code_007b_002dq_007d-30"></a>“Quiet”. Do not print the introductory and copyright messages. These 83messages are also suppressed in batch mode. 84 85 <br><dt><code>-batch</code><dd><a name="index-g_t_0040code_007b_002d_002dbatch_007d-31"></a>Run in batch mode. Exit with status <code>0</code> after processing all the 86command files specified with ‘<samp><span class="samp">-x</span></samp>’ (and all commands from 87initialization files, if not inhibited with ‘<samp><span class="samp">-n</span></samp>’). Exit with 88nonzero status if an error occurs in executing the <span class="sc">gdb</span> commands 89in the command files. Batch mode also disables pagination, sets unlimited 90terminal width and height see <a href="Screen-Size.html#Screen-Size">Screen Size</a>, and acts as if <kbd>set confirm 91off</kbd> were in effect (see <a href="Messages_002fWarnings.html#Messages_002fWarnings">Messages/Warnings</a>). 92 93 <p>Batch mode may be useful for running <span class="sc">gdb</span> as a filter, for 94example to download and run a program on another computer; in order to 95make this more useful, the message 96 97 <pre class="smallexample"> Program exited normally. 98</pre> 99 <p class="noindent">(which is ordinarily issued whenever a program running under 100<span class="sc">gdb</span> control terminates) is not issued when running in batch 101mode. 102 103 <br><dt><code>-batch-silent</code><dd><a name="index-g_t_0040code_007b_002d_002dbatch_002dsilent_007d-32"></a>Run in batch mode exactly like ‘<samp><span class="samp">-batch</span></samp>’, but totally silently. All 104<span class="sc">gdb</span> output to <code>stdout</code> is prevented (<code>stderr</code> is 105unaffected). This is much quieter than ‘<samp><span class="samp">-silent</span></samp>’ and would be useless 106for an interactive session. 107 108 <p>This is particularly useful when using targets that give ‘<samp><span class="samp">Loading section</span></samp>’ 109messages, for example. 110 111 <p>Note that targets that give their output via <span class="sc">gdb</span>, as opposed to 112writing directly to <code>stdout</code>, will also be made silent. 113 114 <br><dt><code>-return-child-result</code><dd><a name="index-g_t_0040code_007b_002d_002dreturn_002dchild_002dresult_007d-33"></a>The return code from <span class="sc">gdb</span> will be the return code from the child 115process (the process being debugged), with the following exceptions: 116 117 <ul> 118<li><span class="sc">gdb</span> exits abnormally. E.g., due to an incorrect argument or an 119internal error. In this case the exit code is the same as it would have been 120without ‘<samp><span class="samp">-return-child-result</span></samp>’. 121<li>The user quits with an explicit value. E.g., ‘<samp><span class="samp">quit 1</span></samp>’. 122<li>The child process never runs, or is not allowed to terminate, in which case 123the exit code will be -1. 124</ul> 125 126 <p>This option is useful in conjunction with ‘<samp><span class="samp">-batch</span></samp>’ or ‘<samp><span class="samp">-batch-silent</span></samp>’, 127when <span class="sc">gdb</span> is being used as a remote program loader or simulator 128interface. 129 130 <br><dt><code>-nowindows</code><dt><code>-nw</code><dd><a name="index-g_t_0040code_007b_002d_002dnowindows_007d-34"></a><a name="index-g_t_0040code_007b_002dnw_007d-35"></a>“No windows”. If <span class="sc">gdb</span> comes with a graphical user interface 131(GUI) built in, then this option tells <span class="sc">gdb</span> to only use the command-line 132interface. If no GUI is available, this option has no effect. 133 134 <br><dt><code>-windows</code><dt><code>-w</code><dd><a name="index-g_t_0040code_007b_002d_002dwindows_007d-36"></a><a name="index-g_t_0040code_007b_002dw_007d-37"></a>If <span class="sc">gdb</span> includes a GUI, then this option requires it to be 135used if possible. 136 137 <br><dt><code>-cd </code><var>directory</var><dd><a name="index-g_t_0040code_007b_002d_002dcd_007d-38"></a>Run <span class="sc">gdb</span> using <var>directory</var> as its working directory, 138instead of the current directory. 139 140 <br><dt><code>-data-directory </code><var>directory</var><dd><a name="index-g_t_0040code_007b_002d_002ddata_002ddirectory_007d-39"></a>Run <span class="sc">gdb</span> using <var>directory</var> as its data directory. 141The data directory is where <span class="sc">gdb</span> searches for its 142auxiliary files. See <a href="Data-Files.html#Data-Files">Data Files</a>. 143 144 <br><dt><code>-fullname</code><dt><code>-f</code><dd><a name="index-g_t_0040code_007b_002d_002dfullname_007d-40"></a><a name="index-g_t_0040code_007b_002df_007d-41"></a><span class="sc">gnu</span> Emacs sets this option when it runs <span class="sc">gdb</span> as a 145subprocess. It tells <span class="sc">gdb</span> to output the full file name and line 146number in a standard, recognizable fashion each time a stack frame is 147displayed (which includes each time your program stops). This 148recognizable format looks like two ‘<samp><span class="samp">\032</span></samp>’ characters, followed by 149the file name, line number and character position separated by colons, 150and a newline. The Emacs-to-<span class="sc">gdb</span> interface program uses the two 151‘<samp><span class="samp">\032</span></samp>’ characters as a signal to display the source code for the 152frame. 153 154 <br><dt><code>-annotate </code><var>level</var><dd><a name="index-g_t_0040code_007b_002d_002dannotate_007d-42"></a>This option sets the <dfn>annotation level</dfn> inside <span class="sc">gdb</span>. Its 155effect is identical to using ‘<samp><span class="samp">set annotate </span><var>level</var></samp>’ 156(see <a href="Annotations.html#Annotations">Annotations</a>). The annotation <var>level</var> controls how much 157information <span class="sc">gdb</span> prints together with its prompt, values of 158expressions, source lines, and other types of output. Level 0 is the 159normal, level 1 is for use when <span class="sc">gdb</span> is run as a subprocess of 160<span class="sc">gnu</span> Emacs, level 3 is the maximum annotation suitable for programs 161that control <span class="sc">gdb</span>, and level 2 has been deprecated. 162 163 <p>The annotation mechanism has largely been superseded by <span class="sc">gdb/mi</span> 164(see <a href="GDB_002fMI.html#GDB_002fMI">GDB/MI</a>). 165 166 <br><dt><code>--args</code><dd><a name="index-g_t_0040code_007b_002d_002dargs_007d-43"></a>Change interpretation of command line so that arguments following the 167executable file are passed as command line arguments to the inferior. 168This option stops option processing. 169 170 <br><dt><code>-baud </code><var>bps</var><dt><code>-b </code><var>bps</var><dd><a name="index-g_t_0040code_007b_002d_002dbaud_007d-44"></a><a name="index-g_t_0040code_007b_002db_007d-45"></a>Set the line speed (baud rate or bits per second) of any serial 171interface used by <span class="sc">gdb</span> for remote debugging. 172 173 <br><dt><code>-l </code><var>timeout</var><dd><a name="index-g_t_0040code_007b_002dl_007d-46"></a>Set the timeout (in seconds) of any communication used by <span class="sc">gdb</span> 174for remote debugging. 175 176 <br><dt><code>-tty </code><var>device</var><dt><code>-t </code><var>device</var><dd><a name="index-g_t_0040code_007b_002d_002dtty_007d-47"></a><a name="index-g_t_0040code_007b_002dt_007d-48"></a>Run using <var>device</var> for your program's standard input and output. 177<!-- FIXME: kingdon thinks there is more to -tty. Investigate. --> 178 179 <!-- resolve the situation of these eventually --> 180 <br><dt><code>-tui</code><dd><a name="index-g_t_0040code_007b_002d_002dtui_007d-49"></a>Activate the <dfn>Text User Interface</dfn> when starting. The Text User 181Interface manages several text windows on the terminal, showing 182source, assembly, registers and <span class="sc">gdb</span> command outputs 183(see <a href="TUI.html#TUI"><span class="sc">gdb</span> Text User Interface</a>). Do not use this 184option if you run <span class="sc">gdb</span> from Emacs (see <a href="Emacs.html#Emacs">Using <span class="sc">gdb</span> under <span class="sc">gnu</span> Emacs</a>). 185 186 <!-- @item -xdb --> 187 <!-- @cindex @code{-xdb} --> 188 <!-- Run in XDB compatibility mode, allowing the use of certain XDB commands. --> 189 <!-- For information, see the file @file{xdb_trans.html}, which is usually --> 190 <!-- installed in the directory @code{/opt/langtools/wdb/doc} on HP-UX --> 191 <!-- systems. --> 192 <br><dt><code>-interpreter </code><var>interp</var><dd><a name="index-g_t_0040code_007b_002d_002dinterpreter_007d-50"></a>Use the interpreter <var>interp</var> for interface with the controlling 193program or device. This option is meant to be set by programs which 194communicate with <span class="sc">gdb</span> using it as a back end. 195See <a href="Interpreters.html#Interpreters">Command Interpreters</a>. 196 197 <p>‘<samp><span class="samp">--interpreter=mi</span></samp>’ (or ‘<samp><span class="samp">--interpreter=mi2</span></samp>’) causes 198<span class="sc">gdb</span> to use the <span class="sc">gdb/mi</span><dfn> interface</dfn> (see <a href="GDB_002fMI.html#GDB_002fMI">The <span class="sc">gdb/mi</span> Interface</a>) included since <span class="sc">gdb</span> version 6.0. The 199previous <span class="sc">gdb/mi</span> interface, included in <span class="sc">gdb</span> version 5.3 and 200selected with ‘<samp><span class="samp">--interpreter=mi1</span></samp>’, is deprecated. Earlier 201<span class="sc">gdb/mi</span> interfaces are no longer supported. 202 203 <br><dt><code>-write</code><dd><a name="index-g_t_0040code_007b_002d_002dwrite_007d-51"></a>Open the executable and core files for both reading and writing. This 204is equivalent to the ‘<samp><span class="samp">set write on</span></samp>’ command inside <span class="sc">gdb</span> 205(see <a href="Patching.html#Patching">Patching</a>). 206 207 <br><dt><code>-statistics</code><dd><a name="index-g_t_0040code_007b_002d_002dstatistics_007d-52"></a>This option causes <span class="sc">gdb</span> to print statistics about time and 208memory usage after it completes each command and returns to the prompt. 209 210 <br><dt><code>-version</code><dd><a name="index-g_t_0040code_007b_002d_002dversion_007d-53"></a>This option causes <span class="sc">gdb</span> to print its version number and 211no-warranty blurb, and exit. 212 213 <br><dt><code>-configuration</code><dd><a name="index-g_t_0040code_007b_002d_002dconfiguration_007d-54"></a>This option causes <span class="sc">gdb</span> to print details about its build-time 214configuration parameters, and then exit. These details can be 215important when reporting <span class="sc">gdb</span> bugs (see <a href="GDB-Bugs.html#GDB-Bugs">GDB Bugs</a>). 216 217 </dl> 218 219 </body></html> 220 221