Overlay-Commands.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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: Overlay Commands</title>
  16. <meta name="description" content="Debugging with GDB: Overlay Commands">
  17. <meta name="keywords" content="Debugging with GDB: Overlay Commands">
  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="Overlays.html#Overlays" rel="up" title="Overlays">
  26. <link href="Automatic-Overlay-Debugging.html#Automatic-Overlay-Debugging" rel="next" title="Automatic Overlay Debugging">
  27. <link href="How-Overlays-Work.html#How-Overlays-Work" rel="previous" title="How Overlays Work">
  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="Overlay-Commands"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Automatic-Overlay-Debugging.html#Automatic-Overlay-Debugging" accesskey="n" rel="next">Automatic Overlay Debugging</a>, Previous: <a href="How-Overlays-Work.html#How-Overlays-Work" accesskey="p" rel="previous">How Overlays Work</a>, Up: <a href="Overlays.html#Overlays" accesskey="u" rel="up">Overlays</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="Overlay-Commands-1"></a>
  65. <h3 class="section">14.2 Overlay Commands</h3>
  66. <p>To use <small>GDB</small>&rsquo;s overlay support, each overlay in your program must
  67. correspond to a separate section of the executable file. The section&rsquo;s
  68. virtual memory address and load memory address must be the overlay&rsquo;s
  69. mapped and load addresses. Identifying overlays with sections allows
  70. <small>GDB</small> to determine the appropriate address of a function or
  71. variable, depending on whether the overlay is mapped or not.
  72. </p>
  73. <p><small>GDB</small>&rsquo;s overlay commands all start with the word <code>overlay</code>;
  74. you can abbreviate this as <code>ov</code> or <code>ovly</code>. The commands are:
  75. </p>
  76. <dl compact="compact">
  77. <dt><code>overlay off</code></dt>
  78. <dd><a name="index-overlay"></a>
  79. <p>Disable <small>GDB</small>&rsquo;s overlay support. When overlay support is
  80. disabled, <small>GDB</small> assumes that all functions and variables are
  81. always present at their mapped addresses. By default, <small>GDB</small>&rsquo;s
  82. overlay support is disabled.
  83. </p>
  84. </dd>
  85. <dt><code>overlay manual</code></dt>
  86. <dd><a name="index-manual-overlay-debugging"></a>
  87. <p>Enable <em>manual</em> overlay debugging. In this mode, <small>GDB</small>
  88. relies on you to tell it which overlays are mapped, and which are not,
  89. using the <code>overlay map-overlay</code> and <code>overlay unmap-overlay</code>
  90. commands described below.
  91. </p>
  92. </dd>
  93. <dt><code>overlay map-overlay <var>overlay</var></code></dt>
  94. <dt><code>overlay map <var>overlay</var></code></dt>
  95. <dd><a name="index-map-an-overlay"></a>
  96. <p>Tell <small>GDB</small> that <var>overlay</var> is now mapped; <var>overlay</var> must
  97. be the name of the object file section containing the overlay. When an
  98. overlay is mapped, <small>GDB</small> assumes it can find the overlay&rsquo;s
  99. functions and variables at their mapped addresses. <small>GDB</small> assumes
  100. that any other overlays whose mapped ranges overlap that of
  101. <var>overlay</var> are now unmapped.
  102. </p>
  103. </dd>
  104. <dt><code>overlay unmap-overlay <var>overlay</var></code></dt>
  105. <dt><code>overlay unmap <var>overlay</var></code></dt>
  106. <dd><a name="index-unmap-an-overlay"></a>
  107. <p>Tell <small>GDB</small> that <var>overlay</var> is no longer mapped; <var>overlay</var>
  108. must be the name of the object file section containing the overlay.
  109. When an overlay is unmapped, <small>GDB</small> assumes it can find the
  110. overlay&rsquo;s functions and variables at their load addresses.
  111. </p>
  112. </dd>
  113. <dt><code>overlay auto</code></dt>
  114. <dd><p>Enable <em>automatic</em> overlay debugging. In this mode, <small>GDB</small>
  115. consults a data structure the overlay manager maintains in the inferior
  116. to see which overlays are mapped. For details, see <a href="Automatic-Overlay-Debugging.html#Automatic-Overlay-Debugging">Automatic Overlay Debugging</a>.
  117. </p>
  118. </dd>
  119. <dt><code>overlay load-target</code></dt>
  120. <dt><code>overlay load</code></dt>
  121. <dd><a name="index-reloading-the-overlay-table"></a>
  122. <p>Re-read the overlay table from the inferior. Normally, <small>GDB</small>
  123. re-reads the table <small>GDB</small> automatically each time the inferior
  124. stops, so this command should only be necessary if you have changed the
  125. overlay mapping yourself using <small>GDB</small>. This command is only
  126. useful when using automatic overlay debugging.
  127. </p>
  128. </dd>
  129. <dt><code>overlay list-overlays</code></dt>
  130. <dt><code>overlay list</code></dt>
  131. <dd><a name="index-listing-mapped-overlays"></a>
  132. <p>Display a list of the overlays currently mapped, along with their mapped
  133. addresses, load addresses, and sizes.
  134. </p>
  135. </dd>
  136. </dl>
  137. <p>Normally, when <small>GDB</small> prints a code address, it includes the name
  138. of the function the address falls in:
  139. </p>
  140. <div class="smallexample">
  141. <pre class="smallexample">(gdb) print main
  142. $3 = {int ()} 0x11a0 &lt;main&gt;
  143. </pre></div>
  144. <p>When overlay debugging is enabled, <small>GDB</small> recognizes code in
  145. unmapped overlays, and prints the names of unmapped functions with
  146. asterisks around them. For example, if <code>foo</code> is a function in an
  147. unmapped overlay, <small>GDB</small> prints it this way:
  148. </p>
  149. <div class="smallexample">
  150. <pre class="smallexample">(gdb) overlay list
  151. No sections are mapped.
  152. (gdb) print foo
  153. $5 = {int (int)} 0x100000 &lt;*foo*&gt;
  154. </pre></div>
  155. <p>When <code>foo</code>&rsquo;s overlay is mapped, <small>GDB</small> prints the function&rsquo;s
  156. name normally:
  157. </p>
  158. <div class="smallexample">
  159. <pre class="smallexample">(gdb) overlay list
  160. Section .ov.foo.text, loaded at 0x100000 - 0x100034,
  161. mapped at 0x1016 - 0x104a
  162. (gdb) print foo
  163. $6 = {int (int)} 0x1016 &lt;foo&gt;
  164. </pre></div>
  165. <p>When overlay debugging is enabled, <small>GDB</small> can find the correct
  166. address for functions and variables in an overlay, whether or not the
  167. overlay is mapped. This allows most <small>GDB</small> commands, like
  168. <code>break</code> and <code>disassemble</code>, to work normally, even on unmapped
  169. code. However, <small>GDB</small>&rsquo;s breakpoint support has some limitations:
  170. </p>
  171. <ul>
  172. <li> <a name="index-breakpoints-in-overlays"></a>
  173. <a name="index-overlays_002c-setting-breakpoints-in"></a>
  174. You can set breakpoints in functions in unmapped overlays, as long as
  175. <small>GDB</small> can write to the overlay at its load address.
  176. </li><li> <small>GDB</small> can not set hardware or simulator-based breakpoints in
  177. unmapped overlays. However, if you set a breakpoint at the end of your
  178. overlay manager (and tell <small>GDB</small> which overlays are now mapped, if
  179. you are using manual overlay management), <small>GDB</small> will re-set its
  180. breakpoints properly.
  181. </li></ul>
  182. <hr>
  183. <div class="header">
  184. <p>
  185. Next: <a href="Automatic-Overlay-Debugging.html#Automatic-Overlay-Debugging" accesskey="n" rel="next">Automatic Overlay Debugging</a>, Previous: <a href="How-Overlays-Work.html#How-Overlays-Work" accesskey="p" rel="previous">How Overlays Work</a>, Up: <a href="Overlays.html#Overlays" accesskey="u" rel="up">Overlays</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>
  186. </div>
  187. </body>
  188. </html>