Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

407 lines
18KB

  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>Breakpoints In Guile (Debugging with GDB)</title>
  17. <meta name="description" content="Breakpoints In Guile (Debugging with GDB)">
  18. <meta name="keywords" content="Breakpoints In Guile (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="Guile-API.html#Guile-API" rel="up" title="Guile API">
  26. <link href="Lazy-Strings-In-Guile.html#Lazy-Strings-In-Guile" rel="next" title="Lazy Strings In Guile">
  27. <link href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile" rel="prev" title="Symbol Tables In Guile">
  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="Breakpoints-In-Guile"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Lazy-Strings-In-Guile.html#Lazy-Strings-In-Guile" accesskey="n" rel="next">Lazy Strings In Guile</a>, Previous: <a href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile" accesskey="p" rel="prev">Symbol Tables In Guile</a>, Up: <a href="Guile-API.html#Guile-API" accesskey="u" rel="up">Guile API</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="Manipulating-breakpoints-using-Guile"></a>
  64. <h4 class="subsubsection">23.3.3.19 Manipulating breakpoints using Guile</h4>
  65. <a name="index-breakpoints-in-guile"></a>
  66. <a name="index-_003cgdb_003abreakpoint_003e"></a>
  67. <p>Breakpoints in Guile are represented by objects of type
  68. <code>&lt;gdb:breakpoint&gt;</code>. New breakpoints can be created with the
  69. <code>make-breakpoint</code> Guile function, and then added to <small>GDB</small> with the
  70. <code>register-breakpoint!</code> Guile function.
  71. This two-step approach is taken to separate out the side-effect of adding
  72. the breakpoint to <small>GDB</small> from <code>make-breakpoint</code>.
  73. </p>
  74. <p>Support is also provided to view and manipulate breakpoints created
  75. outside of Guile.
  76. </p>
  77. <p>The following breakpoint-related procedures are provided by the
  78. <code>(gdb)</code> module:
  79. </p>
  80. <dl>
  81. <dt><a name="index-make_002dbreakpoint"></a>Scheme Procedure: <strong>make-breakpoint</strong> <em>location <span class="roman">[</span>#:type type<span class="roman">]</span> <span class="roman">[</span>#:wp-class wp-class<span class="roman">]</span> <span class="roman">[</span>#:internal internal<span class="roman">]</span></em></dt>
  82. <dd><p>Create a new breakpoint at <var>location</var>, a string naming the
  83. location of the breakpoint, or an expression that defines a watchpoint.
  84. The contents can be any location recognized by the <code>break</code> command,
  85. or in the case of a watchpoint, by the <code>watch</code> command.
  86. </p>
  87. <p>The breakpoint is initially marked as &lsquo;<samp>invalid</samp>&rsquo;.
  88. The breakpoint is not usable until it has been registered with <small>GDB</small>
  89. with <code>register-breakpoint!</code>, at which point it becomes &lsquo;<samp>valid</samp>&rsquo;.
  90. The result is the <code>&lt;gdb:breakpoint&gt;</code> object representing the breakpoint.
  91. </p>
  92. <p>The optional <var>type</var> denotes the breakpoint to create.
  93. This argument can be either <code>BP_BREAKPOINT</code> or <code>BP_WATCHPOINT</code>,
  94. and defaults to <code>BP_BREAKPOINT</code>.
  95. </p>
  96. <p>The optional <var>wp-class</var> argument defines the class of watchpoint to
  97. create, if <var>type</var> is <code>BP_WATCHPOINT</code>. If a watchpoint class is
  98. not provided, it is assumed to be a <code>WP_WRITE</code> class.
  99. </p>
  100. <p>The optional <var>internal</var> argument allows the breakpoint to become
  101. invisible to the user. The breakpoint will neither be reported when
  102. registered, nor will it be listed in the output from <code>info breakpoints</code>
  103. (but will be listed with the <code>maint info breakpoints</code> command).
  104. If an internal flag is not provided, the breakpoint is visible
  105. (non-internal).
  106. </p>
  107. <p>When a watchpoint is created, <small>GDB</small> will try to create a
  108. hardware assisted watchpoint. If successful, the type of the watchpoint
  109. is changed from <code>BP_WATCHPOINT</code> to <code>BP_HARDWARE_WATCHPOINT</code>
  110. for <code>WP_WRITE</code>, <code>BP_READ_WATCHPOINT</code> for <code>WP_READ</code>,
  111. and <code>BP_ACCESS_WATCHPOINT</code> for <code>WP_ACCESS</code>.
  112. If not successful, the type of the watchpoint is left as <code>WP_WATCHPOINT</code>.
  113. </p>
  114. <p>The available types are represented by constants defined in the <code>gdb</code>
  115. module:
  116. </p>
  117. <dl compact="compact">
  118. <dt><code>BP_BREAKPOINT</code>
  119. <a name="index-BP_005fBREAKPOINT-1"></a>
  120. </dt>
  121. <dd><p>Normal code breakpoint.
  122. </p>
  123. </dd>
  124. <dt><code>BP_WATCHPOINT</code>
  125. <a name="index-BP_005fWATCHPOINT-1"></a>
  126. </dt>
  127. <dd><p>Watchpoint breakpoint.
  128. </p>
  129. </dd>
  130. <dt><code>BP_HARDWARE_WATCHPOINT</code>
  131. <a name="index-BP_005fHARDWARE_005fWATCHPOINT-1"></a>
  132. </dt>
  133. <dd><p>Hardware assisted watchpoint.
  134. This value cannot be specified when creating the breakpoint.
  135. </p>
  136. </dd>
  137. <dt><code>BP_READ_WATCHPOINT</code>
  138. <a name="index-BP_005fREAD_005fWATCHPOINT-1"></a>
  139. </dt>
  140. <dd><p>Hardware assisted read watchpoint.
  141. This value cannot be specified when creating the breakpoint.
  142. </p>
  143. </dd>
  144. <dt><code>BP_ACCESS_WATCHPOINT</code>
  145. <a name="index-BP_005fACCESS_005fWATCHPOINT-1"></a>
  146. </dt>
  147. <dd><p>Hardware assisted access watchpoint.
  148. This value cannot be specified when creating the breakpoint.
  149. </p></dd>
  150. </dl>
  151. <p>The available watchpoint types represented by constants are defined in the
  152. <code>(gdb)</code> module:
  153. </p>
  154. <dl compact="compact">
  155. <dt><code>WP_READ</code>
  156. <a name="index-WP_005fREAD-1"></a>
  157. </dt>
  158. <dd><p>Read only watchpoint.
  159. </p>
  160. </dd>
  161. <dt><code>WP_WRITE</code>
  162. <a name="index-WP_005fWRITE-1"></a>
  163. </dt>
  164. <dd><p>Write only watchpoint.
  165. </p>
  166. </dd>
  167. <dt><code>WP_ACCESS</code>
  168. <a name="index-WP_005fACCESS-1"></a>
  169. </dt>
  170. <dd><p>Read/Write watchpoint.
  171. </p></dd>
  172. </dl>
  173. </dd></dl>
  174. <dl>
  175. <dt><a name="index-register_002dbreakpoint_0021"></a>Scheme Procedure: <strong>register-breakpoint!</strong> <em>breakpoint</em></dt>
  176. <dd><p>Add <var>breakpoint</var>, a <code>&lt;gdb:breakpoint&gt;</code> object, to <small>GDB</small>&rsquo;s
  177. list of breakpoints. The breakpoint must have been created with
  178. <code>make-breakpoint</code>. One cannot register breakpoints that have been
  179. created outside of Guile. Once a breakpoint is registered it becomes
  180. &lsquo;<samp>valid</samp>&rsquo;.
  181. It is an error to register an already registered breakpoint.
  182. The result is unspecified.
  183. </p></dd></dl>
  184. <dl>
  185. <dt><a name="index-delete_002dbreakpoint_0021"></a>Scheme Procedure: <strong>delete-breakpoint!</strong> <em>breakpoint</em></dt>
  186. <dd><p>Remove <var>breakpoint</var> from <small>GDB</small>&rsquo;s list of breakpoints.
  187. This also invalidates the Guile <var>breakpoint</var> object.
  188. Any further attempt to access the object will throw an exception.
  189. </p>
  190. <p>If <var>breakpoint</var> was created from Guile with <code>make-breakpoint</code>
  191. it may be re-registered with <small>GDB</small>, in which case the breakpoint
  192. becomes valid again.
  193. </p></dd></dl>
  194. <dl>
  195. <dt><a name="index-breakpoints-1"></a>Scheme Procedure: <strong>breakpoints</strong></dt>
  196. <dd><p>Return a list of all breakpoints.
  197. Each element of the list is a <code>&lt;gdb:breakpoint&gt;</code> object.
  198. </p></dd></dl>
  199. <dl>
  200. <dt><a name="index-breakpoint_003f"></a>Scheme Procedure: <strong>breakpoint?</strong> <em>object</em></dt>
  201. <dd><p>Return <code>#t</code> if <var>object</var> is a <code>&lt;gdb:breakpoint&gt;</code> object,
  202. and <code>#f</code> otherwise.
  203. </p></dd></dl>
  204. <dl>
  205. <dt><a name="index-breakpoint_002dvalid_003f"></a>Scheme Procedure: <strong>breakpoint-valid?</strong> <em>breakpoint</em></dt>
  206. <dd><p>Return <code>#t</code> if <var>breakpoint</var> is valid, <code>#f</code> otherwise.
  207. Breakpoints created with <code>make-breakpoint</code> are marked as invalid
  208. until they are registered with <small>GDB</small> with <code>register-breakpoint!</code>.
  209. A <code>&lt;gdb:breakpoint&gt;</code> object can become invalid
  210. if the user deletes the breakpoint. In this case, the object still
  211. exists, but the underlying breakpoint does not. In the cases of
  212. watchpoint scope, the watchpoint remains valid even if execution of the
  213. inferior leaves the scope of that watchpoint.
  214. </p></dd></dl>
  215. <dl>
  216. <dt><a name="index-breakpoint_002dnumber"></a>Scheme Procedure: <strong>breakpoint-number</strong> <em>breakpoint</em></dt>
  217. <dd><p>Return the breakpoint&rsquo;s number &mdash; the identifier used by
  218. the user to manipulate the breakpoint.
  219. </p></dd></dl>
  220. <dl>
  221. <dt><a name="index-breakpoint_002dtype"></a>Scheme Procedure: <strong>breakpoint-type</strong> <em>breakpoint</em></dt>
  222. <dd><p>Return the breakpoint&rsquo;s type &mdash; the identifier used to
  223. determine the actual breakpoint type or use-case.
  224. </p></dd></dl>
  225. <dl>
  226. <dt><a name="index-breakpoint_002dvisible_003f"></a>Scheme Procedure: <strong>breakpoint-visible?</strong> <em>breakpoint</em></dt>
  227. <dd><p>Return <code>#t</code> if the breakpoint is visible to the user
  228. when hit, or when the &lsquo;<samp>info breakpoints</samp>&rsquo; command is run.
  229. Otherwise return <code>#f</code>.
  230. </p></dd></dl>
  231. <dl>
  232. <dt><a name="index-breakpoint_002dlocation"></a>Scheme Procedure: <strong>breakpoint-location</strong> <em>breakpoint</em></dt>
  233. <dd><p>Return the location of the breakpoint, as specified by
  234. the user. It is a string. If the breakpoint does not have a location
  235. (that is, it is a watchpoint) return <code>#f</code>.
  236. </p></dd></dl>
  237. <dl>
  238. <dt><a name="index-breakpoint_002dexpression"></a>Scheme Procedure: <strong>breakpoint-expression</strong> <em>breakpoint</em></dt>
  239. <dd><p>Return the breakpoint expression, as specified by the user. It is a string.
  240. If the breakpoint does not have an expression (the breakpoint is not a
  241. watchpoint) return <code>#f</code>.
  242. </p></dd></dl>
  243. <dl>
  244. <dt><a name="index-breakpoint_002denabled_003f"></a>Scheme Procedure: <strong>breakpoint-enabled?</strong> <em>breakpoint</em></dt>
  245. <dd><p>Return <code>#t</code> if the breakpoint is enabled, and <code>#f</code> otherwise.
  246. </p></dd></dl>
  247. <dl>
  248. <dt><a name="index-set_002dbreakpoint_002denabled_0021"></a>Scheme Procedure: <strong>set-breakpoint-enabled!</strong> <em>breakpoint flag</em></dt>
  249. <dd><p>Set the enabled state of <var>breakpoint</var> to <var>flag</var>.
  250. If flag is <code>#f</code> it is disabled, otherwise it is enabled.
  251. </p></dd></dl>
  252. <dl>
  253. <dt><a name="index-breakpoint_002dsilent_003f"></a>Scheme Procedure: <strong>breakpoint-silent?</strong> <em>breakpoint</em></dt>
  254. <dd><p>Return <code>#t</code> if the breakpoint is silent, and <code>#f</code> otherwise.
  255. </p>
  256. <p>Note that a breakpoint can also be silent if it has commands and the
  257. first command is <code>silent</code>. This is not reported by the
  258. <code>silent</code> attribute.
  259. </p></dd></dl>
  260. <dl>
  261. <dt><a name="index-set_002dbreakpoint_002dsilent_0021"></a>Scheme Procedure: <strong>set-breakpoint-silent!</strong> <em>breakpoint flag</em></dt>
  262. <dd><p>Set the silent state of <var>breakpoint</var> to <var>flag</var>.
  263. If flag is <code>#f</code> the breakpoint is made silent,
  264. otherwise it is made non-silent (or noisy).
  265. </p></dd></dl>
  266. <dl>
  267. <dt><a name="index-breakpoint_002dignore_002dcount"></a>Scheme Procedure: <strong>breakpoint-ignore-count</strong> <em>breakpoint</em></dt>
  268. <dd><p>Return the ignore count for <var>breakpoint</var>.
  269. </p></dd></dl>
  270. <dl>
  271. <dt><a name="index-set_002dbreakpoint_002dignore_002dcount_0021"></a>Scheme Procedure: <strong>set-breakpoint-ignore-count!</strong> <em>breakpoint count</em></dt>
  272. <dd><p>Set the ignore count for <var>breakpoint</var> to <var>count</var>.
  273. </p></dd></dl>
  274. <dl>
  275. <dt><a name="index-breakpoint_002dhit_002dcount"></a>Scheme Procedure: <strong>breakpoint-hit-count</strong> <em>breakpoint</em></dt>
  276. <dd><p>Return hit count of <var>breakpoint</var>.
  277. </p></dd></dl>
  278. <dl>
  279. <dt><a name="index-set_002dbreakpoint_002dhit_002dcount_0021"></a>Scheme Procedure: <strong>set-breakpoint-hit-count!</strong> <em>breakpoint count</em></dt>
  280. <dd><p>Set the hit count of <var>breakpoint</var> to <var>count</var>.
  281. At present, <var>count</var> must be zero.
  282. </p></dd></dl>
  283. <dl>
  284. <dt><a name="index-breakpoint_002dthread"></a>Scheme Procedure: <strong>breakpoint-thread</strong> <em>breakpoint</em></dt>
  285. <dd><p>Return the global-thread-id for thread-specific breakpoint
  286. <var>breakpoint</var>. Return #f if <var>breakpoint</var> is not
  287. thread-specific.
  288. </p></dd></dl>
  289. <dl>
  290. <dt><a name="index-set_002dbreakpoint_002dthread_0021"></a>Scheme Procedure: <strong>set-breakpoint-thread!</strong> <em>breakpoint global-thread-id|#f</em></dt>
  291. <dd><p>Set the thread-id for <var>breakpoint</var> to <var>global-thread-id</var> If
  292. set to <code>#f</code>, the breakpoint is no longer thread-specific.
  293. </p></dd></dl>
  294. <dl>
  295. <dt><a name="index-breakpoint_002dtask"></a>Scheme Procedure: <strong>breakpoint-task</strong> <em>breakpoint</em></dt>
  296. <dd><p>If the breakpoint is Ada task-specific, return the Ada task id.
  297. If the breakpoint is not task-specific (or the underlying
  298. language is not Ada), return <code>#f</code>.
  299. </p></dd></dl>
  300. <dl>
  301. <dt><a name="index-set_002dbreakpoint_002dtask_0021"></a>Scheme Procedure: <strong>set-breakpoint-task!</strong> <em>breakpoint task</em></dt>
  302. <dd><p>Set the Ada task of <var>breakpoint</var> to <var>task</var>.
  303. If set to <code>#f</code>, the breakpoint is no longer task-specific.
  304. </p></dd></dl>
  305. <dl>
  306. <dt><a name="index-breakpoint_002dcondition"></a>Scheme Procedure: <strong>breakpoint-condition</strong> <em>breakpoint</em></dt>
  307. <dd><p>Return the condition of <var>breakpoint</var>, as specified by the user.
  308. It is a string. If there is no condition, return <code>#f</code>.
  309. </p></dd></dl>
  310. <dl>
  311. <dt><a name="index-set_002dbreakpoint_002dcondition_0021"></a>Scheme Procedure: <strong>set-breakpoint-condition!</strong> <em>breakpoint condition</em></dt>
  312. <dd><p>Set the condition of <var>breakpoint</var> to <var>condition</var>,
  313. which must be a string. If set to <code>#f</code> then the breakpoint
  314. becomes unconditional.
  315. </p></dd></dl>
  316. <dl>
  317. <dt><a name="index-breakpoint_002dstop"></a>Scheme Procedure: <strong>breakpoint-stop</strong> <em>breakpoint</em></dt>
  318. <dd><p>Return the stop predicate of <var>breakpoint</var>.
  319. See <code>set-breakpoint-stop!</code> below in this section.
  320. </p></dd></dl>
  321. <dl>
  322. <dt><a name="index-set_002dbreakpoint_002dstop_0021"></a>Scheme Procedure: <strong>set-breakpoint-stop!</strong> <em>breakpoint procedure|#f</em></dt>
  323. <dd><p>Set the stop predicate of <var>breakpoint</var>. The predicate
  324. <var>procedure</var> takes one argument: the &lt;gdb:breakpoint&gt; object.
  325. If this predicate is set to a procedure then it is invoked whenever
  326. the inferior reaches this breakpoint. If it returns <code>#t</code>,
  327. or any non-<code>#f</code> value, then the inferior is stopped,
  328. otherwise the inferior will continue.
  329. </p>
  330. <p>If there are multiple breakpoints at the same location with a
  331. <code>stop</code> predicate, each one will be called regardless of the
  332. return status of the previous. This ensures that all <code>stop</code>
  333. predicates have a chance to execute at that location. In this scenario
  334. if one of the methods returns <code>#t</code> but the others return
  335. <code>#f</code>, the inferior will still be stopped.
  336. </p>
  337. <p>You should not alter the execution state of the inferior (i.e., step,
  338. next, etc.), alter the current frame context (i.e., change the current
  339. active frame), or alter, add or delete any breakpoint. As a general
  340. rule, you should not alter any data within <small>GDB</small> or the inferior
  341. at this time.
  342. </p>
  343. <p>Example <code>stop</code> implementation:
  344. </p>
  345. <div class="smallexample">
  346. <pre class="smallexample">(define (my-stop? bkpt)
  347. (let ((int-val (parse-and-eval &quot;foo&quot;)))
  348. (value=? int-val 3)))
  349. (define bkpt (make-breakpoint &quot;main.c:42&quot;))
  350. (register-breakpoint! bkpt)
  351. (set-breakpoint-stop! bkpt my-stop?)
  352. </pre></div>
  353. </dd></dl>
  354. <dl>
  355. <dt><a name="index-breakpoint_002dcommands"></a>Scheme Procedure: <strong>breakpoint-commands</strong> <em>breakpoint</em></dt>
  356. <dd><p>Return the commands attached to <var>breakpoint</var> as a string,
  357. or <code>#f</code> if there are none.
  358. </p></dd></dl>
  359. <hr>
  360. <div class="header">
  361. <p>
  362. Next: <a href="Lazy-Strings-In-Guile.html#Lazy-Strings-In-Guile" accesskey="n" rel="next">Lazy Strings In Guile</a>, Previous: <a href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile" accesskey="p" rel="prev">Symbol Tables In Guile</a>, Up: <a href="Guile-API.html#Guile-API" accesskey="u" rel="up">Guile API</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>
  363. </div>
  364. </body>
  365. </html>