| 1 | % (c) 2014-2022 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, | |
| 2 | % Heinrich Heine Universitaet Duesseldorf | |
| 3 | % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) | |
| 4 | ||
| 5 | :- module(dot_graphs_static_analysis, [tcltk_create_dependence_graph/1, tcltk_create_enable_graph/1,tcltk_create_enable_graph_por/3,tcltk_create_disable_graph_por/2]). | |
| 6 | ||
| 7 | /* Modules and Infos for the code coverage analysis */ | |
| 8 | :- use_module(probsrc(module_information)). | |
| 9 | :- module_info(group,model_checker). | |
| 10 | :- module_info(description,'This module provides predicates for printing out graphs in dot-format calculated by computing some of the static analyses used for partial order reduction'). | |
| 11 | ||
| 12 | % Standard SICSTUS prolog libraries | |
| 13 | :- use_module(library(lists)). | |
| 14 | ||
| 15 | % Imports from the POR modules | |
| 16 | :- use_module(probporsrc(static_analysis),[dependent_actions/5,enable_analysis/6,disable_analysis/5]). | |
| 17 | ||
| 18 | % The dot-graph generator | |
| 19 | :- use_module(dotsrc(dot_graph_generator), [gen_dot_graph/6, use_new_dot_attr_pred/7, dot_no_same_rank/1, dot_no_subgraph/3]). | |
| 20 | ||
| 21 | % Preferences | |
| 22 | :- use_module(probsrc(preferences), [get_preference/2]). | |
| 23 | :- use_module(probsrc(bmachine), [b_top_level_operation/1]). | |
| 24 | ||
| 25 | % TODO: move all enabling graph predicates in enabling_analysis.pl used for generating dot-graphs to a new module | |
| 26 | :- use_module(cbcsrc(enabling_analysis), [cbc_enable_analysis/4, | |
| 27 | enabling_dot_graph_attrs/2, enabling_dot_node/4, enabling_dot_edge_attrs/4]). | |
| 28 | ||
| 29 | gen_enabling_dot_graph(File,Kind,InitOpt,EdgePred) :- | |
| 30 | enabling_dot_graph_attrs(Kind,GraphAttrs), | |
| 31 | gen_dot_graph(File,GraphAttrs, | |
| 32 | use_new_dot_attr_pred(enabling_analysis:enabling_dot_node(InitOpt)), | |
| 33 | use_new_dot_attr_pred(EdgePred), | |
| 34 | dot_no_same_rank,dot_no_subgraph). | |
| 35 | ||
| 36 | % Predicates for creating an enable graphs | |
| 37 | tcltk_create_enable_graph(File) :- | |
| 38 | gen_enabling_dot_graph(File,'enabling relations',with_init,dot_graphs_static_analysis:cbc_enable_edge). | |
| 39 | ||
| 40 | tcltk_create_enable_graph_por(File,Inv,UseEnableGraph) :- | |
| 41 | gen_enabling_dot_graph(File,'enabling relations (POR)',no_init, | |
| 42 | dot_graphs_static_analysis:cbc_enable_edge_por(Inv,UseEnableGraph)). | |
| 43 | ||
| 44 | tcltk_create_disable_graph_por(File,Inv) :- | |
| 45 | gen_enabling_dot_graph(File,'disabling relations (POR)',no_init,dot_graphs_static_analysis:cbc_disable_edge_por(Inv)). | |
| 46 | ||
| 47 | :- public cbc_disable_edge_por/4, cbc_enable_edge_por/5, cbc_enable_edge/3, cbc_dependence_edge/3. | |
| 48 | cbc_disable_edge_por(Inv,NodeID,SuccID,Attrs) :- | |
| 49 | get_preference(timeout_cbc_analysis,Timeout), | |
| 50 | b_top_level_operation(NodeID), b_top_level_operation(SuccID), | |
| 51 | disable_analysis(NodeID,SuccID,Inv,Timeout,Res), | |
| 52 | (Res=possible_disable -> Res2=Res ; Res=timeout, Res2=timeout_possible_disable), | |
| 53 | enabling_dot_edge_attrs(Res2,NodeID,SuccID,Attrs). | |
| 54 | ||
| 55 | cbc_enable_edge_por(Inv,UseEnableGraph,NodeID,SuccID,Attrs) :- | |
| 56 | get_preference(timeout_cbc_analysis,Timeout), | |
| 57 | b_top_level_operation(NodeID), b_top_level_operation(SuccID), | |
| 58 | enable_analysis(NodeID,SuccID,Inv,UseEnableGraph,Timeout,Res), | |
| 59 | (Res=possible_enable; Res=possible; Res=guaranteed; Res=timeout; Res=predicate(_Expr)), | |
| 60 | enabling_dot_edge_attrs(Res,NodeID,SuccID,Attrs). | |
| 61 | ||
| 62 | cbc_enable_edge(NodeID,SuccID,Attrs) :- | |
| 63 | get_preference(timeout_cbc_analysis,Timeout), | |
| 64 | cbc_enable_analysis(NodeID,SuccID,Res,Timeout), % was 500 | |
| 65 | enabling_dot_edge_attrs(Res,NodeID,SuccID,Attrs). | |
| 66 | ||
| 67 | % Predicates for creating a dependency graph | |
| 68 | % the dependence relation is symmetric: we draw one undirected edge per pair of operations | |
| 69 | tcltk_create_dependence_graph(File) :- | |
| 70 | gen_enabling_dot_graph(File,'dependence relation',no_init,dot_graphs_static_analysis:cbc_dependence_edge). | |
| 71 | ||
| 72 | cbc_dependence_edge(NodeID,SuccID,[dir/none|Attrs]) :- | |
| 73 | Inv=0, % TODO: remove this later | |
| 74 | get_preference(timeout_cbc_analysis,Timeout), | |
| 75 | b_top_level_operation(NodeID), b_top_level_operation(SuccID), | |
| 76 | NodeID @=< SuccID, | |
| 77 | dependent_actions(NodeID,SuccID,Inv,Timeout,Res), | |
| 78 | % Res can be action, guard, predicate(_), race or general | |
| 79 | \+ (Res=general, NodeID=SuccID), % every operation is trivially dependent on itself | |
| 80 | translate_por_res(Res,EnableRes), | |
| 81 | enabling_dot_edge_attrs(EnableRes,NodeID,SuccID,Attrs). | |
| 82 | ||
| 83 | translate_por_res(action,action_dependent). | |
| 84 | translate_por_res(guard,guard_dependent). | |
| 85 | translate_por_res(predicate(_),guard_dependent). | |
| 86 | translate_por_res(race,race_dependent). | |
| 87 | translate_por_res(general,dependent). % self_dependent or dependent |