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-2021 Free Software Foundation, Inc. 4 5Permission is granted to copy, distribute and/or modify this document 6under the terms of the GNU Free Documentation License, Version 1.3 or 7any later version published by the Free Software Foundation; with the 8Invariant Sections being "Free Software" and "Free Software Needs 9Free Documentation", with the Front-Cover Texts being "A GNU Manual," 10and with the Back-Cover Texts as in (a) below. 11 12(a) The FSF's Back-Cover Text is: "You are free to copy and modify 13this GNU Manual. Buying copies from GNU Press supports the FSF in 14developing GNU and promoting software freedom." --> 15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 16<head> 17<title>Debugging with GDB: Breakpoints In Guile</title> 18 19<meta name="description" content="Debugging with GDB: Breakpoints In Guile"> 20<meta name="keywords" content="Debugging with GDB: Breakpoints In Guile"> 21<meta name="resource-type" content="document"> 22<meta name="distribution" content="global"> 23<meta name="Generator" content="makeinfo"> 24<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 25<link href="index.html#Top" rel="start" title="Top"> 26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> 27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 28<link href="Guile-API.html#Guile-API" rel="up" title="Guile API"> 29<link href="Lazy-Strings-In-Guile.html#Lazy-Strings-In-Guile" rel="next" title="Lazy Strings In Guile"> 30<link href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile" rel="previous" title="Symbol Tables In Guile"> 31<style type="text/css"> 32<!-- 33a.summary-letter {text-decoration: none} 34blockquote.smallquotation {font-size: smaller} 35div.display {margin-left: 3.2em} 36div.example {margin-left: 3.2em} 37div.indentedblock {margin-left: 3.2em} 38div.lisp {margin-left: 3.2em} 39div.smalldisplay {margin-left: 3.2em} 40div.smallexample {margin-left: 3.2em} 41div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 42div.smalllisp {margin-left: 3.2em} 43kbd {font-style:oblique} 44pre.display {font-family: inherit} 45pre.format {font-family: inherit} 46pre.menu-comment {font-family: serif} 47pre.menu-preformatted {font-family: serif} 48pre.smalldisplay {font-family: inherit; font-size: smaller} 49pre.smallexample {font-size: smaller} 50pre.smallformat {font-family: inherit; font-size: smaller} 51pre.smalllisp {font-size: smaller} 52span.nocodebreak {white-space:nowrap} 53span.nolinebreak {white-space:nowrap} 54span.roman {font-family:serif; font-weight:normal} 55span.sansserif {font-family:sans-serif; font-weight:normal} 56ul.no-bullet {list-style: none} 57--> 58</style> 59 60 61</head> 62 63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 64<a name="Breakpoints-In-Guile"></a> 65<div class="header"> 66<p> 67Next: <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="previous">Symbol Tables In Guile</a>, Up: <a href="Guile-API.html#Guile-API" accesskey="u" rel="up">Guile API</a> [<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> 68</div> 69<hr> 70<a name="Manipulating-breakpoints-using-Guile"></a> 71<h4 class="subsubsection">23.3.3.19 Manipulating breakpoints using Guile</h4> 72 73<a name="index-breakpoints-in-guile"></a> 74<a name="index-_003cgdb_003abreakpoint_003e"></a> 75 76<p>Breakpoints in Guile are represented by objects of type 77<code><gdb:breakpoint></code>. New breakpoints can be created with the 78<code>make-breakpoint</code> Guile function, and then added to <small>GDB</small> with the 79<code>register-breakpoint!</code> Guile function. 80This two-step approach is taken to separate out the side-effect of adding 81the breakpoint to <small>GDB</small> from <code>make-breakpoint</code>. 82</p> 83<p>Support is also provided to view and manipulate breakpoints created 84outside of Guile. 85</p> 86<p>The following breakpoint-related procedures are provided by the 87<code>(gdb)</code> module: 88</p> 89<dl> 90<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> 91<dd><p>Create a new breakpoint at <var>location</var>, a string naming the 92location of the breakpoint, or an expression that defines a watchpoint. 93The contents can be any location recognized by the <code>break</code> command, 94or in the case of a watchpoint, by the <code>watch</code> command. 95</p> 96<p>The breakpoint is initially marked as ‘<samp>invalid</samp>’. 97The breakpoint is not usable until it has been registered with <small>GDB</small> 98with <code>register-breakpoint!</code>, at which point it becomes ‘<samp>valid</samp>’. 99The result is the <code><gdb:breakpoint></code> object representing the breakpoint. 100</p> 101<p>The optional <var>type</var> denotes the breakpoint to create. 102This argument can be either <code>BP_BREAKPOINT</code> or <code>BP_WATCHPOINT</code>, 103and defaults to <code>BP_BREAKPOINT</code>. 104</p> 105<p>The optional <var>wp-class</var> argument defines the class of watchpoint to 106create, if <var>type</var> is <code>BP_WATCHPOINT</code>. If a watchpoint class is 107not provided, it is assumed to be a <code>WP_WRITE</code> class. 108</p> 109<p>The optional <var>internal</var> argument allows the breakpoint to become 110invisible to the user. The breakpoint will neither be reported when 111registered, nor will it be listed in the output from <code>info breakpoints</code> 112(but will be listed with the <code>maint info breakpoints</code> command). 113If an internal flag is not provided, the breakpoint is visible 114(non-internal). 115</p> 116<p>When a watchpoint is created, <small>GDB</small> will try to create a 117hardware assisted watchpoint. If successful, the type of the watchpoint 118is changed from <code>BP_WATCHPOINT</code> to <code>BP_HARDWARE_WATCHPOINT</code> 119for <code>WP_WRITE</code>, <code>BP_READ_WATCHPOINT</code> for <code>WP_READ</code>, 120and <code>BP_ACCESS_WATCHPOINT</code> for <code>WP_ACCESS</code>. 121If not successful, the type of the watchpoint is left as <code>WP_WATCHPOINT</code>. 122</p> 123<p>The available types are represented by constants defined in the <code>gdb</code> 124module: 125</p> 126<dl compact="compact"> 127<dt><code>BP_BREAKPOINT</code> 128<a name="index-BP_005fBREAKPOINT-1"></a> 129</dt> 130<dd><p>Normal code breakpoint. 131</p> 132</dd> 133<dt><code>BP_WATCHPOINT</code> 134<a name="index-BP_005fWATCHPOINT-1"></a> 135</dt> 136<dd><p>Watchpoint breakpoint. 137</p> 138</dd> 139<dt><code>BP_HARDWARE_WATCHPOINT</code> 140<a name="index-BP_005fHARDWARE_005fWATCHPOINT-1"></a> 141</dt> 142<dd><p>Hardware assisted watchpoint. 143This value cannot be specified when creating the breakpoint. 144</p> 145</dd> 146<dt><code>BP_READ_WATCHPOINT</code> 147<a name="index-BP_005fREAD_005fWATCHPOINT-1"></a> 148</dt> 149<dd><p>Hardware assisted read watchpoint. 150This value cannot be specified when creating the breakpoint. 151</p> 152</dd> 153<dt><code>BP_ACCESS_WATCHPOINT</code> 154<a name="index-BP_005fACCESS_005fWATCHPOINT-1"></a> 155</dt> 156<dd><p>Hardware assisted access watchpoint. 157This value cannot be specified when creating the breakpoint. 158</p></dd> 159</dl> 160 161<p>The available watchpoint types represented by constants are defined in the 162<code>(gdb)</code> module: 163</p> 164<dl compact="compact"> 165<dt><code>WP_READ</code> 166<a name="index-WP_005fREAD-1"></a> 167</dt> 168<dd><p>Read only watchpoint. 169</p> 170</dd> 171<dt><code>WP_WRITE</code> 172<a name="index-WP_005fWRITE-1"></a> 173</dt> 174<dd><p>Write only watchpoint. 175</p> 176</dd> 177<dt><code>WP_ACCESS</code> 178<a name="index-WP_005fACCESS-1"></a> 179</dt> 180<dd><p>Read/Write watchpoint. 181</p></dd> 182</dl> 183 184</dd></dl> 185 186<dl> 187<dt><a name="index-register_002dbreakpoint_0021"></a>Scheme Procedure: <strong>register-breakpoint!</strong> <em>breakpoint</em></dt> 188<dd><p>Add <var>breakpoint</var>, a <code><gdb:breakpoint></code> object, to <small>GDB</small>’s 189list of breakpoints. The breakpoint must have been created with 190<code>make-breakpoint</code>. One cannot register breakpoints that have been 191created outside of Guile. Once a breakpoint is registered it becomes 192‘<samp>valid</samp>’. 193It is an error to register an already registered breakpoint. 194The result is unspecified. 195</p></dd></dl> 196 197<dl> 198<dt><a name="index-delete_002dbreakpoint_0021"></a>Scheme Procedure: <strong>delete-breakpoint!</strong> <em>breakpoint</em></dt> 199<dd><p>Remove <var>breakpoint</var> from <small>GDB</small>’s list of breakpoints. 200This also invalidates the Guile <var>breakpoint</var> object. 201Any further attempt to access the object will throw an exception. 202</p> 203<p>If <var>breakpoint</var> was created from Guile with <code>make-breakpoint</code> 204it may be re-registered with <small>GDB</small>, in which case the breakpoint 205becomes valid again. 206</p></dd></dl> 207 208<dl> 209<dt><a name="index-breakpoints-1"></a>Scheme Procedure: <strong>breakpoints</strong></dt> 210<dd><p>Return a list of all breakpoints. 211Each element of the list is a <code><gdb:breakpoint></code> object. 212</p></dd></dl> 213 214<dl> 215<dt><a name="index-breakpoint_003f"></a>Scheme Procedure: <strong>breakpoint?</strong> <em>object</em></dt> 216<dd><p>Return <code>#t</code> if <var>object</var> is a <code><gdb:breakpoint></code> object, 217and <code>#f</code> otherwise. 218</p></dd></dl> 219 220<dl> 221<dt><a name="index-breakpoint_002dvalid_003f"></a>Scheme Procedure: <strong>breakpoint-valid?</strong> <em>breakpoint</em></dt> 222<dd><p>Return <code>#t</code> if <var>breakpoint</var> is valid, <code>#f</code> otherwise. 223Breakpoints created with <code>make-breakpoint</code> are marked as invalid 224until they are registered with <small>GDB</small> with <code>register-breakpoint!</code>. 225A <code><gdb:breakpoint></code> object can become invalid 226if the user deletes the breakpoint. In this case, the object still 227exists, but the underlying breakpoint does not. In the cases of 228watchpoint scope, the watchpoint remains valid even if execution of the 229inferior leaves the scope of that watchpoint. 230</p></dd></dl> 231 232<dl> 233<dt><a name="index-breakpoint_002dnumber"></a>Scheme Procedure: <strong>breakpoint-number</strong> <em>breakpoint</em></dt> 234<dd><p>Return the breakpoint’s number — the identifier used by 235the user to manipulate the breakpoint. 236</p></dd></dl> 237 238<dl> 239<dt><a name="index-breakpoint_002dtype"></a>Scheme Procedure: <strong>breakpoint-type</strong> <em>breakpoint</em></dt> 240<dd><p>Return the breakpoint’s type — the identifier used to 241determine the actual breakpoint type or use-case. 242</p></dd></dl> 243 244<dl> 245<dt><a name="index-breakpoint_002dvisible_003f"></a>Scheme Procedure: <strong>breakpoint-visible?</strong> <em>breakpoint</em></dt> 246<dd><p>Return <code>#t</code> if the breakpoint is visible to the user 247when hit, or when the ‘<samp>info breakpoints</samp>’ command is run. 248Otherwise return <code>#f</code>. 249</p></dd></dl> 250 251<dl> 252<dt><a name="index-breakpoint_002dlocation"></a>Scheme Procedure: <strong>breakpoint-location</strong> <em>breakpoint</em></dt> 253<dd><p>Return the location of the breakpoint, as specified by 254the user. It is a string. If the breakpoint does not have a location 255(that is, it is a watchpoint) return <code>#f</code>. 256</p></dd></dl> 257 258<dl> 259<dt><a name="index-breakpoint_002dexpression"></a>Scheme Procedure: <strong>breakpoint-expression</strong> <em>breakpoint</em></dt> 260<dd><p>Return the breakpoint expression, as specified by the user. It is a string. 261If the breakpoint does not have an expression (the breakpoint is not a 262watchpoint) return <code>#f</code>. 263</p></dd></dl> 264 265<dl> 266<dt><a name="index-breakpoint_002denabled_003f"></a>Scheme Procedure: <strong>breakpoint-enabled?</strong> <em>breakpoint</em></dt> 267<dd><p>Return <code>#t</code> if the breakpoint is enabled, and <code>#f</code> otherwise. 268</p></dd></dl> 269 270<dl> 271<dt><a name="index-set_002dbreakpoint_002denabled_0021"></a>Scheme Procedure: <strong>set-breakpoint-enabled!</strong> <em>breakpoint flag</em></dt> 272<dd><p>Set the enabled state of <var>breakpoint</var> to <var>flag</var>. 273If flag is <code>#f</code> it is disabled, otherwise it is enabled. 274</p></dd></dl> 275 276<dl> 277<dt><a name="index-breakpoint_002dsilent_003f"></a>Scheme Procedure: <strong>breakpoint-silent?</strong> <em>breakpoint</em></dt> 278<dd><p>Return <code>#t</code> if the breakpoint is silent, and <code>#f</code> otherwise. 279</p> 280<p>Note that a breakpoint can also be silent if it has commands and the 281first command is <code>silent</code>. This is not reported by the 282<code>silent</code> attribute. 283</p></dd></dl> 284 285<dl> 286<dt><a name="index-set_002dbreakpoint_002dsilent_0021"></a>Scheme Procedure: <strong>set-breakpoint-silent!</strong> <em>breakpoint flag</em></dt> 287<dd><p>Set the silent state of <var>breakpoint</var> to <var>flag</var>. 288If flag is <code>#f</code> the breakpoint is made silent, 289otherwise it is made non-silent (or noisy). 290</p></dd></dl> 291 292<dl> 293<dt><a name="index-breakpoint_002dignore_002dcount"></a>Scheme Procedure: <strong>breakpoint-ignore-count</strong> <em>breakpoint</em></dt> 294<dd><p>Return the ignore count for <var>breakpoint</var>. 295</p></dd></dl> 296 297<dl> 298<dt><a name="index-set_002dbreakpoint_002dignore_002dcount_0021"></a>Scheme Procedure: <strong>set-breakpoint-ignore-count!</strong> <em>breakpoint count</em></dt> 299<dd><p>Set the ignore count for <var>breakpoint</var> to <var>count</var>. 300</p></dd></dl> 301 302<dl> 303<dt><a name="index-breakpoint_002dhit_002dcount"></a>Scheme Procedure: <strong>breakpoint-hit-count</strong> <em>breakpoint</em></dt> 304<dd><p>Return hit count of <var>breakpoint</var>. 305</p></dd></dl> 306 307<dl> 308<dt><a name="index-set_002dbreakpoint_002dhit_002dcount_0021"></a>Scheme Procedure: <strong>set-breakpoint-hit-count!</strong> <em>breakpoint count</em></dt> 309<dd><p>Set the hit count of <var>breakpoint</var> to <var>count</var>. 310At present, <var>count</var> must be zero. 311</p></dd></dl> 312 313<dl> 314<dt><a name="index-breakpoint_002dthread"></a>Scheme Procedure: <strong>breakpoint-thread</strong> <em>breakpoint</em></dt> 315<dd><p>Return the global-thread-id for thread-specific breakpoint 316<var>breakpoint</var>. Return #f if <var>breakpoint</var> is not 317thread-specific. 318</p></dd></dl> 319 320<dl> 321<dt><a name="index-set_002dbreakpoint_002dthread_0021"></a>Scheme Procedure: <strong>set-breakpoint-thread!</strong> <em>breakpoint global-thread-id|#f</em></dt> 322<dd><p>Set the thread-id for <var>breakpoint</var> to <var>global-thread-id</var> If 323set to <code>#f</code>, the breakpoint is no longer thread-specific. 324</p></dd></dl> 325 326<dl> 327<dt><a name="index-breakpoint_002dtask"></a>Scheme Procedure: <strong>breakpoint-task</strong> <em>breakpoint</em></dt> 328<dd><p>If the breakpoint is Ada task-specific, return the Ada task id. 329If the breakpoint is not task-specific (or the underlying 330language is not Ada), return <code>#f</code>. 331</p></dd></dl> 332 333<dl> 334<dt><a name="index-set_002dbreakpoint_002dtask_0021"></a>Scheme Procedure: <strong>set-breakpoint-task!</strong> <em>breakpoint task</em></dt> 335<dd><p>Set the Ada task of <var>breakpoint</var> to <var>task</var>. 336If set to <code>#f</code>, the breakpoint is no longer task-specific. 337</p></dd></dl> 338 339<dl> 340<dt><a name="index-breakpoint_002dcondition"></a>Scheme Procedure: <strong>breakpoint-condition</strong> <em>breakpoint</em></dt> 341<dd><p>Return the condition of <var>breakpoint</var>, as specified by the user. 342It is a string. If there is no condition, return <code>#f</code>. 343</p></dd></dl> 344 345<dl> 346<dt><a name="index-set_002dbreakpoint_002dcondition_0021"></a>Scheme Procedure: <strong>set-breakpoint-condition!</strong> <em>breakpoint condition</em></dt> 347<dd><p>Set the condition of <var>breakpoint</var> to <var>condition</var>, 348which must be a string. If set to <code>#f</code> then the breakpoint 349becomes unconditional. 350</p></dd></dl> 351 352<dl> 353<dt><a name="index-breakpoint_002dstop"></a>Scheme Procedure: <strong>breakpoint-stop</strong> <em>breakpoint</em></dt> 354<dd><p>Return the stop predicate of <var>breakpoint</var>. 355See <code>set-breakpoint-stop!</code> below in this section. 356</p></dd></dl> 357 358<dl> 359<dt><a name="index-set_002dbreakpoint_002dstop_0021"></a>Scheme Procedure: <strong>set-breakpoint-stop!</strong> <em>breakpoint procedure|#f</em></dt> 360<dd><p>Set the stop predicate of <var>breakpoint</var>. The predicate 361<var>procedure</var> takes one argument: the <gdb:breakpoint> object. 362If this predicate is set to a procedure then it is invoked whenever 363the inferior reaches this breakpoint. If it returns <code>#t</code>, 364or any non-<code>#f</code> value, then the inferior is stopped, 365otherwise the inferior will continue. 366</p> 367<p>If there are multiple breakpoints at the same location with a 368<code>stop</code> predicate, each one will be called regardless of the 369return status of the previous. This ensures that all <code>stop</code> 370predicates have a chance to execute at that location. In this scenario 371if one of the methods returns <code>#t</code> but the others return 372<code>#f</code>, the inferior will still be stopped. 373</p> 374<p>You should not alter the execution state of the inferior (i.e., step, 375next, etc.), alter the current frame context (i.e., change the current 376active frame), or alter, add or delete any breakpoint. As a general 377rule, you should not alter any data within <small>GDB</small> or the inferior 378at this time. 379</p> 380<p>Example <code>stop</code> implementation: 381</p> 382<div class="smallexample"> 383<pre class="smallexample">(define (my-stop? bkpt) 384 (let ((int-val (parse-and-eval "foo"))) 385 (value=? int-val 3))) 386(define bkpt (make-breakpoint "main.c:42")) 387(register-breakpoint! bkpt) 388(set-breakpoint-stop! bkpt my-stop?) 389</pre></div> 390</dd></dl> 391 392<dl> 393<dt><a name="index-breakpoint_002dcommands"></a>Scheme Procedure: <strong>breakpoint-commands</strong> <em>breakpoint</em></dt> 394<dd><p>Return the commands attached to <var>breakpoint</var> as a string, 395or <code>#f</code> if there are none. 396</p></dd></dl> 397 398<hr> 399<div class="header"> 400<p> 401Next: <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="previous">Symbol Tables In Guile</a>, Up: <a href="Guile-API.html#Guile-API" accesskey="u" rel="up">Guile API</a> [<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> 402</div> 403 404 405 406</body> 407</html> 408