Next: Enabling and Disabling, Previous: Accessing Breakpoints, Up: Intro to Breakpoints
A breakpoint's behaviour determines what happens when that breakpoint is hit. Several kinds of behaviour are generally useful.
debug-here
trace-here
trace-subtree
trace-subtree
is a great preliminary exploration tool when all
you know is that there is a bug “somewhere in XXX or in something that
XXX calls”.
(at-exit
thunk)
(at-exit debug-here)
.
(at-next
count thunk)
(at-entry
count thunk)
(at-apply
count thunk)
(at-step
count thunk)
at-entry
and at-apply
; counts both
evaluations and applications.
Every breakpoint instance has a slot in which its behaviour is stored.
If you have a breakpoint instance in hand, you can change its behaviour
using the bp-behaviour
accessor.
An accessor supports the setting of a property like this:
(set! (bp-behaviour breakpoint) new-behaviour)
See the GOOPS manual for further information on accessors.
Alternatively, if you know how to specify the location-args for
the breakpoint in question, you can change its behaviour using
set-breakpoint!
. For example:
;; Change behaviour of breakpoint number 2. (set-breakpoint! new-behaviour 2) ;; Change behaviour of procedural breakpoint on [fact1]. (set-breakpoint! new-behaviour fact1)
In all cases, the behaviour that you specify should be either a single thunk, or a list of thunks, to be called when the breakpoint is hit.
The most common behaviours above are exported as thunks from the
(ice-9 debugger behaviour)
module. So, if you use this module, you can
use those behaviours directly like this:
(use-modules (ice-9 debugger behaviour)) (set-breakpoint! trace-subtree 2) (set! (bp-behaviour (get-breakpoint 3)) debug-here)
You can also use the list option to combine common behaviours:
(set-breakpoint! (list trace-here debug-here) 2)
Or, for more customized behaviour, you could build and use your own thunk like this:
(define (my-behaviour) (trace-here) (at-exit (lambda () (display "Exiting frame of my-behaviour bp\n") ... do something unusual ...))) (set-breakpoint my-behaviour 2)