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: Caching Target Data</title>
18
19<meta name="description" content="Debugging with GDB: Caching Target Data">
20<meta name="keywords" content="Debugging with GDB: Caching Target Data">
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="Data.html#Data" rel="up" title="Data">
29<link href="Searching-Memory.html#Searching-Memory" rel="next" title="Searching Memory">
30<link href="Character-Sets.html#Character-Sets" rel="previous" title="Character Sets">
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="Caching-Target-Data"></a>
65<div class="header">
66<p>
67Next: <a href="Searching-Memory.html#Searching-Memory" accesskey="n" rel="next">Searching Memory</a>, Previous: <a href="Character-Sets.html#Character-Sets" accesskey="p" rel="previous">Character Sets</a>, Up: <a href="Data.html#Data" accesskey="u" rel="up">Data</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>
68</div>
69<hr>
70<a name="Caching-Data-of-Targets"></a>
71<h3 class="section">10.21 Caching Data of Targets</h3>
72<a name="index-caching-data-of-targets"></a>
73
74<p><small>GDB</small> caches data exchanged between the debugger and a target.
75Each cache is associated with the address space of the inferior.
76See <a href="Inferiors-Connections-and-Programs.html#Inferiors-Connections-and-Programs">Inferiors Connections and Programs</a>, about inferior and address space.
77Such caching generally improves performance in remote debugging
78(see <a href="Remote-Debugging.html#Remote-Debugging">Remote Debugging</a>), because it reduces the overhead of the
79remote protocol by bundling memory reads and writes into large chunks.
80Unfortunately, simply caching everything would lead to incorrect results,
81since <small>GDB</small> does not necessarily know anything about volatile
82values, memory-mapped I/O addresses, etc.  Furthermore, in non-stop mode
83(see <a href="Non_002dStop-Mode.html#Non_002dStop-Mode">Non-Stop Mode</a>) memory can be changed <em>while</em> a gdb command
84is executing.
85Therefore, by default, <small>GDB</small> only caches data
86known to be on the stack<a name="DOCF13" href="#FOOT13"><sup>13</sup></a> or
87in the code segment.
88Other regions of memory can be explicitly marked as
89cacheable; see <a href="Memory-Region-Attributes.html#Memory-Region-Attributes">Memory Region Attributes</a>.
90</p>
91<dl compact="compact">
92<dd><a name="index-set-remotecache"></a>
93</dd>
94<dt><code>set remotecache on</code></dt>
95<dt><code>set remotecache off</code></dt>
96<dd><p>This option no longer does anything; it exists for compatibility
97with old scripts.
98</p>
99<a name="index-show-remotecache"></a>
100</dd>
101<dt><code>show remotecache</code></dt>
102<dd><p>Show the current state of the obsolete remotecache flag.
103</p>
104<a name="index-set-stack_002dcache"></a>
105</dd>
106<dt><code>set stack-cache on</code></dt>
107<dt><code>set stack-cache off</code></dt>
108<dd><p>Enable or disable caching of stack accesses.  When <code>on</code>, use
109caching.  By default, this option is <code>on</code>.
110</p>
111<a name="index-show-stack_002dcache"></a>
112</dd>
113<dt><code>show stack-cache</code></dt>
114<dd><p>Show the current state of data caching for memory accesses.
115</p>
116<a name="index-set-code_002dcache"></a>
117</dd>
118<dt><code>set code-cache on</code></dt>
119<dt><code>set code-cache off</code></dt>
120<dd><p>Enable or disable caching of code segment accesses.  When <code>on</code>,
121use caching.  By default, this option is <code>on</code>.  This improves
122performance of disassembly in remote debugging.
123</p>
124<a name="index-show-code_002dcache"></a>
125</dd>
126<dt><code>show code-cache</code></dt>
127<dd><p>Show the current state of target memory cache for code segment
128accesses.
129</p>
130<a name="index-info-dcache"></a>
131</dd>
132<dt><code>info dcache <span class="roman">[</span>line<span class="roman">]</span></code></dt>
133<dd><p>Print the information about the performance of data cache of the
134current inferior&rsquo;s address space.  The information displayed
135includes the dcache width and depth, and for each cache line, its
136number, address, and how many times it was referenced.  This
137command is useful for debugging the data cache operation.
138</p>
139<p>If a line number is specified, the contents of that line will be
140printed in hex.
141</p>
142</dd>
143<dt><code>set dcache size <var>size</var></code></dt>
144<dd><a name="index-dcache-size"></a>
145<a name="index-set-dcache-size"></a>
146<p>Set maximum number of entries in dcache (dcache depth above).
147</p>
148</dd>
149<dt><code>set dcache line-size <var>line-size</var></code></dt>
150<dd><a name="index-dcache-line_002dsize"></a>
151<a name="index-set-dcache-line_002dsize"></a>
152<p>Set number of bytes each dcache entry caches (dcache width above).
153Must be a power of 2.
154</p>
155</dd>
156<dt><code>show dcache size</code></dt>
157<dd><a name="index-show-dcache-size"></a>
158<p>Show maximum number of dcache entries.  See <a href="#Caching-Target-Data">info dcache</a>.
159</p>
160</dd>
161<dt><code>show dcache line-size</code></dt>
162<dd><a name="index-show-dcache-line_002dsize"></a>
163<p>Show default size of dcache lines.
164</p>
165</dd>
166</dl>
167
168<div class="footnote">
169<hr>
170<h4 class="footnotes-heading">Footnotes</h4>
171
172<h3><a name="FOOT13" href="#DOCF13">(13)</a></h3>
173<p>In non-stop mode, it is moderately
174rare for a running thread to modify the stack of a stopped thread
175in a way that would interfere with a backtrace, and caching of
176stack reads provides a significant speed up of remote backtraces.</p>
177</div>
178<hr>
179<div class="header">
180<p>
181Next: <a href="Searching-Memory.html#Searching-Memory" accesskey="n" rel="next">Searching Memory</a>, Previous: <a href="Character-Sets.html#Character-Sets" accesskey="p" rel="previous">Character Sets</a>, Up: <a href="Data.html#Data" accesskey="u" rel="up">Data</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>
182</div>
183
184
185
186</body>
187</html>
188