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:
mi2). 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.
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 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).
interpreter-exec only changes the interpreter for the
duration of the specified command. It does not change the interpreter
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 interpreter tty
The interpreter parameter specifies the interpreter to run.
This accepts the same values as the
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.