1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<!-- Copyright (C) 1988-2021 Free Software Foundation, Inc. 4 5Permission is granted to copy, distribute and/or modify this document 6under the terms of the GNU Free Documentation License, Version 1.3 or 7any later version published by the Free Software Foundation; with the 8Invariant Sections being "Free Software" and "Free Software Needs 9Free Documentation", with the Front-Cover Texts being "A GNU Manual," 10and with the Back-Cover Texts as in (a) below. 11 12(a) The FSF's Back-Cover Text is: "You are free to copy and modify 13this GNU Manual. Buying copies from GNU Press supports the FSF in 14developing GNU and promoting software freedom." --> 15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 16<head> 17<title>Debugging with GDB: Interpreters</title> 18 19<meta name="description" content="Debugging with GDB: Interpreters"> 20<meta name="keywords" content="Debugging with GDB: Interpreters"> 21<meta name="resource-type" content="document"> 22<meta name="distribution" content="global"> 23<meta name="Generator" content="makeinfo"> 24<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 25<link href="index.html#Top" rel="start" title="Top"> 26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> 27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 28<link href="index.html#Top" rel="up" title="Top"> 29<link href="TUI.html#TUI" rel="next" title="TUI"> 30<link href="Aliases.html#Aliases" rel="previous" title="Aliases"> 31<style type="text/css"> 32<!-- 33a.summary-letter {text-decoration: none} 34blockquote.smallquotation {font-size: smaller} 35div.display {margin-left: 3.2em} 36div.example {margin-left: 3.2em} 37div.indentedblock {margin-left: 3.2em} 38div.lisp {margin-left: 3.2em} 39div.smalldisplay {margin-left: 3.2em} 40div.smallexample {margin-left: 3.2em} 41div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 42div.smalllisp {margin-left: 3.2em} 43kbd {font-style:oblique} 44pre.display {font-family: inherit} 45pre.format {font-family: inherit} 46pre.menu-comment {font-family: serif} 47pre.menu-preformatted {font-family: serif} 48pre.smalldisplay {font-family: inherit; font-size: smaller} 49pre.smallexample {font-size: smaller} 50pre.smallformat {font-family: inherit; font-size: smaller} 51pre.smalllisp {font-size: smaller} 52span.nocodebreak {white-space:nowrap} 53span.nolinebreak {white-space:nowrap} 54span.roman {font-family:serif; font-weight:normal} 55span.sansserif {font-family:sans-serif; font-weight:normal} 56ul.no-bullet {list-style: none} 57--> 58</style> 59 60 61</head> 62 63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 64<a name="Interpreters"></a> 65<div class="header"> 66<p> 67Next: <a href="TUI.html#TUI" accesskey="n" rel="next">TUI</a>, Previous: <a href="Extending-GDB.html#Extending-GDB" accesskey="p" rel="previous">Extending GDB</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> 68</div> 69<hr> 70<a name="Command-Interpreters"></a> 71<h2 class="chapter">24 Command Interpreters</h2> 72<a name="index-command-interpreters"></a> 73 74<p><small>GDB</small> supports multiple command interpreters, and some command 75infrastructure to allow users or user interface writers to switch 76between interpreters or run commands in other interpreters. 77</p> 78<p><small>GDB</small> currently supports two command interpreters, the console 79interpreter (sometimes called the command-line interpreter or <small>CLI</small>) 80and the machine interface interpreter (or <small>GDB/MI</small>). This manual 81describes both of these interfaces in great detail. 82</p> 83<p>By default, <small>GDB</small> will start with the console interpreter. 84However, the user may choose to start <small>GDB</small> with another 85interpreter by specifying the <samp>-i</samp> or <samp>--interpreter</samp> 86startup options. Defined interpreters include: 87</p> 88<dl compact="compact"> 89<dt><code>console</code></dt> 90<dd><a name="index-console-interpreter"></a> 91<p>The traditional console or command-line interpreter. This is the most often 92used interpreter with <small>GDB</small>. With no interpreter specified at runtime, 93<small>GDB</small> will use this interpreter. 94</p> 95</dd> 96<dt><code>mi</code></dt> 97<dd><a name="index-mi-interpreter"></a> 98<p>The newest <small>GDB/MI</small> interface (currently <code>mi3</code>). Used primarily 99by programs wishing to use <small>GDB</small> as a backend for a debugger GUI 100or an IDE. For more information, see <a href="GDB_002fMI.html#GDB_002fMI">The <small>GDB/MI</small> 101Interface</a>. 102</p> 103</dd> 104<dt><code>mi3</code></dt> 105<dd><a name="index-mi3-interpreter"></a> 106<p>The <small>GDB/MI</small> interface introduced in <small>GDB</small> 9.1. 107</p> 108</dd> 109<dt><code>mi2</code></dt> 110<dd><a name="index-mi2-interpreter"></a> 111<p>The <small>GDB/MI</small> interface introduced in <small>GDB</small> 6.0. 112</p> 113</dd> 114<dt><code>mi1</code></dt> 115<dd><a name="index-mi1-interpreter"></a> 116<p>The <small>GDB/MI</small> interface introduced in <small>GDB</small> 5.1. 117</p> 118</dd> 119</dl> 120 121<a name="index-invoke-another-interpreter"></a> 122 123<a name="index-interpreter_002dexec"></a> 124<p>You may execute commands in any interpreter from the current 125interpreter using the appropriate command. If you are running the 126console interpreter, simply use the <code>interpreter-exec</code> command: 127</p> 128<div class="smallexample"> 129<pre class="smallexample">interpreter-exec mi "-data-list-register-names" 130</pre></div> 131 132<p><small>GDB/MI</small> has a similar command, although it is only available in versions of 133<small>GDB</small> which support <small>GDB/MI</small> version 2 (or greater). 134</p> 135<p>Note that <code>interpreter-exec</code> only changes the interpreter for the 136duration of the specified command. It does not change the interpreter 137permanently. 138</p> 139<a name="index-start-a-new-independent-interpreter"></a> 140 141<p>Although you may only choose a single interpreter at startup, it is 142possible to run an independent interpreter on a specified input/output 143device (usually a tty). 144</p> 145<p>For example, consider a debugger GUI or IDE that wants to provide a 146<small>GDB</small> console view. It may do so by embedding a terminal 147emulator widget in its GUI, starting <small>GDB</small> in the traditional 148command-line mode with stdin/stdout/stderr redirected to that 149terminal, and then creating an MI interpreter running on a specified 150input/output device. The console interpreter created by <small>GDB</small> 151at startup handles commands the user types in the terminal widget, 152while the GUI controls and synchronizes state with <small>GDB</small> using 153the separate MI interpreter. 154</p> 155<p>To start a new secondary <em>user interface</em> running MI, use the 156<code>new-ui</code> command: 157</p> 158<a name="index-new_002dui"></a> 159<a name="index-new-user-interface"></a> 160<div class="smallexample"> 161<pre class="smallexample">new-ui <var>interpreter</var> <var>tty</var> 162</pre></div> 163 164<p>The <var>interpreter</var> parameter specifies the interpreter to run. 165This accepts the same values as the <code>interpreter-exec</code> command. 166For example, ‘<samp>console</samp>’, ‘<samp>mi</samp>’, ‘<samp>mi2</samp>’, etc. The 167<var>tty</var> parameter specifies the name of the bidirectional file the 168interpreter uses for input/output, usually the name of a 169pseudoterminal slave on Unix systems. For example: 170</p> 171<div class="smallexample"> 172<pre class="smallexample">(gdb) new-ui mi /dev/pts/9 173</pre></div> 174 175<p>runs an MI interpreter on <samp>/dev/pts/9</samp>. 176</p> 177<hr> 178<div class="header"> 179<p> 180Next: <a href="TUI.html#TUI" accesskey="n" rel="next">TUI</a>, Previous: <a href="Extending-GDB.html#Extending-GDB" accesskey="p" rel="previous">Extending GDB</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> 181</div> 182 183 184 185</body> 186</html> 187