next up previous
Next: Exception Handling Up: Hackers corner Previous: Examining the Environment

Intercepting the Tracer

prolog_trace_interception( +Port, +Frame, -Action)

  Dynamic predicate, normally not defined. This predicate is called from the SWI-Prolog debugger just before it would show a port. If this predicate succeeds the debugger assumes the trace action has been taken care of and continues execution as described by Action. Otherwise the normal Prolog debugger actions are performed.

Port is one of call , redo , exit , fail or unify . Frame is an integer reference to the current local stack frame. Action should be unified with one of the atoms continue (just continue execution), retry (retry the current goal) or fail (force the current goal to fail). Leaving it a variable is identical to continue .

Together with the predicates described in section gif and the other predicates of this chapter this predicate enables the Prolog user to define a complete new debugger in Prolog. Besides this it enables the Prolog programmer monitor the execution of a program. The example shown in figure gif records all goals trapped by the tracer in the database. To trace the execution of `go' this way the following query should be given:

  
Figure: Record a trace in the database

prolog_skip_level( -Old, +New)

  Unify Old with the old value of `skip level' and than set this level according to New. New is an integer, or the special atom very_deep (meaning don't skip). The `skip level' is a global variable of the Prolog system that disables the debugger on all recursion levels deeper than the level of the variable. Used to implement the trace options `skip' (sets skip level to the level of the frame) and `up' (sets skip level to the level of the parent frame (i.e.\ the level of this frame minus 1).



next up previous
Next: Exception Handling Up: Hackers corner Previous: Examining the Environment



Passani Luca
Tue Nov 14 08:58:33 MET 1995