Next: , Previous: Extending GDB, Up: Top   [Contents][Index]


24 Command Interpreters

GDB supports multiple command interpreters, and some command infrastructure to allow users or user interface writers to switch between interpreters or run commands in other interpreters.

GDB currently supports two command interpreters, the console interpreter (sometimes called the command-line interpreter or CLI) and the machine interface interpreter (or GDB/MI). This manual describes both of these interfaces in great detail.

By default, GDB will start with the console interpreter. However, the user may choose to start GDB with another interpreter by specifying the -i or --interpreter startup options. Defined interpreters include:

console

The traditional console or command-line interpreter. This is the most often used interpreter with GDB. With no interpreter specified at runtime, GDB will use this interpreter.

mi

The newest GDB/MI interface (currently mi3). Used primarily by programs wishing to use GDB as a backend for a debugger GUI or an IDE. For more information, see The GDB/MI Interface.

mi3

The GDB/MI interface introduced in GDB 9.1.

mi2

The GDB/MI interface introduced in GDB 6.0.

mi1

The GDB/MI interface introduced in GDB 5.1.

You may execute commands in any interpreter from the current interpreter using the appropriate command. If you are running the console interpreter, simply use the interpreter-exec command:

interpreter-exec mi "-data-list-register-names"

GDB/MI has a similar command, although it is only available in versions of GDB which support GDB/MI version 2 (or greater).

Note that interpreter-exec only changes the interpreter for the duration of the specified command. It does not change the interpreter permanently.

Although you may only choose a single interpreter at startup, it is possible to run an independent interpreter on a specified input/output device (usually a tty).

For example, consider a debugger GUI or IDE that wants to provide a GDB console view. It may do so by embedding a terminal emulator widget in its GUI, starting GDB in the traditional command-line mode with stdin/stdout/stderr redirected to that terminal, and then creating an MI interpreter running on a specified input/output device. The console interpreter created by GDB at startup handles commands the user types in the terminal widget, while the GUI controls and synchronizes state with GDB using the separate MI interpreter.

To start a new secondary user interface running MI, use the new-ui command:

new-ui interpreter tty

The interpreter parameter specifies the interpreter to run. This accepts the same values as the interpreter-exec command. For example, ‘console’, ‘mi’, ‘mi2’, etc. The tty parameter specifies the name of the bidirectional file the interpreter uses for input/output, usually the name of a pseudoterminal slave on Unix systems. For example:

(gdb) new-ui mi /dev/pts/9

runs an MI interpreter on /dev/pts/9.


Next: , Previous: Extending GDB, Up: Top   [Contents][Index]