3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Patching">Patching
</a>,
13 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Calling.html#Calling">Calling
</a>,
14 Up:
<a rel=
"up" accesskey=
"u" href=
"Altering.html#Altering">Altering
</a>
18 <h3 class=
"section">Patching programs
</h3>
20 <p>By default, GDB opens the file containing your program's
21 executable code (or the corefile) read-only. This prevents accidental
22 alterations to machine code; but it also prevents you from intentionally
23 patching your program's binary.
25 <p>If you'd like to be able to patch the binary, you can specify that
26 explicitly with the
<code>set write
</code> command. For example, you might
27 want to turn on internal debugging flags, or even to make emergency
31 <dt><code>set write on
</code>
32 <dd><dt><code>set write off
</code>
33 <dd>If you specify
<code>set write on
</code>, GDB opens executable and
34 core files for both reading and writing; if you specify
<code>set write
35 off
</code> (the default), GDB opens them read-only.
37 <p>If you have already loaded a file, you must load it again (using the
38 <code>exec-file
</code> or
<code>core-file
</code> command) after changing
<code>set
39 write
</code>, for your new setting to take effect.
41 <br><dt><code>show write
</code>
42 <dd>Display whether executable files and core files are opened for writing