☰

Inspecting PLAI analysis results

Author(s): Isabel Garcia-Contreras, Marco Ciccalè (minor improvements), Manuel Hermenegildo (minor improvements).

We describe here different facilities available for inspecting analysis results.

Messages and output files

CiaoPP produces normally two types of outputs:

  • Messages emitted during CiaoPP's operation: information on the abstract domains being used, transformations performed, processing times, results of assertion checking, etc.

  • An output file (or a series of them) containing the source program annotated with the analysis results (as true assertions), and the results of assertion checking, transformations, etc.

The level of detail in both messages and output files can be controlled using preprocessor flags. Some examples:

  • In the output files results are normally given at the procedure level (call and success states) but information can be obtained for each program point (each point between two literals or primitive statements) by setting the pp_info flag to on.

  • Similarly, by default simplified results are provided which collapse all generated versions (e.g., call/success pairs) for each predicate. This saves clutter but reduces the observable precision. However, this can be avoided setting the collapse_ai_vers flag to off.

  • Equally, info on the abstract domain that produced each result can be obtained with the show_domain_name flag, callers and paths with the show_parents flag, etc.

Outputting raw analysis results

The output files described above go through some post-processing aimed at making them more readable and also reloadable into CiaoPP. This includes for example translating from the internal representation of the abstract domain elements to user-level properties and eliminating unnecessary module qualifications. However, it is also possible to inspect the analysis results without any post-processing. To generate this raw output simply set the preprocess flag output_lang to raw before generating the analysis output:

?- set_pp_flag(output_lang, raw).

yes
% make analysis
?- module(foo).
{Loading current module from foo.pl
{loaded in 390.268 msec.}
}

yes
?- analyze(eterms).
{Analyzing foo.pl
{preprocessed for the plai fixpoint in 1.736 msec.}
{analyzed by plai using eterms with local-control off in 5.106 msec.}
}

?- output.
{written file .../foo_eterms_co.pl}

yes
?- % open file or C-c C-v in emacs, etc.

In contrast to the usual output, in the raw output clauses are represented using CiaoPP's internal clause representation and the abstract values are represented using the internal representation of the abstract domain elements. The latter is specially useful when developing a new abstract domain, since if the predicates asub_to_info/5, asub_to_native/6, etc. are not defined, no useful information appears in the normal output.

In addition, in this raw output true assertions are always generated for all call/success pattern inferred by the analysis, each identified by the node id. In the body, each reachable program point is adorned with one or more true annotations—one per inferred call pattern—each attaching the id of its corresponding call pattern.

Inspecting analysis graphs

Analysis graphs can be dumped to some file <file> and inspected in several ways as follows:

First, dump the analysis graph in <file>:

ciaopp ?- use_module(ciaopp(p_dump)).

yes
ciaopp ?- dump(<file>).

Then, use the ciaopp-dump command for inspecting the analysis graph dumped in <file>:

$ ciaopp-dump show <file>            # Print info of the dump <file>.
$ ciaopp-dump fmt <file>             # Outputs the analysis result in dot format.
$ dot -Tpdf <file>.dot -o <file>.pdf # Generates a graph in pdf of the analysis dot file.

Accessing PLAI databases

It is also possible to access the solver's databases directly from within the top-level by querying the plai_db:complete/7 or plai_db:memo_table/6 predicates. For example:

ciaopp ?- use_module(ciaopp(plai/plai_db)).

yes
ciaopp ?- complete(SgKey,AbsInt,Sg,Proj,Prime,Id,Parents).