next up previous contents
Next: Solutions and Comments Up: Prolog Programming A Previous: References

Details of the SICStus Prolog Tracer

  The description of the SICStus Prolog tracer follows closely the description of the Quintus Prolog tracer since these two Prolog systems are very similar. We consider version 0.6 here as defined in [SICStus, 1988].

The SICStus debugger is a development of the DEC-10 debugger. It is described in terms of the so-called four port model of Prolog execution. The four ports are call, exit, redo and fail. Full tracing only applies to non-compiled code but some limited tracing can be done for compiled code. The behaviour is similar to the treatment of system predicates.

Monitor Execution:
Different kinds of control are provided. The difference between debug and trace is that trace goes into creep mode directly whereas debug waits for some decision from the user to start offering the standard range of debugging options. Both otherwise cause the system to save relevant information.

The predicate nodebug/0 switches off debugging and the predicate debugging/0 shows the action on finding an unknown predicate, whether debugging is in action or not, which predicates are spied and what mode of leashing is in force.

Control of Information Shown:
Controlling Amount of Execution Information:
Spypoints can be set for any number of relations via the predicate spy/1. The argument of spy might be a predicate name or a name/ arity or a list of such. Undefined predicates can be spied by using the name/ arity form of argument.

Controlling Amount of Interaction:
The leash/1 predicate is provided to control the amount of interaction with the programmer. The options are: full (prompt on call, exit redo and fail), tight (prompt on call, redo and fail), half (prompt on call and redo), and loose (prompt on call)gif.
Controlling Amount of Term Visible:
Representing a complex term by ellipsis is done automatically in the debugger but the user can control the complexity of displayed terms. There do not appear to be any supplied procedures to manage the depth when using write/1 etc. There is also a way of examining subterms via the set subterm option within the debugger.

Going Forwards:
There are several different versions of the `next interesting event'.
A Step at a Time:
The user is able to single step through the code using the creep option.
On to Next Spy Point:
The user is able to jump to the next predicate that is spied using the leap option.
Skip:
The skip option jumps to the exit/ fail port of the procedure or the first procedure encountered that has a spy-point. Only available at the call/ redo ports. It does not stop at spy points.

Going Backwards:
Single stepping backwards versus jumping back to the last choice point.
Retry a Previous Goal:
The retry command transfers control back to the call port of the current box. Everything is as it was unless any assert/ retracts have taken place. It is possible to give an argument to retry the computation from much further back ---this gets messed up usually by cut (!). Side effects are, inevitably, not undone. This includes clauses asserted etc.

Interfering with Execution:
Different ways of handling this.
Forcing Failure:
While tracing, the programmer is able to force a failure even though a goal would succeed. This can be done via the unify option. Just try to unify the current goal with some impossible term.
Forcing Success:
This feature is provided via the unify choise at the Call port for a goal. This could be badly abused.
Find Another Solution:
This does not seem to be possible.

Examining a Goal:
Different ways of looking at Prolog terms.
Writing a Goal:
Printing the goal with the syntax obtained by applying any operator declarations in force.
Pretty Printing a Goal:
Printing the goal possibly using the user defined portray/1, if possible.
Displaying Underlying Syntax:
Showing the regular syntax of some goal using display/1

Showing Context:
Details of the execution in terms of what has happened, what has yet to be done and the source code.
Ancestors:
Looking at some possibly user-defined number of ancestor goals. Equivalent to the ancestors/0 command.

Breaking Out:
Providing the facility to access Prolog while tracing ---with sometimes irreversible consequences.
Single Command:
A single command can be executed.
New Interpreter:
A new incarnation of Prolog is initiated via a call to break which will be in force until either another break command is given, or an abort or an end_of_file character.
Aborting Execution
Calls the command abort/0 which aborts the execution back to top level, throwing all incarnations of the interpreter away.



next up previous contents
Next: Solutions and Comments Up: Prolog Programming A Previous: References



Paul Brna
Mon May 24 20:14:48 BST 1999