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: Breakpoints</title> 18 19<meta name="description" content="Debugging with GDB: Breakpoints"> 20<meta name="keywords" content="Debugging with GDB: Breakpoints"> 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="Stopping.html#Stopping" rel="up" title="Stopping"> 29<link href="Set-Breaks.html#Set-Breaks" rel="next" title="Set Breaks"> 30<link href="Stopping.html#Stopping" rel="previous" title="Stopping"> 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="Breakpoints"></a> 65<div class="header"> 66<p> 67Next: <a href="Continuing-and-Stepping.html#Continuing-and-Stepping" accesskey="n" rel="next">Continuing and Stepping</a>, Up: <a href="Stopping.html#Stopping" accesskey="u" rel="up">Stopping</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="Breakpoints_002c-Watchpoints_002c-and-Catchpoints"></a> 71<h3 class="section">5.1 Breakpoints, Watchpoints, and Catchpoints</h3> 72 73<a name="index-breakpoints"></a> 74<p>A <em>breakpoint</em> makes your program stop whenever a certain point in 75the program is reached. For each breakpoint, you can add conditions to 76control in finer detail whether your program stops. You can set 77breakpoints with the <code>break</code> command and its variants (see <a href="Set-Breaks.html#Set-Breaks">Setting Breakpoints</a>), to specify the place where your program 78should stop by line number, function name or exact address in the 79program. 80</p> 81<p>On some systems, you can set breakpoints in shared libraries before 82the executable is run. 83</p> 84<a name="index-watchpoints"></a> 85<a name="index-data-breakpoints"></a> 86<a name="index-memory-tracing"></a> 87<a name="index-breakpoint-on-memory-address"></a> 88<a name="index-breakpoint-on-variable-modification"></a> 89<p>A <em>watchpoint</em> is a special breakpoint that stops your program 90when the value of an expression changes. The expression may be a value 91of a variable, or it could involve values of one or more variables 92combined by operators, such as ‘<samp>a + b</samp>’. This is sometimes called 93<em>data breakpoints</em>. You must use a different command to set 94watchpoints (see <a href="Set-Watchpoints.html#Set-Watchpoints">Setting Watchpoints</a>), but aside 95from that, you can manage a watchpoint like any other breakpoint: you 96enable, disable, and delete both breakpoints and watchpoints using the 97same commands. 98</p> 99<p>You can arrange to have values from your program displayed automatically 100whenever <small>GDB</small> stops at a breakpoint. See <a href="Auto-Display.html#Auto-Display">Automatic Display</a>. 101</p> 102<a name="index-catchpoints"></a> 103<a name="index-breakpoint-on-events"></a> 104<p>A <em>catchpoint</em> is another special breakpoint that stops your program 105when a certain kind of event occurs, such as the throwing of a C<tt>++</tt> 106exception or the loading of a library. As with watchpoints, you use a 107different command to set a catchpoint (see <a href="Set-Catchpoints.html#Set-Catchpoints">Setting 108Catchpoints</a>), but aside from that, you can manage a catchpoint like any 109other breakpoint. (To stop when your program receives a signal, use the 110<code>handle</code> command; see <a href="Signals.html#Signals">Signals</a>.) 111</p> 112<a name="index-breakpoint-numbers"></a> 113<a name="index-numbers-for-breakpoints"></a> 114<p><small>GDB</small> assigns a number to each breakpoint, watchpoint, or 115catchpoint when you create it; these numbers are successive integers 116starting with one. In many of the commands for controlling various 117features of breakpoints you use the breakpoint number to say which 118breakpoint you want to change. Each breakpoint may be <em>enabled</em> or 119<em>disabled</em>; if disabled, it has no effect on your program until you 120enable it again. 121</p> 122<a name="index-breakpoint-ranges"></a> 123<a name="index-breakpoint-lists"></a> 124<a name="index-ranges-of-breakpoints"></a> 125<a name="index-lists-of-breakpoints"></a> 126<p>Some <small>GDB</small> commands accept a space-separated list of breakpoints 127on which to operate. A list element can be either a single breakpoint number, 128like ‘<samp>5</samp>’, or a range of such numbers, like ‘<samp>5-7</samp>’. 129When a breakpoint list is given to a command, all breakpoints in that list 130are operated on. 131</p> 132<table class="menu" border="0" cellspacing="0"> 133<tr><td align="left" valign="top">• <a href="Set-Breaks.html#Set-Breaks" accesskey="1">Set Breaks</a>:</td><td> </td><td align="left" valign="top">Setting breakpoints 134</td></tr> 135<tr><td align="left" valign="top">• <a href="Set-Watchpoints.html#Set-Watchpoints" accesskey="2">Set Watchpoints</a>:</td><td> </td><td align="left" valign="top">Setting watchpoints 136</td></tr> 137<tr><td align="left" valign="top">• <a href="Set-Catchpoints.html#Set-Catchpoints" accesskey="3">Set Catchpoints</a>:</td><td> </td><td align="left" valign="top">Setting catchpoints 138</td></tr> 139<tr><td align="left" valign="top">• <a href="Delete-Breaks.html#Delete-Breaks" accesskey="4">Delete Breaks</a>:</td><td> </td><td align="left" valign="top">Deleting breakpoints 140</td></tr> 141<tr><td align="left" valign="top">• <a href="Disabling.html#Disabling" accesskey="5">Disabling</a>:</td><td> </td><td align="left" valign="top">Disabling breakpoints 142</td></tr> 143<tr><td align="left" valign="top">• <a href="Conditions.html#Conditions" accesskey="6">Conditions</a>:</td><td> </td><td align="left" valign="top">Break conditions 144</td></tr> 145<tr><td align="left" valign="top">• <a href="Break-Commands.html#Break-Commands" accesskey="7">Break Commands</a>:</td><td> </td><td align="left" valign="top">Breakpoint command lists 146</td></tr> 147<tr><td align="left" valign="top">• <a href="Dynamic-printf.html#Dynamic-printf" accesskey="8">Dynamic printf</a>:</td><td> </td><td align="left" valign="top">Dynamic printf 148</td></tr> 149<tr><td align="left" valign="top">• <a href="Save-Breakpoints.html#Save-Breakpoints" accesskey="9">Save Breakpoints</a>:</td><td> </td><td align="left" valign="top">How to save breakpoints in a file 150</td></tr> 151<tr><td align="left" valign="top">• <a href="Static-Probe-Points.html#Static-Probe-Points">Static Probe Points</a>:</td><td> </td><td align="left" valign="top">Listing static probe points 152</td></tr> 153<tr><td align="left" valign="top">• <a href="Error-in-Breakpoints.html#Error-in-Breakpoints">Error in Breakpoints</a>:</td><td> </td><td align="left" valign="top">“Cannot insert breakpoints” 154</td></tr> 155<tr><td align="left" valign="top">• <a href="Breakpoint_002drelated-Warnings.html#Breakpoint_002drelated-Warnings">Breakpoint-related Warnings</a>:</td><td> </td><td align="left" valign="top">“Breakpoint address adjusted...” 156</td></tr> 157</table> 158 159<hr> 160<div class="header"> 161<p> 162Next: <a href="Continuing-and-Stepping.html#Continuing-and-Stepping" accesskey="n" rel="next">Continuing and Stepping</a>, Up: <a href="Stopping.html#Stopping" accesskey="u" rel="up">Stopping</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> 163</div> 164 165 166 167</body> 168</html> 169