f78 Invoking GDB Contents|Index|Previous|Next
 

Invoking GDB 

Invoke GDB by using the command, gdb. Once started, GDB reads commands from the terminal until you tell it to quit.

You can also run gdb with a variety of arguments and options, to specify more of your debugging environment at the outset.

The command-line options described in the following discussions are designed to cover a variety of situations; in some environments, effectively, some of these options may be unavailable.

The usual way to start GDB is with one argument, specifying an executable program that you want to debug.

You can also start with both an executable program and a core file specified as the following example’s input and variables show.

You can, instead, specify a process ID as a second argument, if you want to debug a running process, for instance, as the following example’s input and variables show. Your machine hereby attaches GDB to process 1234 (unless you also have a file named ‘1234’; GDB does check for a core file first).

Taking advantage of the second command-line argument requires a fairly complete operating system; when you use GDB 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.

You can run gdb without printing the front material, which describes GDB’s non-warranty, by specifying -silent:
 

You can further control how GDB starts up by using command-line options. GDB itself can remind you of the options available.

To display all available options and briefly describe their use, use gdb -help as 1f8 input (‘gdb -h’ is a shorter equivalent).

All options and command line arguments you give are processed in sequential order. The order makes a difference when using the ‘-x’ option. 0