Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
The PDT lets you use all the built-in tracing facilities of SWI-Prolog. The SWI-Prolog tracer is invoked by calling trace
before the goal you want to trace. For instance, if you want to trace the execution of p(X,Y,Z) you call:
?- trace, p(X,Y,Z).
What you get as a result of such a call depends on the enabled tracing mode:
In console tracing mode, each 'RETURN' shows you the next “step” of the logic program's execution. For a full listing of possible console tracing actions hit 'h' and 'RETURN'. Here is how console tracing looks after a series of “step” commands:
A note to Mac users To use the GUI tracer you need to have a X11 server running. On the Mac you need to start it explicitly, it is not on by default.
The GUI tracer is enabled / disabled by using the GUI tracer toggle button in the Prolog Console Toolbar:
Alternatively, the GUI tracer is enabled / disabled by typing guitracer
/ noguitracer
in the Prolog Console 1):
If GUI tracing is enabled, the query
?- trace, p(X,Y,Z).
opens the SWI-Prolog GUI tracer as a new window ( A note to Windows users On Windows the GUI tracer window is intially iconified. Look for its symbol in the task bar and expand it to see the view shown below.) ) that
The tool bar of the SWI-Prolog GUI tracer offers some useful shortcuts
The buttons in (1) provide - from left to right - the option to show the unifier for the current goal, step into the current goal's execution, step over it or finish the selected goal. The buttons in (2) provide - from left to right – the option to step to the next spy point, add spy points, set a stop at the caret and to remove spy points. For details on other buttons see the respective tool tip.
If a variable's value is too long to fit in the bindings frame (1) you can view it in full in a separate window by double clicking the variable in (1)
ViaEdit > Breakpoints
you can define spy points on predicates occurring in the program (by entering the predicate's name/arity and then pressing the left-most button – see red arrow).