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 {
36 bool search_cycle = false;
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 bool exploration_started = false;
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 std::shared_ptr<simgrid::mc::State> graph_state = nullptr; /* System state included */
55 xbt_automaton_state_t automaton_state = nullptr;
56 std::vector<int> atomic_propositions;
57 std::size_t heap_bytes_used = 0;
61 int pair_num, xbt_automaton_state_t automaton_state,
62 std::vector<int> const& atomic_propositions,
63 std::shared_ptr<simgrid::mc::State> graph_state);
67 class XBT_PRIVATE 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 std::vector<int> 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 void purgeVisitedPairs();
86 std::list<std::shared_ptr<VisitedPair>> acceptancePairs_;
87 std::list<std::shared_ptr<Pair>> livenessStack_;
88 std::list<std::shared_ptr<VisitedPair>> visitedPairs_;