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
16 #include <simgrid_config.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"
31 extern XBT_PRIVATE xbt_automaton_t property_automaton;
33 struct XBT_PRIVATE Pair {
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;
41 int exploration_started = 0;
46 Pair(Pair const&) = delete;
47 Pair& operator=(Pair const&) = delete;
50 struct XBT_PRIVATE VisitedPair {
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;
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);
67 class LivenessChecker : public Checker {
69 LivenessChecker(Session& session);
72 RecordTrace getRecordTrace() override;
73 std::vector<std::string> getTextualTrace() override;
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);
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;