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
12 #include <simgrid_config.h>
15 #include <xbt/dynar.h>
16 #include <xbt/automaton.h>
17 #include <xbt/memory.hpp>
18 #include "src/mc/mc_state.h"
19 #include "src/mc/Checker.hpp"
28 extern XBT_PRIVATE xbt_automaton_t property_automaton;
30 struct XBT_PRIVATE Pair {
33 simgrid::mc::State* graph_state = nullptr; /* System state included */
34 xbt_automaton_state_t automaton_state = nullptr;
35 simgrid::xbt::unique_ptr<s_xbt_dynar_t> atomic_propositions;
38 int exploration_started = 0;
39 int visited_pair_removed = 0;
44 Pair(Pair const&) = delete;
45 Pair& operator=(Pair const&) = delete;
48 struct XBT_PRIVATE VisitedPair {
50 int other_num = 0; /* Dot output for */
51 int acceptance_pair = 0;
52 simgrid::mc::State* graph_state = nullptr; /* System state included */
53 xbt_automaton_state_t automaton_state = nullptr;
54 simgrid::xbt::unique_ptr<s_xbt_dynar_t> atomic_propositions;
55 size_t heap_bytes_used = 0;
57 int acceptance_removed = 0;
58 int visited_removed = 0;
60 VisitedPair(int pair_num, xbt_automaton_state_t automaton_state, xbt_dynar_t atomic_propositions, simgrid::mc::State* graph_state);
64 class LivenessChecker : public Checker {
66 LivenessChecker(Session& session);
69 RecordTrace getRecordTrace() override;
70 std::vector<std::string> getTextualTrace() override;
74 int compare(simgrid::mc::VisitedPair* state1, simgrid::mc::VisitedPair* state2);
75 simgrid::xbt::unique_ptr<s_xbt_dynar_t> getPropositionValues();
76 simgrid::mc::VisitedPair* insertAcceptancePair(simgrid::mc::Pair* pair);
77 int insertVisitedPair(simgrid::mc::VisitedPair* visited_pair, simgrid::mc::Pair* pair);
78 void showAcceptanceCycle(std::size_t depth);
79 void replay(xbt_fifo_t stack);
80 void removeAcceptancePair(int pair_num);