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 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;
41 int visited_pair_removed = 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 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;
59 int acceptance_removed = 0;
60 int visited_removed = 0;
62 VisitedPair(int pair_num, xbt_automaton_state_t automaton_state, xbt_dynar_t atomic_propositions, simgrid::mc::State* graph_state);
66 class LivenessChecker : public Checker {
68 LivenessChecker(Session& session);
71 RecordTrace getRecordTrace() override;
72 std::vector<std::string> getTextualTrace() override;
76 int compare(simgrid::mc::VisitedPair* state1, simgrid::mc::VisitedPair* state2);
77 simgrid::xbt::unique_ptr<s_xbt_dynar_t> getPropositionValues();
78 simgrid::mc::VisitedPair* insertAcceptancePair(simgrid::mc::Pair* pair);
79 int insertVisitedPair(simgrid::mc::VisitedPair* visited_pair, simgrid::mc::Pair* pair);
80 void showAcceptanceCycle(std::size_t depth);
82 void removeAcceptancePair(int pair_num);
83 public: // (non-static wannabe) fields
84 static xbt_dynar_t acceptance_pairs;
85 static std::list<Pair*> liveness_stack;