Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move main liveness code in a LivenessChecker class
[simgrid.git] / src / mc / LivenessChecker.hpp
1 /* Copyright (c) 2007-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SIMGRID_MC_LIVENESS_CHECKER_HPP
8 #define SIMGRID_MC_LIVENESS_CHECKER_HPP
9
10 #include <stdint.h>
11
12 #include <simgrid_config.h>
13 #include <xbt/base.h>
14 #include <xbt/fifo.h>
15 #include <xbt/dynar.h>
16 #include <xbt/automaton.h>
17 #include <xbt/memory.hpp>
18 #include "src/mc/mc_state.h"
19 #include "src/mc/Checker.hpp"
20
21 SG_BEGIN_DECL()
22
23 SG_END_DECL()
24
25 namespace simgrid {
26 namespace mc {
27
28 extern XBT_PRIVATE xbt_automaton_t property_automaton;
29
30 struct XBT_PRIVATE Pair {
31   int num = 0;
32   int search_cycle = 0;
33   mc_state_t graph_state = nullptr; /* System state included */
34   xbt_automaton_state_t automaton_state = nullptr;
35   simgrid::xbt::unique_ptr<s_xbt_dynar_t> atomic_propositions;
36   int requests = 0;
37   int depth = 0;
38   int exploration_started = 0;
39   int visited_pair_removed = 0;
40
41   Pair();
42   ~Pair();
43
44   Pair(Pair const&) = delete;
45   Pair& operator=(Pair const&) = delete;
46 };
47
48 struct XBT_PRIVATE VisitedPair {
49   int num = 0;
50   int other_num = 0; /* Dot output for */
51   int acceptance_pair = 0;
52   mc_state_t graph_state = nullptr; /* System state included */
53   xbt_automaton_state_t automaton_state = nullptr;
54   simgrid::xbt::unique_ptr<s_xbt_dynar_t> atomic_propositions;
55   size_t heap_bytes_used = 0;
56   int nb_processes = 0;
57   int acceptance_removed = 0;
58   int visited_removed = 0;
59
60   VisitedPair(int pair_num, xbt_automaton_state_t automaton_state, xbt_dynar_t atomic_propositions, mc_state_t graph_state);
61   ~VisitedPair();
62 };
63
64 class LivenessChecker : public Checker {
65 public:
66   LivenessChecker(Session& session);
67   ~LivenessChecker();
68   int run() override;
69 private:
70   int main();
71   void prepare();
72   int compare(simgrid::mc::VisitedPair* state1, simgrid::mc::VisitedPair* state2);
73   void dumpStack(xbt_fifo_t stack);
74   void showStack(xbt_fifo_t stack);
75   simgrid::xbt::unique_ptr<s_xbt_dynar_t> getPropositionValues();
76   simgrid::mc::VisitedPair* insertAcceptancePair(simgrid::mc::Pair* pair);
77   int insertVisitedPair(simgrid::mc::VisitedPair* visited_pair, simgrid::mc::Pair* pair);
78   void showAcceptanceCycle(std::size_t depth);
79   void replay(xbt_fifo_t stack);
80   void removeAcceptancePair(int pair_num);
81 };
82
83 }
84 }
85
86 #endif