list-traps can be used to print a description of all known trap
objects. This uses a weak value hash table, keyed by a trap index
number. Each trap object has its index number assigned, and is added
to the hash table, when it is created by a make trap-class
... call. When a trap object is GC'd, it is automatically
removed from the hash table, and so no longer appears in the output
from list-traps.
The following example shows a single trap that traces applications of
the procedure facti.
guile> (list-traps)
#<<procedure-trap> 100d2e30> is an instance of class <procedure-trap>
Slots are:
number = 1
installed = #t
condition = #f
skip-count = 0
single-shot = #f
behaviour = (#<procedure trace-trap (trap-context)>)
repeat-identical-behaviour = #f
procedure = #<procedure facti (n a)>
When all-traps or list-traps reveals a trap that you
want to modify but no longer have a reference to, you can retrieve the
trap object by calling get-trap with the trap's number. For
example, here's how you could change the behaviour of the trap listed
just above.
(slot-set! (get-trap 1) 'behaviour (list debug-trap))