Interpreters.html 8.0 KB

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