You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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>Bootstrapping (Debugging with GDB)</title>
  17. <meta name="description" content="Bootstrapping (Debugging with GDB)">
  18. <meta name="keywords" content="Bootstrapping (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-Stub.html#Remote-Stub" rel="up" title="Remote Stub">
  26. <link href="Debug-Session.html#Debug-Session" rel="next" title="Debug Session">
  27. <link href="Stub-Contents.html#Stub-Contents" rel="prev" title="Stub Contents">
  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="Bootstrapping"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Debug-Session.html#Debug-Session" accesskey="n" rel="next">Debug Session</a>, Previous: <a href="Stub-Contents.html#Stub-Contents" accesskey="p" rel="prev">Stub Contents</a>, Up: <a href="Remote-Stub.html#Remote-Stub" accesskey="u" rel="up">Remote Stub</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="What-You-Must-Do-for-the-Stub"></a>
  64. <h4 class="subsection">20.5.2 What You Must Do for the Stub</h4>
  65. <a name="index-remote-stub_002c-support-routines"></a>
  66. <p>The debugging stubs that come with <small>GDB</small> are set up for a particular
  67. chip architecture, but they have no information about the rest of your
  68. debugging target machine.
  69. </p>
  70. <p>First of all you need to tell the stub how to communicate with the
  71. serial port.
  72. </p>
  73. <dl compact="compact">
  74. <dt><code>int getDebugChar()</code></dt>
  75. <dd><a name="index-getDebugChar"></a>
  76. <p>Write this subroutine to read a single character from the serial port.
  77. It may be identical to <code>getchar</code> for your target system; a
  78. different name is used to allow you to distinguish the two if you wish.
  79. </p>
  80. </dd>
  81. <dt><code>void putDebugChar(int)</code></dt>
  82. <dd><a name="index-putDebugChar"></a>
  83. <p>Write this subroutine to write a single character to the serial port.
  84. It may be identical to <code>putchar</code> for your target system; a
  85. different name is used to allow you to distinguish the two if you wish.
  86. </p></dd>
  87. </dl>
  88. <a name="index-control-C_002c-and-remote-debugging"></a>
  89. <a name="index-interrupting-remote-targets"></a>
  90. <p>If you want <small>GDB</small> to be able to stop your program while it is
  91. running, you need to use an interrupt-driven serial driver, and arrange
  92. for it to stop when it receives a <code>^C</code> (&lsquo;<samp>\003</samp>&rsquo;, the control-C
  93. character). That is the character which <small>GDB</small> uses to tell the
  94. remote system to stop.
  95. </p>
  96. <p>Getting the debugging target to return the proper status to <small>GDB</small>
  97. probably requires changes to the standard stub; one quick and dirty way
  98. is to just execute a breakpoint instruction (the &ldquo;dirty&rdquo; part is that
  99. <small>GDB</small> reports a <code>SIGTRAP</code> instead of a <code>SIGINT</code>).
  100. </p>
  101. <p>Other routines you need to supply are:
  102. </p>
  103. <dl compact="compact">
  104. <dt><code>void exceptionHandler (int <var>exception_number</var>, void *<var>exception_address</var>)</code></dt>
  105. <dd><a name="index-exceptionHandler"></a>
  106. <p>Write this function to install <var>exception_address</var> in the exception
  107. handling tables. You need to do this because the stub does not have any
  108. way of knowing what the exception handling tables on your target system
  109. are like (for example, the processor&rsquo;s table might be in <small>ROM</small>,
  110. containing entries which point to a table in <small>RAM</small>).
  111. The <var>exception_number</var> specifies the exception which should be changed;
  112. its meaning is architecture-dependent (for example, different numbers
  113. might represent divide by zero, misaligned access, etc). When this
  114. exception occurs, control should be transferred directly to
  115. <var>exception_address</var>, and the processor state (stack, registers,
  116. and so on) should be just as it is when a processor exception occurs. So if
  117. you want to use a jump instruction to reach <var>exception_address</var>, it
  118. should be a simple jump, not a jump to subroutine.
  119. </p>
  120. <p>For the 386, <var>exception_address</var> should be installed as an interrupt
  121. gate so that interrupts are masked while the handler runs. The gate
  122. should be at privilege level 0 (the most privileged level). The
  123. <small>SPARC</small> and 68k stubs are able to mask interrupts themselves without
  124. help from <code>exceptionHandler</code>.
  125. </p>
  126. </dd>
  127. <dt><code>void flush_i_cache()</code></dt>
  128. <dd><a name="index-flush_005fi_005fcache"></a>
  129. <p>On <small>SPARC</small> and <small>SPARCLITE</small> only, write this subroutine to flush the
  130. instruction cache, if any, on your target machine. If there is no
  131. instruction cache, this subroutine may be a no-op.
  132. </p>
  133. <p>On target machines that have instruction caches, <small>GDB</small> requires this
  134. function to make certain that the state of your program is stable.
  135. </p></dd>
  136. </dl>
  137. <p>You must also make sure this library routine is available:
  138. </p>
  139. <dl compact="compact">
  140. <dt><code>void *memset(void *, int, int)</code></dt>
  141. <dd><a name="index-memset"></a>
  142. <p>This is the standard library function <code>memset</code> that sets an area of
  143. memory to a known value. If you have one of the free versions of
  144. <code>libc.a</code>, <code>memset</code> can be found there; otherwise, you must
  145. either obtain it from your hardware manufacturer, or write your own.
  146. </p></dd>
  147. </dl>
  148. <p>If you do not use the GNU C compiler, you may need other standard
  149. library subroutines as well; this varies from one stub to another,
  150. but in general the stubs are likely to use any of the common library
  151. subroutines which <code><small>GCC</small></code> generates as inline code.
  152. </p>
  153. <hr>
  154. <div class="header">
  155. <p>
  156. Next: <a href="Debug-Session.html#Debug-Session" accesskey="n" rel="next">Debug Session</a>, Previous: <a href="Stub-Contents.html#Stub-Contents" accesskey="p" rel="prev">Stub Contents</a>, Up: <a href="Remote-Stub.html#Remote-Stub" accesskey="u" rel="up">Remote Stub</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>
  157. </div>
  158. </body>
  159. </html>