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-2021 Free Software Foundation, Inc. 4 5Permission is granted to copy, distribute and/or modify this document 6under the terms of the GNU Free Documentation License, Version 1.3 or 7any later version published by the Free Software Foundation; with the 8Invariant Sections being "Free Software" and "Free Software Needs 9Free Documentation", with the Front-Cover Texts being "A GNU Manual," 10and with the Back-Cover Texts as in (a) below. 11 12(a) The FSF's Back-Cover Text is: "You are free to copy and modify 13this GNU Manual. Buying copies from GNU Press supports the FSF in 14developing GNU and promoting software freedom." --> 15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 16<head> 17<title>Debugging with GDB: Overlay Commands</title> 18 19<meta name="description" content="Debugging with GDB: Overlay Commands"> 20<meta name="keywords" content="Debugging with GDB: Overlay Commands"> 21<meta name="resource-type" content="document"> 22<meta name="distribution" content="global"> 23<meta name="Generator" content="makeinfo"> 24<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 25<link href="index.html#Top" rel="start" title="Top"> 26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> 27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 28<link href="Overlays.html#Overlays" rel="up" title="Overlays"> 29<link href="Automatic-Overlay-Debugging.html#Automatic-Overlay-Debugging" rel="next" title="Automatic Overlay Debugging"> 30<link href="How-Overlays-Work.html#How-Overlays-Work" rel="previous" title="How Overlays Work"> 31<style type="text/css"> 32<!-- 33a.summary-letter {text-decoration: none} 34blockquote.smallquotation {font-size: smaller} 35div.display {margin-left: 3.2em} 36div.example {margin-left: 3.2em} 37div.indentedblock {margin-left: 3.2em} 38div.lisp {margin-left: 3.2em} 39div.smalldisplay {margin-left: 3.2em} 40div.smallexample {margin-left: 3.2em} 41div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 42div.smalllisp {margin-left: 3.2em} 43kbd {font-style:oblique} 44pre.display {font-family: inherit} 45pre.format {font-family: inherit} 46pre.menu-comment {font-family: serif} 47pre.menu-preformatted {font-family: serif} 48pre.smalldisplay {font-family: inherit; font-size: smaller} 49pre.smallexample {font-size: smaller} 50pre.smallformat {font-family: inherit; font-size: smaller} 51pre.smalllisp {font-size: smaller} 52span.nocodebreak {white-space:nowrap} 53span.nolinebreak {white-space:nowrap} 54span.roman {font-family:serif; font-weight:normal} 55span.sansserif {font-family:sans-serif; font-weight:normal} 56ul.no-bullet {list-style: none} 57--> 58</style> 59 60 61</head> 62 63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 64<a name="Overlay-Commands"></a> 65<div class="header"> 66<p> 67Next: <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> [<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> 68</div> 69<hr> 70<a name="Overlay-Commands-1"></a> 71<h3 class="section">14.2 Overlay Commands</h3> 72 73<p>To use <small>GDB</small>’s overlay support, each overlay in your program must 74correspond to a separate section of the executable file. The section’s 75virtual memory address and load memory address must be the overlay’s 76mapped and load addresses. Identifying overlays with sections allows 77<small>GDB</small> to determine the appropriate address of a function or 78variable, depending on whether the overlay is mapped or not. 79</p> 80<p><small>GDB</small>’s overlay commands all start with the word <code>overlay</code>; 81you can abbreviate this as <code>ov</code> or <code>ovly</code>. The commands are: 82</p> 83<dl compact="compact"> 84<dt><code>overlay off</code></dt> 85<dd><a name="index-overlay"></a> 86<p>Disable <small>GDB</small>’s overlay support. When overlay support is 87disabled, <small>GDB</small> assumes that all functions and variables are 88always present at their mapped addresses. By default, <small>GDB</small>’s 89overlay support is disabled. 90</p> 91</dd> 92<dt><code>overlay manual</code></dt> 93<dd><a name="index-manual-overlay-debugging"></a> 94<p>Enable <em>manual</em> overlay debugging. In this mode, <small>GDB</small> 95relies on you to tell it which overlays are mapped, and which are not, 96using the <code>overlay map-overlay</code> and <code>overlay unmap-overlay</code> 97commands described below. 98</p> 99</dd> 100<dt><code>overlay map-overlay <var>overlay</var></code></dt> 101<dt><code>overlay map <var>overlay</var></code></dt> 102<dd><a name="index-map-an-overlay"></a> 103<p>Tell <small>GDB</small> that <var>overlay</var> is now mapped; <var>overlay</var> must 104be the name of the object file section containing the overlay. When an 105overlay is mapped, <small>GDB</small> assumes it can find the overlay’s 106functions and variables at their mapped addresses. <small>GDB</small> assumes 107that any other overlays whose mapped ranges overlap that of 108<var>overlay</var> are now unmapped. 109</p> 110</dd> 111<dt><code>overlay unmap-overlay <var>overlay</var></code></dt> 112<dt><code>overlay unmap <var>overlay</var></code></dt> 113<dd><a name="index-unmap-an-overlay"></a> 114<p>Tell <small>GDB</small> that <var>overlay</var> is no longer mapped; <var>overlay</var> 115must be the name of the object file section containing the overlay. 116When an overlay is unmapped, <small>GDB</small> assumes it can find the 117overlay’s functions and variables at their load addresses. 118</p> 119</dd> 120<dt><code>overlay auto</code></dt> 121<dd><p>Enable <em>automatic</em> overlay debugging. In this mode, <small>GDB</small> 122consults a data structure the overlay manager maintains in the inferior 123to see which overlays are mapped. For details, see <a href="Automatic-Overlay-Debugging.html#Automatic-Overlay-Debugging">Automatic Overlay Debugging</a>. 124</p> 125</dd> 126<dt><code>overlay load-target</code></dt> 127<dt><code>overlay load</code></dt> 128<dd><a name="index-reloading-the-overlay-table"></a> 129<p>Re-read the overlay table from the inferior. Normally, <small>GDB</small> 130re-reads the table <small>GDB</small> automatically each time the inferior 131stops, so this command should only be necessary if you have changed the 132overlay mapping yourself using <small>GDB</small>. This command is only 133useful when using automatic overlay debugging. 134</p> 135</dd> 136<dt><code>overlay list-overlays</code></dt> 137<dt><code>overlay list</code></dt> 138<dd><a name="index-listing-mapped-overlays"></a> 139<p>Display a list of the overlays currently mapped, along with their mapped 140addresses, load addresses, and sizes. 141</p> 142</dd> 143</dl> 144 145<p>Normally, when <small>GDB</small> prints a code address, it includes the name 146of the function the address falls in: 147</p> 148<div class="smallexample"> 149<pre class="smallexample">(gdb) print main 150$3 = {int ()} 0x11a0 <main> 151</pre></div> 152<p>When overlay debugging is enabled, <small>GDB</small> recognizes code in 153unmapped overlays, and prints the names of unmapped functions with 154asterisks around them. For example, if <code>foo</code> is a function in an 155unmapped overlay, <small>GDB</small> prints it this way: 156</p> 157<div class="smallexample"> 158<pre class="smallexample">(gdb) overlay list 159No sections are mapped. 160(gdb) print foo 161$5 = {int (int)} 0x100000 <*foo*> 162</pre></div> 163<p>When <code>foo</code>’s overlay is mapped, <small>GDB</small> prints the function’s 164name normally: 165</p> 166<div class="smallexample"> 167<pre class="smallexample">(gdb) overlay list 168Section .ov.foo.text, loaded at 0x100000 - 0x100034, 169 mapped at 0x1016 - 0x104a 170(gdb) print foo 171$6 = {int (int)} 0x1016 <foo> 172</pre></div> 173 174<p>When overlay debugging is enabled, <small>GDB</small> can find the correct 175address for functions and variables in an overlay, whether or not the 176overlay is mapped. This allows most <small>GDB</small> commands, like 177<code>break</code> and <code>disassemble</code>, to work normally, even on unmapped 178code. However, <small>GDB</small>’s breakpoint support has some limitations: 179</p> 180<ul> 181<li> <a name="index-breakpoints-in-overlays"></a> 182<a name="index-overlays_002c-setting-breakpoints-in"></a> 183You can set breakpoints in functions in unmapped overlays, as long as 184<small>GDB</small> can write to the overlay at its load address. 185</li><li> <small>GDB</small> can not set hardware or simulator-based breakpoints in 186unmapped overlays. However, if you set a breakpoint at the end of your 187overlay manager (and tell <small>GDB</small> which overlays are now mapped, if 188you are using manual overlay management), <small>GDB</small> will re-set its 189breakpoints properly. 190</li></ul> 191 192 193<hr> 194<div class="header"> 195<p> 196Next: <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> [<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> 197</div> 198 199 200 201</body> 202</html> 203