Go to the previous, next section.
_GDBP__
. Once it's running,
_GDBN__ reads commands from the terminal until you tell it to exit.
You can also run _GDBP__
with a variety of arguments and options,
to specify more of your debugging environment at the outset.
_if__(_GENERIC__)
The command-line options described here are designed
to cover a variety of situations; in some environments, some of these
options may effectively be unavailable.
_fi__(_GENERIC__)
The most usual way to start _GDBN__ is with one argument,
specifying an executable program:
_GDBP__ program
_if__(!_BARE__) You can also start with both an executable program and a core file specified:
_GDBP__ program core
You can, instead, specify a process ID as a second argument, if you want to debug a running process:
_GDBP__ program 1234
would attach _GDBN__ to process 1234
(unless you also have a file
named `1234'; _GDBN__ does check for a core file first).
Taking advantage of the second command-line argument requires a fairly complete operating system; when you use _GDBN__ as a remote debugger attached to a bare board, there may not be any notion of "process", and there is often no way to get a core dump. _fi__(!_BARE__)
You can further control how _GDBN__ starts up by using command-line options. _GDBN__ itself can remind you of the options available.
Type
_GDBP__ -help
to display all available options and briefly describe their use (`_GDBP__ -h' is a shorter equivalent).
All options and command line arguments you give are processed in sequential order. The order makes a difference when the `-x' option is used.
_if__(!_GENERIC__) _include__(gdbinv-s.m4) _fi__(!_GENERIC__)
_if__(!_BARE__) When _GDBN__ starts, it reads any arguments other than options as specifying an executable file and core file (or process ID). This is the same as if the arguments were specified by the `-se' and `-c' options respectively. (_GDBN__ reads the first argument that does not have an associated option flag as equivalent to the `-se' option followed by that argument; and the second argument that does not have an associated option flag, if any, as equivalent to the `-c' option followed by that argument.) _fi__(!_BARE__) _if__(_BARE__) When _GDBN__ starts, it reads any argument other than options as specifying an executable file. This is the same as if the argument was specified by the `-se' option. _fi__(_BARE__)
Many options have both long and short forms; both are shown in the following list. _GDBN__ also recognizes the long forms if you truncate them, so long as enough of the option is present to be unambiguous. (If you prefer, you can flag option arguments with `--' rather than `-', though we illustrate the more usual convention.)
-symbols=file
-s file
-exec=file
-e file
-se=file
_if__(!_BARE__)
-core=file
-c file
-command=file
-x file
-directory=directory
-d directory
_if__(!_BARE__)
-m
-mapped
mmap
system call, you can use this option
to have _GDBN__ write the symbols from your
program into a reusable file in the current directory. If the program you are debugging is
called `/tmp/fred', the mapped symbol file will be `./fred.syms'.
Future _GDBN__ debugging sessions will notice the presence of this file,
and will quickly map in symbol information from it, rather than reading
the symbol table from the executable program.
The `.syms' file is specific to the host machine on which _GDBN__ is run. It holds an exact image of _GDBN__'s internal symbol table. It cannot be shared across multiple host platforms. _fi__(!_BARE__)
-r
-readnow
_if__(!_BARE__)
The -mapped
and -readnow
options are typically combined in order to
build a `.syms' file that contains complete symbol information.
A simple GDB invocation to do nothing but build a `.syms' file for future
use is:
gdb -batch -nx -mapped -readnow programname_fi__(!_BARE__)
You can run _GDBN__ in various alternative modes--for example, in batch mode or quiet mode.
-nx
-n
-quiet
-q
-batch
0
after processing all the command
files specified with `-x' (and `_GDBINIT__', if not inhibited).
Exit with nonzero status if an error occurs in executing the _GDBN__
commands in the command files.
Batch mode may be useful for running _GDBN__ 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 _GDBN__ control terminates) is not issued when running in batch mode.
-cd=directory
_if__(_LUCID__)
-context authentication
-fullname
-f
_if__(_GENERIC__ || !_H8__)
-b bps
-tty=device
quit
quit
command (abbreviated q
), or type
an end-of-file character (usually C-d).
An interrupt (often C-c) will not exit from _GDBN__, but rather will terminate the action of any _GDBN__ command that is in progress and return to _GDBN__ command level. It is safe to type the interrupt character at any time because _GDBN__ does not allow it to take effect until a time when it is safe.
_if__(!_BARE__)
If you have been using _GDBN__ to control an attached process or device, you
can release it with the detach
command; see section Debugging an Already-Running Process..
_fi__(!_BARE__)
_if__(!_BARE__)
If you need to execute occasional shell commands during your
debugging session, there is no need to leave or suspend _GDBN__; you can
just use the shell
command.
shell command string
SHELL
is used
for the name of the shell to run. Otherwise _GDBN__ uses
/bin/sh
.
The utility make
is often needed in development environments.
You do not have to use the shell
command for this purpose in _GDBN__:
make make-args
make
program with the specified
arguments. This is equivalent to `shell make make-args'.
Go to the previous, next section.