
The following tools are provided for both interactive and non-interactive tracing/monitoring of the solver and the abstract domain operations.
During analysis, the solver can emit messages to the top level reporting on the operations in the analysis graph as they are being performed. This is particularly useful in combination with the raw output, since node ids in the graph match those in the raw true assertions and the true annotations.
For enabling this feature, comment out the
:- use_package(ciaopp(plai/notrace)).
directive in the src/plai/fixpoint_options.pl file, and recompile CiaoPP:
$ ciao build --bin ciaopp
In some cases cleaning may be necessary before recompilation, because of possible undetected dependencies during incremental compilation due to included files:
$ ciao clean ciaopp $ ciao build --bin ciaopp
Then, set preprocess flag trace_fixp to trace, which, if you are using the CiaoPP top level, can be done by:
ciaopp ?- set_pp_flag(trace_fixp, trace).or, if you are using the CiaoPP command line interface, it can be done by:
$ ciaopp -A <file> -ftrace_fixp=trace
Additionally, and only from the CiaoPP top level, if the preprocess flag timestamp_trace is set to on, a timestamp is printed when tracing. This can be helpful for diagnosing performance issues.
In addition to the raw tracing above, an abstract debugging tool is provided on top of it that is analogous to the standard source-level debugger (see The interactive debugger), but for the abstract execution of a program. As in the standard debugger, the interactive abstract debugger can highlight the point in the source code that corresponds to the current step being performed by the analysis. The actual highlighting of the source lines is handled by the editor/IDE (Emacs, VS Code, Playground, etc.).
The abstract debugger extends Byrd's Procedure Box model of debugging execution, which provides a simple way of visualizing control flow at the predicate level.
In the standard Byrd model, each predicate call is represented as a box with four ports: Call, Exit, Redo, and Fail. The abstract debugger reuses this same structure, but the transitions between ports now reflect the abstract execution of the program rather than its concrete execution. That is, instead of displaying (inlined) unifications (e.g., p(a)), the abstract debugger displays abstract substitutions belonging to the abstract domain being used (e.g., p(X): [ground([X])] for the groundness domain).
Consider the following diagrams:
Literal (also entry, i.e., initial call)
Call ┌─────────────┐ Succ
───────────►│ Procedure │───────────►
└─────────────┘Procedure WidenCall FixpStart ┌───────────┐ WidenSucc FixpEnd
─ ─ ─ ─ ─ ─►─────────►│ Clauses │─ ─ ─ ─ ─ ─►───────►
└───────────┘
▲ │
└───┘
FixpIterClauses VisitClause ┌────────────┐ ExitClause Comb
───────────►│ Clause │────────────►──────►
└────────────┘ │
▲ │
└───────────┘
ExitClauseClause Proj Entry ┌────────────┐ Exit Prime
────►─────►│ Literals │─────►─────►
└────────────┘There are labeled arrows (representing ports) indicating the control flow in and out of the procedure boxes. The abstract substitution at each port is displayed at every step. The meaning of each labeled arrow (port) in the abstract setting is as follows:The format of the abstract debugging messages mimics that of regular debugging, so the reader is referred to the interactive debugger's manual for details. However, here we discuss some slight differences:
Instead of (in-lined) unifications, abstract debugging messages show first the subgoal under analysis, then the abstract substitution, and, when changing variable context, the variable binding equations.
For example, the following abstract debugging messages:
1 1 Call: integers(Low_1,High_1,Is_1): [int(Low_1),int(High_1),term(Is_1)] ?
2 1 Entry: integers(Low_2,High_2,[Low_2|Is_2]): [int(Low_2),int(High_2),term(Is_2)]
➔ with [Low_2=Low_1,High_2=High_1,[Low_2|Is_2]=Is_1] ? produced when analyzing the following program:
:- pred integers(Low, High, Is) : (int(Low), int(High)) => int(Is).
integers(Low, High, [Low | Rest]) :-
Low =< High, !,
M is Low + 1,
integers(M, High, Rest).
integers(_,_,[]). Show:
Ports can be "unleashed." This means that the debugger will stop and display the corresponding message while not allowing the user to interact with it. Obviously, the ? prompt will not be shown in such messages, since the user has specified that no interaction is desired at this point.
Also, ports can be "hidden." This means that the debugger will not stop nor display the corresponding message.
Abstract debugging is enabled via PLAI's tracing facilities, as in Tracing the fixpoint operations. However, the trace_fixp flag needs to be set to debug. I.e., the steps to follow are:
?- module(example).
...
?- analyze(shfr).
@{Analyzing (shfr): [/private/tmp/p.pl]
@{init for the plai fixpoint in 0.196 msec.@}
@{preprocessed for the plai fixpoint in 0.395 msec.@}
1 1 Call: p(_3706): [sharing([[_3706]])] ? ;
2 1 Entry: p(_3928): [sharing([[_3928]])] with [_3928=_3706] ? ;
3 1 Call: q(_3928): [sharing([[_3928]])] ? ;
4 2 Call: q(_3928): [sharing([[_3928]])] ? ;
5 2 Entry: q(_4694): [sharing([[_4694]])] with [_4694=_3928] ?
... If this is done within one of the supported IDEs (Emacs, VS Code, Playground, etc.) the corresponding element in the source program will be highlighted, as in the standard source debugger.
Note that the daVinci executable has to be accessible in the path for Ciao.
?- trace_fixp(view). % This will open a uDraw(Graph) window yes ?- module(PathToModule). % load the module to analyze (located in PathToModule) yes ?- analyze(AbsInt). % Analyze for abstract domain AbsInt % The process will appear in the uDraw(Graph) window. yes ?- trace_fixp(no). % Stop the tracing
A menu is generated in uDraw(Graph) (Edit) that allows to execute the analysis in a synchronous and asynchronous way (see Edit->Mode) to switch options.
If the synchronous option is on, once the analysis has started, the visualization (and the fixpoint) will do one operation each step. The next step will be performed only if command Edit->'One step ahead' is executed.
Go to any module, add :- use_package(rtchecks). and recompile by
$ ciao build --bin ciaopp
Modules recommended: