blob: eba51a9b2ccfd9fa4e6f1191577b9c195b556a68 [file] [log] [blame]
<html lang="en">
<head>
<title>Breakpoints - Debugging with GDB</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Debugging with GDB">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Stopping.html#Stopping" title="Stopping">
<link rel="next" href="Continuing-and-Stepping.html#Continuing-and-Stepping" title="Continuing and Stepping">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Free Software'' and ``Free Software Needs
Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom.''-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
<link rel="stylesheet" type="text/css" href="../cs.css">
</head>
<body>
<div class="node">
<a name="Breakpoints"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Continuing-and-Stepping.html#Continuing-and-Stepping">Continuing and Stepping</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Stopping.html#Stopping">Stopping</a>
<hr>
</div>
<h3 class="section">5.1 Breakpoints, Watchpoints, and Catchpoints</h3>
<p><a name="index-breakpoints-199"></a>A <dfn>breakpoint</dfn> makes your program stop whenever a certain point in
the program is reached. For each breakpoint, you can add conditions to
control in finer detail whether your program stops. You can set
breakpoints 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
should stop by line number, function name or exact address in the
program.
<p>On some systems, you can set breakpoints in shared libraries before
the executable is run. There is a minor limitation on HP-UX systems:
you must wait until the executable is run in order to set breakpoints
in shared library routines that are not called directly by the program
(for example, routines that are arguments in a <code>pthread_create</code>
call).
<p><a name="index-watchpoints-200"></a><a name="index-data-breakpoints-201"></a><a name="index-memory-tracing-202"></a><a name="index-breakpoint-on-memory-address-203"></a><a name="index-breakpoint-on-variable-modification-204"></a>A <dfn>watchpoint</dfn> is a special breakpoint that stops your program
when the value of an expression changes. The expression may be a value
of a variable, or it could involve values of one or more variables
combined by operators, such as &lsquo;<samp><span class="samp">a + b</span></samp>&rsquo;. This is sometimes called
<dfn>data breakpoints</dfn>. You must use a different command to set
watchpoints (see <a href="Set-Watchpoints.html#Set-Watchpoints">Setting Watchpoints</a>), but aside
from that, you can manage a watchpoint like any other breakpoint: you
enable, disable, and delete both breakpoints and watchpoints using the
same commands.
<p>You can arrange to have values from your program displayed automatically
whenever <span class="sc">gdb</span> stops at a breakpoint. See <a href="Auto-Display.html#Auto-Display">Automatic Display</a>.
<p><a name="index-catchpoints-205"></a><a name="index-breakpoint-on-events-206"></a>A <dfn>catchpoint</dfn> is another special breakpoint that stops your program
when a certain kind of event occurs, such as the throwing of a C<tt>++</tt>
exception or the loading of a library. As with watchpoints, you use a
different command to set a catchpoint (see <a href="Set-Catchpoints.html#Set-Catchpoints">Setting Catchpoints</a>), but aside from that, you can manage a catchpoint like any
other breakpoint. (To stop when your program receives a signal, use the
<code>handle</code> command; see <a href="Signals.html#Signals">Signals</a>.)
<p><a name="index-breakpoint-numbers-207"></a><a name="index-numbers-for-breakpoints-208"></a><span class="sc">gdb</span> assigns a number to each breakpoint, watchpoint, or
catchpoint when you create it; these numbers are successive integers
starting with one. In many of the commands for controlling various
features of breakpoints you use the breakpoint number to say which
breakpoint you want to change. Each breakpoint may be <dfn>enabled</dfn> or
<dfn>disabled</dfn>; if disabled, it has no effect on your program until you
enable it again.
<p><a name="index-breakpoint-ranges-209"></a><a name="index-ranges-of-breakpoints-210"></a>Some <span class="sc">gdb</span> commands accept a range of breakpoints on which to
operate. A breakpoint range is either a single breakpoint number, like
&lsquo;<samp><span class="samp">5</span></samp>&rsquo;, or two such numbers, in increasing order, separated by a
hyphen, like &lsquo;<samp><span class="samp">5-7</span></samp>&rsquo;. When a breakpoint range is given to a command,
all breakpoints in that range are operated on.
<ul class="menu">
<li><a accesskey="1" href="Set-Breaks.html#Set-Breaks">Set Breaks</a>: Setting breakpoints
<li><a accesskey="2" href="Set-Watchpoints.html#Set-Watchpoints">Set Watchpoints</a>: Setting watchpoints
<li><a accesskey="3" href="Set-Catchpoints.html#Set-Catchpoints">Set Catchpoints</a>: Setting catchpoints
<li><a accesskey="4" href="Delete-Breaks.html#Delete-Breaks">Delete Breaks</a>: Deleting breakpoints
<li><a accesskey="5" href="Disabling.html#Disabling">Disabling</a>: Disabling breakpoints
<li><a accesskey="6" href="Conditions.html#Conditions">Conditions</a>: Break conditions
<li><a accesskey="7" href="Break-Commands.html#Break-Commands">Break Commands</a>: Breakpoint command lists
<li><a accesskey="8" href="Save-Breakpoints.html#Save-Breakpoints">Save Breakpoints</a>: How to save breakpoints in a file
<li><a accesskey="9" href="Error-in-Breakpoints.html#Error-in-Breakpoints">Error in Breakpoints</a>: ``Cannot insert breakpoints''
<li><a href="Breakpoint_002drelated-Warnings.html#Breakpoint_002drelated-Warnings">Breakpoint-related Warnings</a>: ``Breakpoint address adjusted...''
</ul>
</body></html>