Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 3 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Remote Stub (Debugging with GDB)</title>
  17. <meta name="description" content="Remote Stub (Debugging with GDB)">
  18. <meta name="keywords" content="Remote Stub (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  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="Remote-Debugging.html#Remote-Debugging" rel="up" title="Remote Debugging">
  26. <link href="Stub-Contents.html#Stub-Contents" rel="next" title="Stub Contents">
  27. <link href="Remote-Configuration.html#Remote-Configuration" rel="prev" title="Remote Configuration">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Remote-Stub"></a>
  58. <div class="header">
  59. <p>
  60. Previous: <a href="Remote-Configuration.html#Remote-Configuration" accesskey="p" rel="prev">Remote Configuration</a>, Up: <a href="Remote-Debugging.html#Remote-Debugging" accesskey="u" rel="up">Remote Debugging</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>
  61. </div>
  62. <hr>
  63. <a name="Implementing-a-Remote-Stub"></a>
  64. <h3 class="section">20.5 Implementing a Remote Stub</h3>
  65. <a name="index-debugging-stub_002c-example"></a>
  66. <a name="index-remote-stub_002c-example"></a>
  67. <a name="index-stub-example_002c-remote-debugging"></a>
  68. <p>The stub files provided with <small>GDB</small> implement the target side of the
  69. communication protocol, and the <small>GDB</small> side is implemented in the
  70. <small>GDB</small> source file <samp>remote.c</samp>. Normally, you can simply allow
  71. these subroutines to communicate, and ignore the details. (If you&rsquo;re
  72. implementing your own stub file, you can still ignore the details: start
  73. with one of the existing stub files. <samp>sparc-stub.c</samp> is the best
  74. organized, and therefore the easiest to read.)
  75. </p>
  76. <a name="index-remote-serial-debugging_002c-overview"></a>
  77. <p>To debug a program running on another machine (the debugging
  78. <em>target</em> machine), you must first arrange for all the usual
  79. prerequisites for the program to run by itself. For example, for a C
  80. program, you need:
  81. </p>
  82. <ol>
  83. <li> A startup routine to set up the C runtime environment; these usually
  84. have a name like <samp>crt0</samp>. The startup routine may be supplied by
  85. your hardware supplier, or you may have to write your own.
  86. </li><li> A C subroutine library to support your program&rsquo;s
  87. subroutine calls, notably managing input and output.
  88. </li><li> A way of getting your program to the other machine&mdash;for example, a
  89. download program. These are often supplied by the hardware
  90. manufacturer, but you may have to write your own from hardware
  91. documentation.
  92. </li></ol>
  93. <p>The next step is to arrange for your program to use a serial port to
  94. communicate with the machine where <small>GDB</small> is running (the <em>host</em>
  95. machine). In general terms, the scheme looks like this:
  96. </p>
  97. <dl compact="compact">
  98. <dt><em>On the host,</em></dt>
  99. <dd><p><small>GDB</small> already understands how to use this protocol; when everything
  100. else is set up, you can simply use the &lsquo;<samp>target remote</samp>&rsquo; command
  101. (see <a href="Targets.html#Targets">Specifying a Debugging Target</a>).
  102. </p>
  103. </dd>
  104. <dt><em>On the target,</em></dt>
  105. <dd><p>you must link with your program a few special-purpose subroutines that
  106. implement the <small>GDB</small> remote serial protocol. The file containing these
  107. subroutines is called a <em>debugging stub</em>.
  108. </p>
  109. <p>On certain remote targets, you can use an auxiliary program
  110. <code>gdbserver</code> instead of linking a stub into your program.
  111. See <a href="Server.html#Server">Using the <code>gdbserver</code> Program</a>, for details.
  112. </p></dd>
  113. </dl>
  114. <p>The debugging stub is specific to the architecture of the remote
  115. machine; for example, use <samp>sparc-stub.c</samp> to debug programs on
  116. <small>SPARC</small> boards.
  117. </p>
  118. <a name="index-remote-serial-stub-list"></a>
  119. <p>These working remote stubs are distributed with <small>GDB</small>:
  120. </p>
  121. <dl compact="compact">
  122. <dt><code>i386-stub.c</code></dt>
  123. <dd><a name="index-i386_002dstub_002ec"></a>
  124. <a name="index-Intel"></a>
  125. <a name="index-i386"></a>
  126. <p>For Intel 386 and compatible architectures.
  127. </p>
  128. </dd>
  129. <dt><code>m68k-stub.c</code></dt>
  130. <dd><a name="index-m68k_002dstub_002ec"></a>
  131. <a name="index-Motorola-680x0"></a>
  132. <a name="index-m680x0"></a>
  133. <p>For Motorola 680x0 architectures.
  134. </p>
  135. </dd>
  136. <dt><code>sh-stub.c</code></dt>
  137. <dd><a name="index-sh_002dstub_002ec"></a>
  138. <a name="index-Renesas"></a>
  139. <a name="index-SH"></a>
  140. <p>For Renesas SH architectures.
  141. </p>
  142. </dd>
  143. <dt><code>sparc-stub.c</code></dt>
  144. <dd><a name="index-sparc_002dstub_002ec"></a>
  145. <a name="index-Sparc"></a>
  146. <p>For <small>SPARC</small> architectures.
  147. </p>
  148. </dd>
  149. <dt><code>sparcl-stub.c</code></dt>
  150. <dd><a name="index-sparcl_002dstub_002ec"></a>
  151. <a name="index-Fujitsu"></a>
  152. <a name="index-SparcLite"></a>
  153. <p>For Fujitsu <small>SPARCLITE</small> architectures.
  154. </p>
  155. </dd>
  156. </dl>
  157. <p>The <samp>README</samp> file in the <small>GDB</small> distribution may list other
  158. recently added stubs.
  159. </p>
  160. <table class="menu" border="0" cellspacing="0">
  161. <tr><td align="left" valign="top">&bull; <a href="Stub-Contents.html#Stub-Contents" accesskey="1">Stub Contents</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What the stub can do for you
  162. </td></tr>
  163. <tr><td align="left" valign="top">&bull; <a href="Bootstrapping.html#Bootstrapping" accesskey="2">Bootstrapping</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What you must do for the stub
  164. </td></tr>
  165. <tr><td align="left" valign="top">&bull; <a href="Debug-Session.html#Debug-Session" accesskey="3">Debug Session</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Putting it all together
  166. </td></tr>
  167. </table>
  168. <hr>
  169. <div class="header">
  170. <p>
  171. Previous: <a href="Remote-Configuration.html#Remote-Configuration" accesskey="p" rel="prev">Remote Configuration</a>, Up: <a href="Remote-Debugging.html#Remote-Debugging" accesskey="u" rel="up">Remote Debugging</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>
  172. </div>
  173. </body>
  174. </html>