From: Martin Quinson Date: Sat, 14 Jan 2017 00:52:32 +0000 (+0100) Subject: further cleanups to the SafetyChecker X-Git-Tag: v3_15~545 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/90319766c67d84542aace23dac42b74a63b1c707?hp=01c96c4bc37fc4aac70e6b5fe3ff6992a9736c04 further cleanups to the SafetyChecker --- diff --git a/src/mc/checker/SafetyChecker.cpp b/src/mc/checker/SafetyChecker.cpp index 1d57219d75..2d766e2f70 100644 --- a/src/mc/checker/SafetyChecker.cpp +++ b/src/mc/checker/SafetyChecker.cpp @@ -34,17 +34,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_safety, mc, namespace simgrid { namespace mc { -static void MC_show_non_termination(void) -{ - XBT_INFO("******************************************"); - XBT_INFO("*** NON-PROGRESSIVE CYCLE DETECTED ***"); - XBT_INFO("******************************************"); - XBT_INFO("Counter-example execution trace:"); - for (auto& s : mc_model_checker->getChecker()->getTextualTrace()) - XBT_INFO("%s", s.c_str()); - simgrid::mc::session->logState(); -} - static int snapshot_compare(simgrid::mc::State* state1, simgrid::mc::State* state2) { simgrid::mc::Snapshot* s1 = state1->system_state.get(); @@ -54,14 +43,21 @@ static int snapshot_compare(simgrid::mc::State* state1, simgrid::mc::State* stat return snapshot_compare(num1, s1, num2, s2); } -bool SafetyChecker::checkNonTermination(simgrid::mc::State* current_state) +void SafetyChecker::checkNonTermination(simgrid::mc::State* current_state) { for (auto state = stack_.rbegin(); state != stack_.rend(); ++state) if (snapshot_compare(state->get(), current_state) == 0) { XBT_INFO("Non-progressive cycle: state %d -> state %d", (*state)->num, current_state->num); - return true; + XBT_INFO("******************************************"); + XBT_INFO("*** NON-PROGRESSIVE CYCLE DETECTED ***"); + XBT_INFO("******************************************"); + XBT_INFO("Counter-example execution trace:"); + for (auto& s : mc_model_checker->getChecker()->getTextualTrace()) + XBT_INFO("%s", s.c_str()); + simgrid::mc::session->logState(); + + throw simgrid::mc::TerminationError(); } - return false; } RecordTrace SafetyChecker::getRecordTrace() // override @@ -127,8 +123,8 @@ void SafetyChecker::run() continue; } + // Search an enabled transition in the current state; backtrack if the interleave set is empty smx_simcall_t req = MC_state_get_request(state); - // Backtrack if the interleave set is empty if (req == nullptr) { XBT_DEBUG("There are no more processes to interleave. (depth %zi)", stack_.size() + 1); @@ -155,17 +151,15 @@ void SafetyChecker::run() std::unique_ptr next_state = std::unique_ptr(new simgrid::mc::State(++expandedStatesCount_)); - if (_sg_mc_termination && this->checkNonTermination(next_state.get())) { - MC_show_non_termination(); - throw simgrid::mc::TerminationError(); - } + if (_sg_mc_termination) + this->checkNonTermination(next_state.get()); /* Check whether we already explored next_state in the past (but only if interested in state-equality reduction) */ if (_sg_mc_visited == true) visitedState_ = visitedStates_.addVisitedState(expandedStatesCount_, next_state.get(), true); /* If this is a new state (or if we don't care about state-equality reduction) */ - if (_sg_mc_visited == 0 || visitedState_ == nullptr) { + if (visitedState_ == nullptr) { /* Get an enabled process and insert it in the interleave set of the next state */ for (auto& actor : mc_model_checker->process().actors()) diff --git a/src/mc/checker/SafetyChecker.hpp b/src/mc/checker/SafetyChecker.hpp index 235c8a9073..f5b3de4fd5 100644 --- a/src/mc/checker/SafetyChecker.hpp +++ b/src/mc/checker/SafetyChecker.hpp @@ -29,7 +29,7 @@ public: std::vector getTextualTrace() override; void logState() override; private: - bool checkNonTermination(simgrid::mc::State* current_state); + void checkNonTermination(simgrid::mc::State* current_state); void backtrack(); void restoreState(); private: