Next: Mode Options, Up: Invoking GDB
When gdb 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' (or `-p') options respectively. (gdb 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'/`-p' option followed by that argument.) If the second argument begins with a decimal digit, gdb will first attempt to attach to it as a process, and if that fails, attempt to open it as a corefile. If you have a corefile whose name begins with a digit, you can prevent gdb from treating it as a pid by prefixing it with ./, e.g. ./12345.
If gdb has not been configured to included core file support, such as for most embedded targets, then it will complain about a second argument and ignore it.
For the `-s', `-e', and `-se' options, and their long
form equivalents, the method used to search the file system for the
symbol and/or executable file is the same as that used by the
file command. See file.
Many options have both long and short forms; both are shown in the following list. gdb 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-core file-c file-pid number-p numberattach command.
-command file-x filesource command would.
See Command files.
-eval-command command-ex commandThis option may be used multiple times to call multiple commands. It may also be interleaved with `-command' as required.
gdb -ex 'target sim' -ex 'load' \
-x setbreakpoints -ex 'run' a.out
-init-command file-ix file-init-eval-command command-iex command-early-init-command file-eix file-early-init-eval-command command-eiex command-directory directory-d directory-r-readnow--readnever