You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Set-Breaks.html 26KB

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