Set-Breaks.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  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: Set Breaks</title>
  16. <meta name="description" content="Debugging with GDB: Set Breaks">
  17. <meta name="keywords" content="Debugging with GDB: Set Breaks">
  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="Breakpoints.html#Breakpoints" rel="up" title="Breakpoints">
  26. <link href="Set-Watchpoints.html#Set-Watchpoints" rel="next" title="Set Watchpoints">
  27. <link href="Breakpoints.html#Breakpoints" rel="previous" title="Breakpoints">
  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="Set-Breaks"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Set-Watchpoints.html#Set-Watchpoints" accesskey="n" rel="next">Set Watchpoints</a>, Up: <a href="Breakpoints.html#Breakpoints" accesskey="u" rel="up">Breakpoints</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="Setting-Breakpoints"></a>
  65. <h4 class="subsection">5.1.1 Setting Breakpoints</h4>
  66. <a name="index-break"></a>
  67. <a name="index-b-_0028break_0029"></a>
  68. <a name="index-_0024bpnum_002c-convenience-variable"></a>
  69. <a name="index-latest-breakpoint"></a>
  70. <p>Breakpoints are set with the <code>break</code> command (abbreviated
  71. <code>b</code>). The debugger convenience variable &lsquo;<samp>$bpnum</samp>&rsquo; records the
  72. number of the breakpoint you&rsquo;ve set most recently; see <a href="Convenience-Vars.html#Convenience-Vars">Convenience Variables</a>, for a discussion of what you can do with
  73. convenience variables.
  74. </p>
  75. <dl compact="compact">
  76. <dt><code>break <var>location</var></code></dt>
  77. <dd><p>Set a breakpoint at the given <var>location</var>, which can specify a
  78. function name, a line number, or an address of an instruction.
  79. (See <a href="Specify-Location.html#Specify-Location">Specify Location</a>, for a list of all the possible ways to
  80. specify a <var>location</var>.) The breakpoint will stop your program just
  81. before it executes any of the code in the specified <var>location</var>.
  82. </p>
  83. <p>When using source languages that permit overloading of symbols, such as
  84. C<tt>++</tt>, a function name may refer to more than one possible place to break.
  85. See <a href="Ambiguous-Expressions.html#Ambiguous-Expressions">Ambiguous Expressions</a>, for a discussion of
  86. that situation.
  87. </p>
  88. <p>It is also possible to insert a breakpoint that will stop the program
  89. only if a specific thread (see <a href="Thread_002dSpecific-Breakpoints.html#Thread_002dSpecific-Breakpoints">Thread-Specific Breakpoints</a>)
  90. or a specific task (see <a href="Ada-Tasks.html#Ada-Tasks">Ada Tasks</a>) hits that breakpoint.
  91. </p>
  92. </dd>
  93. <dt><code>break</code></dt>
  94. <dd><p>When called without any arguments, <code>break</code> sets a breakpoint at
  95. the next instruction to be executed in the selected stack frame
  96. (see <a href="Stack.html#Stack">Examining the Stack</a>). In any selected frame but the
  97. innermost, this makes your program stop as soon as control
  98. returns to that frame. This is similar to the effect of a
  99. <code>finish</code> command in the frame inside the selected frame&mdash;except
  100. that <code>finish</code> does not leave an active breakpoint. If you use
  101. <code>break</code> without an argument in the innermost frame, <small>GDB</small> stops
  102. the next time it reaches the current location; this may be useful
  103. inside loops.
  104. </p>
  105. <p><small>GDB</small> normally ignores breakpoints when it resumes execution, until at
  106. least one instruction has been executed. If it did not do this, you
  107. would be unable to proceed past a breakpoint without first disabling the
  108. breakpoint. This rule applies whether or not the breakpoint already
  109. existed when your program stopped.
  110. </p>
  111. </dd>
  112. <dt><code>break &hellip; if <var>cond</var></code></dt>
  113. <dd><p>Set a breakpoint with condition <var>cond</var>; evaluate the expression
  114. <var>cond</var> each time the breakpoint is reached, and stop only if the
  115. value is nonzero&mdash;that is, if <var>cond</var> evaluates as true.
  116. &lsquo;<samp>&hellip;</samp>&rsquo; stands for one of the possible arguments described
  117. above (or no argument) specifying where to break. See <a href="Conditions.html#Conditions">Break Conditions</a>, for more information on breakpoint conditions.
  118. </p>
  119. <a name="index-tbreak"></a>
  120. </dd>
  121. <dt><code>tbreak <var>args</var></code></dt>
  122. <dd><p>Set a breakpoint enabled only for one stop. The <var>args</var> are the
  123. same as for the <code>break</code> command, and the breakpoint is set in the same
  124. way, but the breakpoint is automatically deleted after the first time your
  125. program stops there. See <a href="Disabling.html#Disabling">Disabling Breakpoints</a>.
  126. </p>
  127. <a name="index-hbreak"></a>
  128. <a name="index-hardware-breakpoints"></a>
  129. </dd>
  130. <dt><code>hbreak <var>args</var></code></dt>
  131. <dd><p>Set a hardware-assisted breakpoint. The <var>args</var> are the same as for the
  132. <code>break</code> command and the breakpoint is set in the same way, but the
  133. breakpoint requires hardware support and some target hardware may not
  134. have this support. The main purpose of this is EPROM/ROM code
  135. debugging, so you can set a breakpoint at an instruction without
  136. changing the instruction. This can be used with the new trap-generation
  137. provided by SPARClite DSU and most x86-based targets. These targets
  138. will generate traps when a program accesses some data or instruction
  139. address that is assigned to the debug registers. However the hardware
  140. breakpoint registers can take a limited number of breakpoints. For
  141. example, on the DSU, only two data breakpoints can be set at a time, and
  142. <small>GDB</small> will reject this command if more than two are used. Delete
  143. or disable unused hardware breakpoints before setting new ones
  144. (see <a href="Disabling.html#Disabling">Disabling Breakpoints</a>).
  145. See <a href="Conditions.html#Conditions">Break Conditions</a>.
  146. For remote targets, you can restrict the number of hardware
  147. breakpoints <small>GDB</small> will use, see <a href="Remote-Configuration.html#set-remote-hardware_002dbreakpoint_002dlimit">set remote hardware-breakpoint-limit</a>.
  148. </p>
  149. <a name="index-thbreak"></a>
  150. </dd>
  151. <dt><code>thbreak <var>args</var></code></dt>
  152. <dd><p>Set a hardware-assisted breakpoint enabled only for one stop. The <var>args</var>
  153. are the same as for the <code>hbreak</code> command and the breakpoint is set in
  154. the same way. However, like the <code>tbreak</code> command,
  155. the breakpoint is automatically deleted after the
  156. first time your program stops there. Also, like the <code>hbreak</code>
  157. command, the breakpoint requires hardware support and some target hardware
  158. may not have this support. See <a href="Disabling.html#Disabling">Disabling Breakpoints</a>.
  159. See also <a href="Conditions.html#Conditions">Break Conditions</a>.
  160. </p>
  161. <a name="index-rbreak"></a>
  162. <a name="index-regular-expression"></a>
  163. <a name="index-breakpoints-at-functions-matching-a-regexp"></a>
  164. <a name="index-set-breakpoints-in-many-functions"></a>
  165. </dd>
  166. <dt><code>rbreak <var>regex</var></code></dt>
  167. <dd><p>Set breakpoints on all functions matching the regular expression
  168. <var>regex</var>. This command sets an unconditional breakpoint on all
  169. matches, printing a list of all breakpoints it set. Once these
  170. breakpoints are set, they are treated just like the breakpoints set with
  171. the <code>break</code> command. You can delete them, disable them, or make
  172. them conditional the same way as any other breakpoint.
  173. </p>
  174. <p>In programs using different languages, <small>GDB</small> chooses the syntax
  175. to print the list of all breakpoints it sets according to the
  176. &lsquo;<samp>set language</samp>&rsquo; value: using &lsquo;<samp>set language auto</samp>&rsquo;
  177. (see <a href="Automatically.html#Automatically">Set Language Automatically</a>) means to use the
  178. language of the breakpoint&rsquo;s function, other values mean to use
  179. the manually specified language (see <a href="Manually.html#Manually">Set Language Manually</a>).
  180. </p>
  181. <p>The syntax of the regular expression is the standard one used with tools
  182. like <samp>grep</samp>. Note that this is different from the syntax used by
  183. shells, so for instance <code>foo*</code> matches all functions that include
  184. an <code>fo</code> followed by zero or more <code>o</code>s. There is an implicit
  185. <code>.*</code> leading and trailing the regular expression you supply, so to
  186. match only functions that begin with <code>foo</code>, use <code>^foo</code>.
  187. </p>
  188. <a name="index-non_002dmember-C_002b_002b-functions_002c-set-breakpoint-in"></a>
  189. <p>When debugging C<tt>++</tt> programs, <code>rbreak</code> is useful for setting
  190. breakpoints on overloaded functions that are not members of any special
  191. classes.
  192. </p>
  193. <a name="index-set-breakpoints-on-all-functions"></a>
  194. <p>The <code>rbreak</code> command can be used to set breakpoints in
  195. <strong>all</strong> the functions in a program, like this:
  196. </p>
  197. <div class="smallexample">
  198. <pre class="smallexample">(gdb) rbreak .
  199. </pre></div>
  200. </dd>
  201. <dt><code>rbreak <var>file</var>:<var>regex</var></code></dt>
  202. <dd><p>If <code>rbreak</code> is called with a filename qualification, it limits
  203. the search for functions matching the given regular expression to the
  204. specified <var>file</var>. This can be used, for example, to set breakpoints on
  205. every function in a given file:
  206. </p>
  207. <div class="smallexample">
  208. <pre class="smallexample">(gdb) rbreak file.c:.
  209. </pre></div>
  210. <p>The colon separating the filename qualifier from the regex may
  211. optionally be surrounded by spaces.
  212. </p>
  213. <a name="index-info-breakpoints"></a>
  214. <a name="index-_0024_005f-and-info-breakpoints"></a>
  215. </dd>
  216. <dt><code>info breakpoints <span class="roman">[</span><var>list</var>&hellip;<span class="roman">]</span></code></dt>
  217. <dt><code>info break <span class="roman">[</span><var>list</var>&hellip;<span class="roman">]</span></code></dt>
  218. <dd><p>Print a table of all breakpoints, watchpoints, and catchpoints set and
  219. not deleted. Optional argument <var>n</var> means print information only
  220. about the specified breakpoint(s) (or watchpoint(s) or catchpoint(s)).
  221. For each breakpoint, following columns are printed:
  222. </p>
  223. <dl compact="compact">
  224. <dt><em>Breakpoint Numbers</em></dt>
  225. <dt><em>Type</em></dt>
  226. <dd><p>Breakpoint, watchpoint, or catchpoint.
  227. </p></dd>
  228. <dt><em>Disposition</em></dt>
  229. <dd><p>Whether the breakpoint is marked to be disabled or deleted when hit.
  230. </p></dd>
  231. <dt><em>Enabled or Disabled</em></dt>
  232. <dd><p>Enabled breakpoints are marked with &lsquo;<samp>y</samp>&rsquo;. &lsquo;<samp>n</samp>&rsquo; marks breakpoints
  233. that are not enabled.
  234. </p></dd>
  235. <dt><em>Address</em></dt>
  236. <dd><p>Where the breakpoint is in your program, as a memory address. For a
  237. pending breakpoint whose address is not yet known, this field will
  238. contain &lsquo;<samp>&lt;PENDING&gt;</samp>&rsquo;. Such breakpoint won&rsquo;t fire until a shared
  239. library that has the symbol or line referred by breakpoint is loaded.
  240. See below for details. A breakpoint with several locations will
  241. have &lsquo;<samp>&lt;MULTIPLE&gt;</samp>&rsquo; in this field&mdash;see below for details.
  242. </p></dd>
  243. <dt><em>What</em></dt>
  244. <dd><p>Where the breakpoint is in the source for your program, as a file and
  245. line number. For a pending breakpoint, the original string passed to
  246. the breakpoint command will be listed as it cannot be resolved until
  247. the appropriate shared library is loaded in the future.
  248. </p></dd>
  249. </dl>
  250. <p>If a breakpoint is conditional, there are two evaluation modes: &ldquo;host&rdquo; and
  251. &ldquo;target&rdquo;. If mode is &ldquo;host&rdquo;, breakpoint condition evaluation is done by
  252. <small>GDB</small> on the host&rsquo;s side. If it is &ldquo;target&rdquo;, then the condition
  253. is evaluated by the target. The <code>info break</code> command shows
  254. the condition on the line following the affected breakpoint, together with
  255. its condition evaluation mode in between parentheses.
  256. </p>
  257. <p>Breakpoint commands, if any, are listed after that. A pending breakpoint is
  258. allowed to have a condition specified for it. The condition is not parsed for
  259. validity until a shared library is loaded that allows the pending
  260. breakpoint to resolve to a valid location.
  261. </p>
  262. <p><code>info break</code> with a breakpoint
  263. number <var>n</var> as argument lists only that breakpoint. The
  264. convenience variable <code>$_</code> and the default examining-address for
  265. the <code>x</code> command are set to the address of the last breakpoint
  266. listed (see <a href="Memory.html#Memory">Examining Memory</a>).
  267. </p>
  268. <p><code>info break</code> displays a count of the number of times the breakpoint
  269. has been hit. This is especially useful in conjunction with the
  270. <code>ignore</code> command. You can ignore a large number of breakpoint
  271. hits, look at the breakpoint info to see how many times the breakpoint
  272. was hit, and then run again, ignoring one less than that number. This
  273. will get you quickly to the last hit of that breakpoint.
  274. </p>
  275. <p>For a breakpoints with an enable count (xref) greater than 1,
  276. <code>info break</code> also displays that count.
  277. </p>
  278. </dd>
  279. </dl>
  280. <p><small>GDB</small> allows you to set any number of breakpoints at the same place in
  281. your program. There is nothing silly or meaningless about this. When
  282. the breakpoints are conditional, this is even useful
  283. (see <a href="Conditions.html#Conditions">Break Conditions</a>).
  284. </p>
  285. <a name="index-multiple-locations_002c-breakpoints"></a>
  286. <a name="index-breakpoints_002c-multiple-locations"></a>
  287. <p>It is possible that a breakpoint corresponds to several locations
  288. in your program. Examples of this situation are:
  289. </p>
  290. <ul>
  291. <li> Multiple functions in the program may have the same name.
  292. </li><li> For a C<tt>++</tt> constructor, the <small>GCC</small> compiler generates several
  293. instances of the function body, used in different cases.
  294. </li><li> For a C<tt>++</tt> template function, a given line in the function can
  295. correspond to any number of instantiations.
  296. </li><li> For an inlined function, a given source line can correspond to
  297. several places where that function is inlined.
  298. </li></ul>
  299. <p>In all those cases, <small>GDB</small> will insert a breakpoint at all
  300. the relevant locations.
  301. </p>
  302. <p>A breakpoint with multiple locations is displayed in the breakpoint
  303. table using several rows&mdash;one header row, followed by one row for
  304. each breakpoint location. The header row has &lsquo;<samp>&lt;MULTIPLE&gt;</samp>&rsquo; in the
  305. address column. The rows for individual locations contain the actual
  306. addresses for locations, and show the functions to which those
  307. locations belong. The number column for a location is of the form
  308. <var>breakpoint-number</var>.<var>location-number</var>.
  309. </p>
  310. <p>For example:
  311. </p>
  312. <div class="smallexample">
  313. <pre class="smallexample">Num Type Disp Enb Address What
  314. 1 breakpoint keep y &lt;MULTIPLE&gt;
  315. stop only if i==1
  316. breakpoint already hit 1 time
  317. 1.1 y 0x080486a2 in void foo&lt;int&gt;() at t.cc:8
  318. 1.2 y 0x080486ca in void foo&lt;double&gt;() at t.cc:8
  319. </pre></div>
  320. <p>You cannot delete the individual locations from a breakpoint. However,
  321. each location can be individually enabled or disabled by passing
  322. <var>breakpoint-number</var>.<var>location-number</var> as argument to the
  323. <code>enable</code> and <code>disable</code> commands. It&rsquo;s also possible to
  324. <code>enable</code> and <code>disable</code> a range of <var>location-number</var>
  325. locations using a <var>breakpoint-number</var> and two <var>location-number</var>s,
  326. in increasing order, separated by a hyphen, like
  327. <kbd><var>breakpoint-number</var>.<var>location-number1</var>-<var>location-number2</var></kbd>,
  328. in which case <small>GDB</small> acts on all the locations in the range (inclusive).
  329. Disabling or enabling the parent breakpoint (see <a href="Disabling.html#Disabling">Disabling</a>) affects
  330. all of the locations that belong to that breakpoint.
  331. </p>
  332. <a name="index-pending-breakpoints"></a>
  333. <p>It&rsquo;s quite common to have a breakpoint inside a shared library.
  334. Shared libraries can be loaded and unloaded explicitly,
  335. and possibly repeatedly, as the program is executed. To support
  336. this use case, <small>GDB</small> updates breakpoint locations whenever
  337. any shared library is loaded or unloaded. Typically, you would
  338. set a breakpoint in a shared library at the beginning of your
  339. debugging session, when the library is not loaded, and when the
  340. symbols from the library are not available. When you try to set
  341. breakpoint, <small>GDB</small> will ask you if you want to set
  342. a so called <em>pending breakpoint</em>&mdash;breakpoint whose address
  343. is not yet resolved.
  344. </p>
  345. <p>After the program is run, whenever a new shared library is loaded,
  346. <small>GDB</small> reevaluates all the breakpoints. When a newly loaded
  347. shared library contains the symbol or line referred to by some
  348. pending breakpoint, that breakpoint is resolved and becomes an
  349. ordinary breakpoint. When a library is unloaded, all breakpoints
  350. that refer to its symbols or source lines become pending again.
  351. </p>
  352. <p>This logic works for breakpoints with multiple locations, too. For
  353. example, if you have a breakpoint in a C<tt>++</tt> template function, and
  354. a newly loaded shared library has an instantiation of that template,
  355. a new location is added to the list of locations for the breakpoint.
  356. </p>
  357. <p>Except for having unresolved address, pending breakpoints do not
  358. differ from regular breakpoints. You can set conditions or commands,
  359. enable and disable them and perform other breakpoint operations.
  360. </p>
  361. <p><small>GDB</small> provides some additional commands for controlling what
  362. happens when the &lsquo;<samp>break</samp>&rsquo; command cannot resolve breakpoint
  363. address specification to an address:
  364. </p>
  365. <a name="index-set-breakpoint-pending"></a>
  366. <a name="index-show-breakpoint-pending"></a>
  367. <dl compact="compact">
  368. <dt><code>set breakpoint pending auto</code></dt>
  369. <dd><p>This is the default behavior. When <small>GDB</small> cannot find the breakpoint
  370. location, it queries you whether a pending breakpoint should be created.
  371. </p>
  372. </dd>
  373. <dt><code>set breakpoint pending on</code></dt>
  374. <dd><p>This indicates that an unrecognized breakpoint location should automatically
  375. result in a pending breakpoint being created.
  376. </p>
  377. </dd>
  378. <dt><code>set breakpoint pending off</code></dt>
  379. <dd><p>This indicates that pending breakpoints are not to be created. Any
  380. unrecognized breakpoint location results in an error. This setting does
  381. not affect any pending breakpoints previously created.
  382. </p>
  383. </dd>
  384. <dt><code>show breakpoint pending</code></dt>
  385. <dd><p>Show the current behavior setting for creating pending breakpoints.
  386. </p></dd>
  387. </dl>
  388. <p>The settings above only affect the <code>break</code> command and its
  389. variants. Once breakpoint is set, it will be automatically updated
  390. as shared libraries are loaded and unloaded.
  391. </p>
  392. <a name="index-automatic-hardware-breakpoints"></a>
  393. <p>For some targets, <small>GDB</small> can automatically decide if hardware or
  394. software breakpoints should be used, depending on whether the
  395. breakpoint address is read-only or read-write. This applies to
  396. breakpoints set with the <code>break</code> command as well as to internal
  397. breakpoints set by commands like <code>next</code> and <code>finish</code>. For
  398. breakpoints set with <code>hbreak</code>, <small>GDB</small> will always use hardware
  399. breakpoints.
  400. </p>
  401. <p>You can control this automatic behaviour with the following commands:
  402. </p>
  403. <a name="index-set-breakpoint-auto_002dhw"></a>
  404. <a name="index-show-breakpoint-auto_002dhw"></a>
  405. <dl compact="compact">
  406. <dt><code>set breakpoint auto-hw on</code></dt>
  407. <dd><p>This is the default behavior. When <small>GDB</small> sets a breakpoint, it
  408. will try to use the target memory map to decide if software or hardware
  409. breakpoint must be used.
  410. </p>
  411. </dd>
  412. <dt><code>set breakpoint auto-hw off</code></dt>
  413. <dd><p>This indicates <small>GDB</small> should not automatically select breakpoint
  414. type. If the target provides a memory map, <small>GDB</small> will warn when
  415. trying to set software breakpoint at a read-only address.
  416. </p></dd>
  417. </dl>
  418. <p><small>GDB</small> normally implements breakpoints by replacing the program code
  419. at the breakpoint address with a special instruction, which, when
  420. executed, given control to the debugger. By default, the program
  421. code is so modified only when the program is resumed. As soon as
  422. the program stops, <small>GDB</small> restores the original instructions. This
  423. behaviour guards against leaving breakpoints inserted in the
  424. target should gdb abrubptly disconnect. However, with slow remote
  425. targets, inserting and removing breakpoint can reduce the performance.
  426. This behavior can be controlled with the following commands::
  427. </p>
  428. <a name="index-set-breakpoint-always_002dinserted"></a>
  429. <a name="index-show-breakpoint-always_002dinserted"></a>
  430. <dl compact="compact">
  431. <dt><code>set breakpoint always-inserted off</code></dt>
  432. <dd><p>All breakpoints, including newly added by the user, are inserted in
  433. the target only when the target is resumed. All breakpoints are
  434. removed from the target when it stops. This is the default mode.
  435. </p>
  436. </dd>
  437. <dt><code>set breakpoint always-inserted on</code></dt>
  438. <dd><p>Causes all breakpoints to be inserted in the target at all times. If
  439. the user adds a new breakpoint, or changes an existing breakpoint, the
  440. breakpoints in the target are updated immediately. A breakpoint is
  441. removed from the target only when breakpoint itself is deleted.
  442. </p></dd>
  443. </dl>
  444. <p><small>GDB</small> handles conditional breakpoints by evaluating these conditions
  445. when a breakpoint breaks. If the condition is true, then the process being
  446. debugged stops, otherwise the process is resumed.
  447. </p>
  448. <p>If the target supports evaluating conditions on its end, <small>GDB</small> may
  449. download the breakpoint, together with its conditions, to it.
  450. </p>
  451. <p>This feature can be controlled via the following commands:
  452. </p>
  453. <a name="index-set-breakpoint-condition_002devaluation"></a>
  454. <a name="index-show-breakpoint-condition_002devaluation"></a>
  455. <dl compact="compact">
  456. <dt><code>set breakpoint condition-evaluation host</code></dt>
  457. <dd><p>This option commands <small>GDB</small> to evaluate the breakpoint
  458. conditions on the host&rsquo;s side. Unconditional breakpoints are sent to
  459. the target which in turn receives the triggers and reports them back to GDB
  460. for condition evaluation. This is the standard evaluation mode.
  461. </p>
  462. </dd>
  463. <dt><code>set breakpoint condition-evaluation target</code></dt>
  464. <dd><p>This option commands <small>GDB</small> to download breakpoint conditions
  465. to the target at the moment of their insertion. The target
  466. is responsible for evaluating the conditional expression and reporting
  467. breakpoint stop events back to <small>GDB</small> whenever the condition
  468. is true. Due to limitations of target-side evaluation, some conditions
  469. cannot be evaluated there, e.g., conditions that depend on local data
  470. that is only known to the host. Examples include
  471. conditional expressions involving convenience variables, complex types
  472. that cannot be handled by the agent expression parser and expressions
  473. that are too long to be sent over to the target, specially when the
  474. target is a remote system. In these cases, the conditions will be
  475. evaluated by <small>GDB</small>.
  476. </p>
  477. </dd>
  478. <dt><code>set breakpoint condition-evaluation auto</code></dt>
  479. <dd><p>This is the default mode. If the target supports evaluating breakpoint
  480. conditions on its end, <small>GDB</small> will download breakpoint conditions to
  481. the target (limitations mentioned previously apply). If the target does
  482. not support breakpoint condition evaluation, then <small>GDB</small> will fallback
  483. to evaluating all these conditions on the host&rsquo;s side.
  484. </p></dd>
  485. </dl>
  486. <a name="index-negative-breakpoint-numbers"></a>
  487. <a name="index-internal-GDB-breakpoints"></a>
  488. <p><small>GDB</small> itself sometimes sets breakpoints in your program for
  489. special purposes, such as proper handling of <code>longjmp</code> (in C
  490. programs). These internal breakpoints are assigned negative numbers,
  491. starting with <code>-1</code>; &lsquo;<samp>info breakpoints</samp>&rsquo; does not display them.
  492. You can see these breakpoints with the <small>GDB</small> maintenance command
  493. &lsquo;<samp>maint info breakpoints</samp>&rsquo; (see <a href="Maintenance-Commands.html#maint-info-breakpoints">maint info breakpoints</a>).
  494. </p>
  495. <hr>
  496. <div class="header">
  497. <p>
  498. Next: <a href="Set-Watchpoints.html#Set-Watchpoints" accesskey="n" rel="next">Set Watchpoints</a>, Up: <a href="Breakpoints.html#Breakpoints" accesskey="u" rel="up">Breakpoints</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>
  499. </div>
  500. </body>
  501. </html>