next up previous index
Next: Switching To Creep Mode Up: Debugging Previous: Using the Debugger via   Index

Subsections

Extending the Debugger

User-defined Ports

The primitive trace_port(?Invoc, +Port, +Term) allows the programmer to create user-defined debugger ports, thus enhancing the debugger's basic box model with application-specific checkpoints. Calls to trace_port/3 can be inserted in the code, and when the debugger is on, they will cause execution to stop and enter the debugger, displaying a trace line with the user-defined port and data.

The following example defines two special ports that indicate that values are selected for a boolean variable:

:- pragma(nodebug).
bool(B) :-
    trace_port(Invoc, 'TRY_ZERO', B=0),  
    (
        B=0
    ;
        trace_port(Invoc, 'TRY_ONE', B=1),
        B=1
    ).
:- untraceable bool/1.
In the execution, this will look as follows:
[eclipse 9]: bool(B).
(3) 3 TRY_ZERO  B = 0 %> creep

B = 0     More? (;) 
(3) 3 TRY_ONE  B = 1 %> creep

B = 1
yes.
Note that both ports share the same invocation number, so the i command can be used to skip from one to the other.




1999-08-06