1 /* Copyright (c) 2007-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #ifndef SIMGRID_MC_LIVENESS_CHECKER_HPP
8 #define SIMGRID_MC_LIVENESS_CHECKER_HPP
15 #include <simgrid_config.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"
30 extern XBT_PRIVATE xbt_automaton_t property_automaton;
32 struct XBT_PRIVATE Pair {
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;
40 int exploration_started = 0;
45 Pair(Pair const&) = delete;
46 Pair& operator=(Pair const&) = delete;
49 struct XBT_PRIVATE VisitedPair {
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;
58 int acceptance_removed = 0;
59 int visited_removed = 0;
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);
68 class LivenessChecker : public Checker {
70 LivenessChecker(Session& session);
73 RecordTrace getRecordTrace() override;
74 std::vector<std::string> getTextualTrace() override;
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);
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;