Next: , Previous: Specifying Trap Behaviour, Up: Traps


5.21.3.4 Trap Context

The trap context is an object that caches information about the low level trap call and the stack at the point of the trap, and is passed as the only argument to all behaviour procedures. The information in the trap context can be accessed through the procedures beginning tc: that are exported by the (ice-9 debugging traps) module1; the most useful of these are as follows.

— Generic Function: tc:type trap-context

Indicates the type of the low level trap by returning one of the keywords #:application, #:evaluation, #:return or #:error.

— Generic Function: tc:return-value trap-context

When tc:type gives #:return, this provides the value that is being returned.

— Generic Function: tc:stack trap-context

Provides the stack at the point of the trap (as computed by make-stack, but cached so that the lengthy make-stack operation is not performed more than once for the same low level trap).

— Generic Function: tc:frame trap-context

The innermost frame of the stack at the point of the trap.

— Generic Function: tc:depth trap-context

The number of frames (including tail recursive non-real frames) in the stack at the point of the trap.

— Generic Function: tc:real-depth trap-context

The number of real frames (that is, excluding the non-real frames that describe tail recursive calls) in the stack at the point of the trap.


Footnotes

[1] Plus of course any procedures that build on these, such as the trace/... procedures exported by (ice-9 debugging trace) (see Tracing Configuration).