Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
6b2fcbbef654adf2dd9a43295c8d7abbe4d58f6f
[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 <cstddef>
11
12 #include <string>
13 #include <list>
14
15 #include <simgrid_config.h>
16 #include <xbt/base.h>
17 #include <xbt/dynar.h>
18 #include <xbt/automaton.h>
19 #include <xbt/memory.hpp>
20 #include "src/mc/mc_state.h"
21 #include "src/mc/Checker.hpp"
22
23 SG_BEGIN_DECL()
24
25 SG_END_DECL()
26
27 namespace simgrid {
28 namespace mc {
29
30 extern XBT_PRIVATE xbt_automaton_t property_automaton;
31
32 struct XBT_PRIVATE Pair {
33   int num = 0;
34   int search_cycle = 0;
35   std::shared_ptr<simgrid::mc::State> graph_state = nullptr; /* System state included */
36   xbt_automaton_state_t automaton_state = nullptr;
37   simgrid::xbt::unique_ptr<s_xbt_dynar_t> atomic_propositions;
38   int requests = 0;
39   int depth = 0;
40   int exploration_started = 0;
41
42   Pair();
43   ~Pair();
44
45   Pair(Pair const&) = delete;
46   Pair& operator=(Pair const&) = delete;
47 };
48
49 struct XBT_PRIVATE VisitedPair {
50   int num = 0;
51   int other_num = 0; /* Dot output for */
52   int acceptance_pair = 0;
53   std::shared_ptr<simgrid::mc::State> graph_state = nullptr; /* System state included */
54   xbt_automaton_state_t automaton_state = nullptr;
55   simgrid::xbt::unique_ptr<s_xbt_dynar_t> atomic_propositions;
56   std::size_t heap_bytes_used = 0;
57   int nb_processes = 0;
58   int acceptance_removed = 0;
59   int visited_removed = 0;
60
61   VisitedPair(
62     int pair_num, xbt_automaton_state_t automaton_state,
63     xbt_dynar_t atomic_propositions,
64     std::shared_ptr<simgrid::mc::State> graph_state);
65   ~VisitedPair();
66 };
67
68 class LivenessChecker : public Checker {
69 public:
70   LivenessChecker(Session& session);
71   ~LivenessChecker();
72   int run() override;
73   RecordTrace getRecordTrace() override;
74   std::vector<std::string> getTextualTrace() override;
75 private:
76   int main();
77   void prepare();
78   int compare(simgrid::mc::VisitedPair* state1, simgrid::mc::VisitedPair* state2);
79   simgrid::xbt::unique_ptr<s_xbt_dynar_t> getPropositionValues();
80   simgrid::mc::VisitedPair* insertAcceptancePair(simgrid::mc::Pair* pair);
81   int insertVisitedPair(simgrid::mc::VisitedPair* visited_pair, simgrid::mc::Pair* pair);
82   void showAcceptanceCycle(std::size_t depth);
83   void replay();
84   void removeAcceptancePair(int pair_num);
85 public: // (non-static wannabe) fields
86   static std::list<VisitedPair*> acceptance_pairs;
87   static std::list<Pair*> liveness_stack;
88 };
89
90 }
91 }
92
93 #endif