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: Observer Mode</title> 18 19<meta name="description" content="Debugging with GDB: Observer Mode"> 20<meta name="keywords" content="Debugging with GDB: Observer Mode"> 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="Thread-Stops.html#Thread-Stops" rel="up" title="Thread Stops"> 29<link href="Reverse-Execution.html#Reverse-Execution" rel="next" title="Reverse Execution"> 30<link href="Interrupted-System-Calls.html#Interrupted-System-Calls" rel="previous" title="Interrupted System Calls"> 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="Observer-Mode"></a> 65<div class="header"> 66<p> 67Previous: <a href="Interrupted-System-Calls.html#Interrupted-System-Calls" accesskey="p" rel="previous">Interrupted System Calls</a>, Up: <a href="Thread-Stops.html#Thread-Stops" accesskey="u" rel="up">Thread Stops</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="Observer-Mode-1"></a> 71<h4 class="subsection">5.5.6 Observer Mode</h4> 72 73<p>If you want to build on non-stop mode and observe program behavior 74without any chance of disruption by <small>GDB</small>, you can set 75variables to disable all of the debugger’s attempts to modify state, 76whether by writing memory, inserting breakpoints, etc. These operate 77at a low level, intercepting operations from all commands. 78</p> 79<p>When all of these are set to <code>off</code>, then <small>GDB</small> is said to 80be <em>observer mode</em>. As a convenience, the variable 81<code>observer</code> can be set to disable these, plus enable non-stop 82mode. 83</p> 84<p>Note that <small>GDB</small> will not prevent you from making nonsensical 85combinations of these settings. For instance, if you have enabled 86<code>may-insert-breakpoints</code> but disabled <code>may-write-memory</code>, 87then breakpoints that work by writing trap instructions into the code 88stream will still not be able to be placed. 89</p> 90<dl compact="compact"> 91<dd> 92<a name="index-observer"></a> 93</dd> 94<dt><code>set observer on</code></dt> 95<dt><code>set observer off</code></dt> 96<dd><p>When set to <code>on</code>, this disables all the permission variables 97below (except for <code>insert-fast-tracepoints</code>), plus enables 98non-stop debugging. Setting this to <code>off</code> switches back to 99normal debugging, though remaining in non-stop mode. 100</p> 101</dd> 102<dt><code>show observer</code></dt> 103<dd><p>Show whether observer mode is on or off. 104</p> 105<a name="index-may_002dwrite_002dregisters"></a> 106</dd> 107<dt><code>set may-write-registers on</code></dt> 108<dt><code>set may-write-registers off</code></dt> 109<dd><p>This controls whether <small>GDB</small> will attempt to alter the values of 110registers, such as with assignment expressions in <code>print</code>, or the 111<code>jump</code> command. It defaults to <code>on</code>. 112</p> 113</dd> 114<dt><code>show may-write-registers</code></dt> 115<dd><p>Show the current permission to write registers. 116</p> 117<a name="index-may_002dwrite_002dmemory"></a> 118</dd> 119<dt><code>set may-write-memory on</code></dt> 120<dt><code>set may-write-memory off</code></dt> 121<dd><p>This controls whether <small>GDB</small> will attempt to alter the contents 122of memory, such as with assignment expressions in <code>print</code>. It 123defaults to <code>on</code>. 124</p> 125</dd> 126<dt><code>show may-write-memory</code></dt> 127<dd><p>Show the current permission to write memory. 128</p> 129<a name="index-may_002dinsert_002dbreakpoints"></a> 130</dd> 131<dt><code>set may-insert-breakpoints on</code></dt> 132<dt><code>set may-insert-breakpoints off</code></dt> 133<dd><p>This controls whether <small>GDB</small> will attempt to insert breakpoints. 134This affects all breakpoints, including internal breakpoints defined 135by <small>GDB</small>. It defaults to <code>on</code>. 136</p> 137</dd> 138<dt><code>show may-insert-breakpoints</code></dt> 139<dd><p>Show the current permission to insert breakpoints. 140</p> 141<a name="index-may_002dinsert_002dtracepoints"></a> 142</dd> 143<dt><code>set may-insert-tracepoints on</code></dt> 144<dt><code>set may-insert-tracepoints off</code></dt> 145<dd><p>This controls whether <small>GDB</small> will attempt to insert (regular) 146tracepoints at the beginning of a tracing experiment. It affects only 147non-fast tracepoints, fast tracepoints being under the control of 148<code>may-insert-fast-tracepoints</code>. It defaults to <code>on</code>. 149</p> 150</dd> 151<dt><code>show may-insert-tracepoints</code></dt> 152<dd><p>Show the current permission to insert tracepoints. 153</p> 154<a name="index-may_002dinsert_002dfast_002dtracepoints"></a> 155</dd> 156<dt><code>set may-insert-fast-tracepoints on</code></dt> 157<dt><code>set may-insert-fast-tracepoints off</code></dt> 158<dd><p>This controls whether <small>GDB</small> will attempt to insert fast 159tracepoints at the beginning of a tracing experiment. It affects only 160fast tracepoints, regular (non-fast) tracepoints being under the 161control of <code>may-insert-tracepoints</code>. It defaults to <code>on</code>. 162</p> 163</dd> 164<dt><code>show may-insert-fast-tracepoints</code></dt> 165<dd><p>Show the current permission to insert fast tracepoints. 166</p> 167<a name="index-may_002dinterrupt"></a> 168</dd> 169<dt><code>set may-interrupt on</code></dt> 170<dt><code>set may-interrupt off</code></dt> 171<dd><p>This controls whether <small>GDB</small> will attempt to interrupt or stop 172program execution. When this variable is <code>off</code>, the 173<code>interrupt</code> command will have no effect, nor will 174<kbd>Ctrl-c</kbd>. It defaults to <code>on</code>. 175</p> 176</dd> 177<dt><code>show may-interrupt</code></dt> 178<dd><p>Show the current permission to interrupt or stop the program. 179</p> 180</dd> 181</dl> 182 183<hr> 184<div class="header"> 185<p> 186Previous: <a href="Interrupted-System-Calls.html#Interrupted-System-Calls" accesskey="p" rel="previous">Interrupted System Calls</a>, Up: <a href="Thread-Stops.html#Thread-Stops" accesskey="u" rel="up">Thread Stops</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> 187</div> 188 189 190 191</body> 192</html> 193