[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.25.4 Traps
Guile’s virtual machine can be configured to call out at key points to arbitrary user-specified procedures.
In principle, these hooks allow Scheme code to implement any model it chooses for examining the evaluation stack as program execution proceeds, and for suspending execution to be resumed later.
VM hooks are very low-level, though, and so Guile also has a library of higher-level traps on top of the VM hooks. A trap is an execution condition that, when fulfilled, will fire a handler. For example, Guile defines a trap that fires when control reaches a certain source location.
Finally, Guile also defines a third level of abstractions: per-thread trap states. A trap state exists to give names to traps, and to hold on to the set of traps so that they can be enabled, disabled, or removed. The trap state infrastructure defines the most useful abstractions for most cases. For example, Guile’s REPL uses trap state functions to set breakpoints and tracepoints.
The following subsections describe all this in detail, for both the user wanting to use traps, and the developer interested in understanding how the interface hangs together.
6.25.4.1 VM Hooks | Modifying Guile’s virtual machine. | |
6.25.4.2 Trap Interface | Traps are on or off. | |
6.25.4.3 Low-Level Traps | The various kinds of low-level traps. | |
6.25.4.4 Tracing Traps | Traps to trace procedure calls and returns. | |
6.25.4.5 Trap States | One state (per thread) to bind them. | |
6.25.4.6 High-Level Traps | The highest-level trap interface. Use this. |
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on April 20, 2013 using texi2html 5.0.