Next: , Previous: Source Traps, Up: Traps


5.21.3.16 Location Traps

The <location-trap> class implements traps that are triggered by evaluation of code at a specific source location. When compared with source traps, they are easier to set, and do not become irrelevant when the relevant code is reloaded; but unfortunately they are a lot less efficient, as they require running some “are we in the right place for a trap” code on every low level frame entry trap call.

— Class: <location-trap>

Class for traps triggered by evaluation of code at a specific source location.

— Trap Option: #:file-regexp regexp

A regular expression specifying the filenames that will match this trap. This option must be specified when creating a location trap.

— Trap Option: #:line line

The line number (0-based) of the source location at which the trap should be triggered. This option must be specified when creating a location trap.

— Trap Option: #:column column

The column number (0-based) of the source location at which the trap should be triggered. This option must be specified when creating a location trap.

Here is an example, which matches the (facti (- n 1) (* a n)) expression in ice-9/debugging/example-fns.scm:

     (install-trap (make <location-trap>
                     #:file-regexp "example-fns.scm"
                     #:line 11
                     #:column 6
                     #:behaviour gds-debug-trap))