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
17 #include <simgrid_config.h>
19 #include <xbt/dynar.h>
20 #include <xbt/automaton.h>
21 #include <xbt/memory.hpp>
22 #include "src/mc/mc_state.h"
23 #include "src/mc/Checker.hpp"
32 extern XBT_PRIVATE xbt_automaton_t property_automaton;
34 struct XBT_PRIVATE Pair {
37 std::shared_ptr<simgrid::mc::State> graph_state = nullptr; /* System state included */
38 xbt_automaton_state_t automaton_state = nullptr;
39 std::vector<int> atomic_propositions;
42 int exploration_started = 0;
47 Pair(Pair const&) = delete;
48 Pair& operator=(Pair const&) = delete;
51 struct XBT_PRIVATE VisitedPair {
53 int other_num = 0; /* Dot output for */
54 int acceptance_pair = 0;
55 std::shared_ptr<simgrid::mc::State> graph_state = nullptr; /* System state included */
56 xbt_automaton_state_t automaton_state = nullptr;
57 std::vector<int> atomic_propositions;
58 std::size_t heap_bytes_used = 0;
62 int pair_num, xbt_automaton_state_t automaton_state,
63 std::vector<int> const& atomic_propositions,
64 std::shared_ptr<simgrid::mc::State> graph_state);
68 class XBT_PRIVATE 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 std::vector<int> getPropositionValues();
80 std::shared_ptr<VisitedPair> insertAcceptancePair(simgrid::mc::Pair* pair);
81 int insertVisitedPair(std::shared_ptr<VisitedPair> visited_pair, simgrid::mc::Pair* pair);
82 void showAcceptanceCycle(std::size_t depth);
84 void removeAcceptancePair(int pair_num);
86 std::list<std::shared_ptr<VisitedPair>> acceptancePairs_;
87 std::list<Pair*> livenessStack_;
88 std::list<std::shared_ptr<VisitedPair>> visitedPairs_;