Logo AND Algorithmique Numérique Distribuée

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