Breakpoints.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Breakpoints</title>
  16. <meta name="description" content="Debugging with GDB: Breakpoints">
  17. <meta name="keywords" content="Debugging with GDB: Breakpoints">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Stopping.html#Stopping" rel="up" title="Stopping">
  26. <link href="Set-Breaks.html#Set-Breaks" rel="next" title="Set Breaks">
  27. <link href="Stopping.html#Stopping" rel="previous" title="Stopping">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style:oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="Breakpoints"></a>
  59. <div class="header">
  60. <p>
  61. Next: <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> &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>
  62. </div>
  63. <hr>
  64. <a name="Breakpoints_002c-Watchpoints_002c-and-Catchpoints"></a>
  65. <h3 class="section">5.1 Breakpoints, Watchpoints, and Catchpoints</h3>
  66. <a name="index-breakpoints"></a>
  67. <p>A <em>breakpoint</em> makes your program stop whenever a certain point in
  68. the program is reached. For each breakpoint, you can add conditions to
  69. control in finer detail whether your program stops. You can set
  70. 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
  71. should stop by line number, function name or exact address in the
  72. program.
  73. </p>
  74. <p>On some systems, you can set breakpoints in shared libraries before
  75. the executable is run.
  76. </p>
  77. <a name="index-watchpoints"></a>
  78. <a name="index-data-breakpoints"></a>
  79. <a name="index-memory-tracing"></a>
  80. <a name="index-breakpoint-on-memory-address"></a>
  81. <a name="index-breakpoint-on-variable-modification"></a>
  82. <p>A <em>watchpoint</em> is a special breakpoint that stops your program
  83. when the value of an expression changes. The expression may be a value
  84. of a variable, or it could involve values of one or more variables
  85. combined by operators, such as &lsquo;<samp>a + b</samp>&rsquo;. This is sometimes called
  86. <em>data breakpoints</em>. You must use a different command to set
  87. watchpoints (see <a href="Set-Watchpoints.html#Set-Watchpoints">Setting Watchpoints</a>), but aside
  88. from that, you can manage a watchpoint like any other breakpoint: you
  89. enable, disable, and delete both breakpoints and watchpoints using the
  90. same commands.
  91. </p>
  92. <p>You can arrange to have values from your program displayed automatically
  93. whenever <small>GDB</small> stops at a breakpoint. See <a href="Auto-Display.html#Auto-Display">Automatic Display</a>.
  94. </p>
  95. <a name="index-catchpoints"></a>
  96. <a name="index-breakpoint-on-events"></a>
  97. <p>A <em>catchpoint</em> is another special breakpoint that stops your program
  98. when a certain kind of event occurs, such as the throwing of a C<tt>++</tt>
  99. exception or the loading of a library. As with watchpoints, you use a
  100. different command to set a catchpoint (see <a href="Set-Catchpoints.html#Set-Catchpoints">Setting
  101. Catchpoints</a>), but aside from that, you can manage a catchpoint like any
  102. other breakpoint. (To stop when your program receives a signal, use the
  103. <code>handle</code> command; see <a href="Signals.html#Signals">Signals</a>.)
  104. </p>
  105. <a name="index-breakpoint-numbers"></a>
  106. <a name="index-numbers-for-breakpoints"></a>
  107. <p><small>GDB</small> assigns a number to each breakpoint, watchpoint, or
  108. catchpoint when you create it; these numbers are successive integers
  109. starting with one. In many of the commands for controlling various
  110. features of breakpoints you use the breakpoint number to say which
  111. breakpoint you want to change. Each breakpoint may be <em>enabled</em> or
  112. <em>disabled</em>; if disabled, it has no effect on your program until you
  113. enable it again.
  114. </p>
  115. <a name="index-breakpoint-ranges"></a>
  116. <a name="index-breakpoint-lists"></a>
  117. <a name="index-ranges-of-breakpoints"></a>
  118. <a name="index-lists-of-breakpoints"></a>
  119. <p>Some <small>GDB</small> commands accept a space-separated list of breakpoints
  120. on which to operate. A list element can be either a single breakpoint number,
  121. like &lsquo;<samp>5</samp>&rsquo;, or a range of such numbers, like &lsquo;<samp>5-7</samp>&rsquo;.
  122. When a breakpoint list is given to a command, all breakpoints in that list
  123. are operated on.
  124. </p>
  125. <table class="menu" border="0" cellspacing="0">
  126. <tr><td align="left" valign="top">&bull; <a href="Set-Breaks.html#Set-Breaks" accesskey="1">Set Breaks</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Setting breakpoints
  127. </td></tr>
  128. <tr><td align="left" valign="top">&bull; <a href="Set-Watchpoints.html#Set-Watchpoints" accesskey="2">Set Watchpoints</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Setting watchpoints
  129. </td></tr>
  130. <tr><td align="left" valign="top">&bull; <a href="Set-Catchpoints.html#Set-Catchpoints" accesskey="3">Set Catchpoints</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Setting catchpoints
  131. </td></tr>
  132. <tr><td align="left" valign="top">&bull; <a href="Delete-Breaks.html#Delete-Breaks" accesskey="4">Delete Breaks</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Deleting breakpoints
  133. </td></tr>
  134. <tr><td align="left" valign="top">&bull; <a href="Disabling.html#Disabling" accesskey="5">Disabling</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Disabling breakpoints
  135. </td></tr>
  136. <tr><td align="left" valign="top">&bull; <a href="Conditions.html#Conditions" accesskey="6">Conditions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Break conditions
  137. </td></tr>
  138. <tr><td align="left" valign="top">&bull; <a href="Break-Commands.html#Break-Commands" accesskey="7">Break Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Breakpoint command lists
  139. </td></tr>
  140. <tr><td align="left" valign="top">&bull; <a href="Dynamic-Printf.html#Dynamic-Printf" accesskey="8">Dynamic Printf</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Dynamic printf
  141. </td></tr>
  142. <tr><td align="left" valign="top">&bull; <a href="Save-Breakpoints.html#Save-Breakpoints" accesskey="9">Save Breakpoints</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to save breakpoints in a file
  143. </td></tr>
  144. <tr><td align="left" valign="top">&bull; <a href="Static-Probe-Points.html#Static-Probe-Points">Static Probe Points</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Listing static probe points
  145. </td></tr>
  146. <tr><td align="left" valign="top">&bull; <a href="Error-in-Breakpoints.html#Error-in-Breakpoints">Error in Breakpoints</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&ldquo;Cannot insert breakpoints&rdquo;
  147. </td></tr>
  148. <tr><td align="left" valign="top">&bull; <a href="Breakpoint_002drelated-Warnings.html#Breakpoint_002drelated-Warnings">Breakpoint-related Warnings</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&ldquo;Breakpoint address adjusted...&rdquo;
  149. </td></tr>
  150. </table>
  151. <hr>
  152. <div class="header">
  153. <p>
  154. Next: <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> &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>
  155. </div>
  156. </body>
  157. </html>