toolchain/share/doc/gdb/Interpreters.html

128 lines
6.5 KiB
HTML
Raw Normal View History

2024-01-10 05:24:32 +00:00
<html lang="en">
<head>
<title>Interpreters - Debugging with GDB</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Debugging with GDB">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="Extending-GDB.html#Extending-GDB" title="Extending GDB">
<link rel="next" href="TUI.html#TUI" title="TUI">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Free Software'' and ``Free Software Needs
Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom.''
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Interpreters"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="TUI.html#TUI">TUI</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Extending-GDB.html#Extending-GDB">Extending GDB</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>
<h2 class="chapter">24 Command Interpreters</h2>
<p><a name="index-command-interpreters-2892"></a>
<span class="sc">gdb</span> 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.
<p><span class="sc">gdb</span> currently supports two command interpreters, the console
interpreter (sometimes called the command-line interpreter or <span class="sc">cli</span>)
and the machine interface interpreter (or <span class="sc">gdb/mi</span>). This manual
describes both of these interfaces in great detail.
<p>By default, <span class="sc">gdb</span> will start with the console interpreter.
However, the user may choose to start <span class="sc">gdb</span> with another
interpreter by specifying the <samp><span class="option">-i</span></samp> or <samp><span class="option">--interpreter</span></samp>
startup options. Defined interpreters include:
<dl>
<dt><code>console</code><dd><a name="index-console-interpreter-2893"></a>The traditional console or command-line interpreter. This is the most often
used interpreter with <span class="sc">gdb</span>. With no interpreter specified at runtime,
<span class="sc">gdb</span> will use this interpreter.
<br><dt><code>mi</code><dd><a name="index-mi-interpreter-2894"></a>The newest <span class="sc">gdb/mi</span> interface (currently <code>mi2</code>). Used primarily
by programs wishing to use <span class="sc">gdb</span> as a backend for a debugger GUI
or an IDE. For more information, see <a href="GDB_002fMI.html#GDB_002fMI">The <span class="sc">gdb/mi</span> Interface</a>.
<br><dt><code>mi2</code><dd><a name="index-mi2-interpreter-2895"></a>The current <span class="sc">gdb/mi</span> interface.
<br><dt><code>mi1</code><dd><a name="index-mi1-interpreter-2896"></a>The <span class="sc">gdb/mi</span> interface included in <span class="sc">gdb</span> 5.1, 5.2, and 5.3.
</dl>
<p><a name="index-invoke-another-interpreter-2897"></a>
<a name="index-interpreter_002dexec-2898"></a>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 <code>interpreter-exec</code> command:
<pre class="smallexample"> interpreter-exec mi "-data-list-register-names"
</pre>
<p><span class="sc">gdb/mi</span> has a similar command, although it is only available in versions of
<span class="sc">gdb</span> which support <span class="sc">gdb/mi</span> version 2 (or greater).
<p>Note that <code>interpreter-exec</code> only changes the interpreter for the
duration of the specified command. It does not change the interpreter
permanently.
<p><a name="index-start-a-new-independent-interpreter-2899"></a>
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).
<p>For example, consider a debugger GUI or IDE that wants to provide a
<span class="sc">gdb</span> console view. It may do so by embedding a terminal
emulator widget in its GUI, starting <span class="sc">gdb</span> 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 <span class="sc">gdb</span>
at startup handles commands the user types in the terminal widget,
while the GUI controls and synchronizes state with <span class="sc">gdb</span> using
the separate MI interpreter.
<p>To start a new secondary <dfn>user interface</dfn> running MI, use the
<code>new-ui</code> command:
<p><a name="index-new_002dui-2900"></a><a name="index-new-user-interface-2901"></a>
<pre class="smallexample"> new-ui <var>interpreter</var> <var>tty</var>
</pre>
<p>The <var>interpreter</var> parameter specifies the interpreter to run.
This accepts the same values as the <code>interpreter-exec</code> command.
For example, &lsquo;<samp><span class="samp">console</span></samp>&rsquo;, &lsquo;<samp><span class="samp">mi</span></samp>&rsquo;, &lsquo;<samp><span class="samp">mi2</span></samp>&rsquo;, etc. The
<var>tty</var> 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:
<pre class="smallexample"> (gdb) new-ui mi /dev/pts/9
</pre>
<p class="noindent">runs an MI interpreter on <samp><span class="file">/dev/pts/9</span></samp>.
</body></html>