gdb: Mode Options
2.1.2 Choosing Modes
--------------------
You can run GDB in various alternative modes--for example, in batch mode
or quiet mode.
'-nx'
'-n'
Do not execute commands found in any initialization file. There
are three init files, loaded in the following order:
'system.gdbinit'
This is the system-wide init file. Its location is specified
with the '--with-system-gdbinit' configure option (
System-wide configuration). It is loaded first when GDB
starts, before command line options have been processed.
'~/.gdbinit'
This is the init file in your home directory. It is loaded
next, after 'system.gdbinit', and before command options have
been processed.
'./.gdbinit'
This is the init file in the current directory. It is loaded
last, after command line options other than '-x' and '-ex'
have been processed. Command line options '-x' and '-ex' are
processed last, after './.gdbinit' has been loaded.
For further documentation on startup processing, Startup.
For documentation on how to write command files, Command
Files Command Files.
'-nh'
Do not execute commands found in '~/.gdbinit', the init file in
your home directory. Startup.
'-quiet'
'-silent'
'-q'
"Quiet". Do not print the introductory and copyright messages.
These messages are also suppressed in batch mode.
'-batch'
Run in batch mode. Exit with status '0' after processing all the
command files specified with '-x' (and all commands from
initialization files, if not inhibited with '-n'). Exit with
nonzero status if an error occurs in executing the GDB commands in
the command files. Batch mode also disables pagination, sets
unlimited terminal width and height Screen Size, and acts
as if 'set confirm off' were in effect (Messages/Warnings).
Batch mode may be useful for running GDB as a filter, for example
to download and run a program on another computer; in order to make
this more useful, the message
Program exited normally.
(which is ordinarily issued whenever a program running under GDB
control terminates) is not issued when running in batch mode.
'-batch-silent'
Run in batch mode exactly like '-batch', but totally silently. All
GDB output to 'stdout' is prevented ('stderr' is unaffected). This
is much quieter than '-silent' and would be useless for an
interactive session.
This is particularly useful when using targets that give 'Loading
section' messages, for example.
Note that targets that give their output via GDB, as opposed to
writing directly to 'stdout', will also be made silent.
'-return-child-result'
The return code from GDB will be the return code from the child
process (the process being debugged), with the following
exceptions:
* GDB exits abnormally. E.g., due to an incorrect argument or
an internal error. In this case the exit code is the same as
it would have been without '-return-child-result'.
* The user quits with an explicit value. E.g., 'quit 1'.
* The child process never runs, or is not allowed to terminate,
in which case the exit code will be -1.
This option is useful in conjunction with '-batch' or
'-batch-silent', when GDB is being used as a remote program loader
or simulator interface.
'-nowindows'
'-nw'
"No windows". If GDB comes with a graphical user interface (GUI)
built in, then this option tells GDB to only use the command-line
interface. If no GUI is available, this option has no effect.
'-windows'
'-w'
If GDB includes a GUI, then this option requires it to be used if
possible.
'-cd DIRECTORY'
Run GDB using DIRECTORY as its working directory, instead of the
current directory.
'-data-directory DIRECTORY'
'-D DIRECTORY'
Run GDB using DIRECTORY as its data directory. The data directory
is where GDB searches for its auxiliary files. Data Files.
'-fullname'
'-f'
GNU Emacs sets this option when it runs GDB as a subprocess. It
tells GDB to output the full file name and line number in a
standard, recognizable fashion each time a stack frame is displayed
(which includes each time your program stops). This recognizable
format looks like two '\032' characters, followed by the file name,
line number and character position separated by colons, and a
newline. The Emacs-to-GDB interface program uses the two '\032'
characters as a signal to display the source code for the frame.
'-annotate LEVEL'
This option sets the "annotation level" inside GDB. Its effect is
identical to using 'set annotate LEVEL' (Annotations). The
annotation LEVEL controls how much information GDB prints together
with its prompt, values of expressions, source lines, and other
types of output. Level 0 is the normal, level 1 is for use when
GDB is run as a subprocess of GNU Emacs, level 3 is the maximum
annotation suitable for programs that control GDB, and level 2 has
been deprecated.
The annotation mechanism has largely been superseded by GDB/MI
(GDB/MI).
'--args'
Change interpretation of command line so that arguments following
the executable file are passed as command line arguments to the
inferior. This option stops option processing.
'-baud BPS'
'-b BPS'
Set the line speed (baud rate or bits per second) of any serial
interface used by GDB for remote debugging.
'-l TIMEOUT'
Set the timeout (in seconds) of any communication used by GDB for
remote debugging.
'-tty DEVICE'
'-t DEVICE'
Run using DEVICE for your program's standard input and output.
'-P'
'--python'
Change interpretation of command line so that the argument
immediately following this switch is taken to be the name of a
Python script file. This option stops option processing;
subsequent options are passed to Python as 'sys.argv'. This option
is only available if Python scripting support was enabled when GDB
was configured.
'-tui'
Activate the "Text User Interface" when starting. The Text User
Interface manages several text windows on the terminal, showing
source, assembly, registers and GDB command outputs (GDB Text
User Interface TUI.). Do not use this option if you run GDB from
Emacs (Using GDB under GNU Emacs Emacs.).
'-interpreter INTERP'
Use the interpreter INTERP for interface with the controlling
program or device. This option is meant to be set by programs
which communicate with GDB using it as a back end. Command
Interpreters Interpreters.
'--interpreter=mi' (or '--interpreter=mi2') causes GDB to use the
"GDB/MI interface" (The GDB/MI Interface GDB/MI.) included
since GDB version 6.0. The previous GDB/MI interface, included in
GDB version 5.3 and selected with '--interpreter=mi1', is
deprecated. Earlier GDB/MI interfaces are no longer supported.
'-write'
Open the executable and core files for both reading and writing.
This is equivalent to the 'set write on' command inside GDB (
Patching).
'-statistics'
This option causes GDB to print statistics about time and memory
usage after it completes each command and returns to the prompt.
'-version'
This option causes GDB to print its version number and no-warranty
blurb, and exit.
'-configuration'
This option causes GDB to print details about its build-time
configuration parameters, and then exit. These details can be
important when reporting GDB bugs (GDB Bugs).