SWI-Prolog offers two debuggers. One is the traditional text console-based 4-port Prolog tracer and the other is a window-based source level debugger. The window-based debugger requires XPCE installed. It operates based on the prolog_trace_interception/4 hook and other low-level functionality described in chapter B.
Window-based tracing provides a much better overview due to the eminent relation to your source code, a clear list of named variables and their bindings as well as a graphical overview of the call and choice point stack. There are some drawbacks though. Using a textual trace on the console, one can scroll back and examine the past, while the graphical debugger just presents a (much better) overview of the current state.
Whether the text-based or window-based debugger is used is controlled
using the predicates guitracer/0
and noguitracer/0.
Entering debug mode is controlled using the normal predicates for this: trace/0
and
spy/1.
In addition, PceEmacs prolog mode provides the command
Prolog/Break at (Control-c b
) to insert a
break-point at a specific location in the source code.
The graphical tracer is particulary useful for debugging threads. The
tracer must be loaded from the main
thread before it can be
used from a background thread.
Control-c b
).guitracer,trace
.guitracer,debug
.guitracer,spy(Predicate)
.