Debug Mode

We can distinguish a couple of debugging modes. In any debugging mode the instrumented fork of a clause will be executed. Depending on the debugging mode the instrumentation will check a certain condition and when this condition is met the current execution is suspended and a callback is called. The debugging modes are:

Table 2: Debugging Modes

Mode

Visual

Condition

off

-

Run until paused or aborted

step in

 

Run until next port

step over

=

Run until predicate is executed

step out

>

Run until parent predicate is executed

on

*

Run until next spy or break point

When the current goal is shown additional information about the debugging mode, the invoca-tion depth and the current port is shown as well. Last call optimization is currently defunct while debugging, the invocation depth is therefore larger than usual. The information is provided in the following format on the display console:

   <mode> <depth> <port> <goal> ?

Predicates that have the sys_notrace predicate property set are ignored in any debugging mode. A couple of predicates that resemble commands, e.g. listing/1, trace/1, etc., have the sys_notrace predicate property by default set. Predicates that are invoked from within a source which has the sys_notrace source property set are as well ignored in any debugging mode. The system sources have the sys_notrace source property by default set.

The following debug mode predicates are provided:
nodebug:
The predicate switches to the off debugging mode.
trace:
The predicate switches to the step in debugging mode.
skip:
The predicate switches to the step over debugging mode.
up:
The predicate switches to the step out debugging mode.
debug:
The predicate switches to the on debugging mode.
visible(L):
Show the ports that are listed in L, hide the ports that are not listed in L. In debug mode, hidden ports are not further debugged but simply continue. The following mnemonics work for the predicate:
off:
Never prompt.
loose:
Only prompt on call port.
half:
Only prompt on call and redo port.
tight:
Only prompt on call, redo and fail port.
full:
Prompt on call, exit, redo and fail port
all:
Prompt on call, exit, redo, fail and head port.

debugging:
The predicate shows the debug mode, the spy points and the break points.
spy(P):
The predicate adds the predicate P to the spy points.
nospy(P):
The predicate removes the predicate P from the spy points.
spying(P):
The predicate succeeds in P for every spy point.
break(F, L):
The predicate adds the file F and the line number L to the break points.
nobreak(F, L):
The predicate removes the file F and the line number L from the break points.
breaking(F, L):
For every break point the predicate succeeds with the file F and the line number L

The following debug mode Prolog flags are provided:

unknown: [ISO 7.11.2.4]
Legal values are error [ISO], fail [ISO] and warning [ISO]. The flag indicates how undefined predicates should be executed. Default value is error. Currently the value cannot be changed.
debug: [ISO 7.11.2.2]
The legal values are on [ISO], step_in, step_over, step_out and off [ISO]. The value indicates the debugging mode the current thread is in. Default value is off. The value can be changed.
sys_max_stack:
The property indicates the size of the stack trace that should be generated for an exception. Legal values are non-negative integers. The value can be changed.
sys_visible:
Legal values are lists of debugger ports. Legal debugger ports are call, exit, redo, fail, head and chop. The flag is per interpreter. The default value is [call,exit,redo,fail]. The value can be changed.

Kommentare