Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #371 from eazimi/master
[simgrid.git] / src / mc / checker / LivenessChecker.cpp
index 12b4356..0a5e5d9 100644 (file)
@@ -4,13 +4,11 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/mc/checker/LivenessChecker.hpp"
-#include "src/mc/Session.hpp"
 #include "src/mc/mc_config.hpp"
 #include "src/mc/mc_exit.hpp"
 #include "src/mc/mc_private.hpp"
 #include "src/mc/mc_request.hpp"
 #include "src/mc/mc_smx.hpp"
-#include "src/mc/mc_api.hpp"
 
 #include <boost/range/algorithm.hpp>
 #include <cstring>
@@ -29,15 +27,11 @@ VisitedPair::VisitedPair(int pair_num, xbt_automaton_state_t automaton_state,
                          std::shared_ptr<State> graph_state)
     : num(pair_num), automaton_state(automaton_state)
 {
-  RemoteSimulation* process = &(mc_model_checker->get_remote_simulation());
-
   this->graph_state = std::move(graph_state);
   if (this->graph_state->system_state_ == nullptr)
     this->graph_state->system_state_ = std::make_shared<Snapshot>(pair_num);
-  this->heap_bytes_used = mmalloc_get_bytes_used_remote(process->get_heap()->heaplimit, process->get_malloc_info());
-
-  this->actors_count = mc_model_checker->get_remote_simulation().actors().size();
-
+  this->heap_bytes_used = mcapi::get().get_remote_heap_bytes();
+  this->actors_count = mcapi::get().get_actors_size();
   this->other_num = -1;
   this->atomic_propositions = std::move(atomic_propositions);
 }
@@ -118,13 +112,13 @@ void LivenessChecker::replay()
   if(_sg_mc_checkpoint > 0) {
     const Pair* pair = exploration_stack_.back().get();
     if (pair->graph_state->system_state_) {
-      pair->graph_state->system_state_->restore(&mc_model_checker->get_remote_simulation());
+      mcapi::get().restore_state(pair->graph_state->system_state_);
       return;
     }
   }
 
   /* Restore the initial state */
-  mc::session->restore_initial_state();
+  mcapi::get().restore_initial_state();
 
   /* Traverse the stack from the initial state and re-execute the transitions */
   int depth = 1;
@@ -142,19 +136,19 @@ void LivenessChecker::replay()
 
       /* because we got a copy of the executed request, we have to fetch the
          real one, pointed by the request field of the issuer process */
-      const smx_actor_t issuer = MC_smx_simcall_get_issuer(saved_req);
+      const smx_actor_t issuer = mcapi::get().simcall_get_issuer(saved_req);
       req                      = &issuer->simcall_;
 
       /* Debug information */
       XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth,
                 mcapi::get().request_to_string(req, req_num, simgrid::mc::RequestType::simix).c_str(), state.get());
 
-      this->get_session().execute(state->transition_);
+      mcapi::get().execute(state->transition_);
     }
 
     /* Update statistics */
     visited_pairs_count_++;
-    mc_model_checker->executed_transitions++;
+    mcapi::get().mc_inc_executed_trans();
 
     depth++;
   }
@@ -179,7 +173,7 @@ int LivenessChecker::insert_visited_pair(std::shared_ptr<VisitedPair> visited_pa
     const VisitedPair* pair_test = i->get();
     if (mcapi::get().automaton_state_compare(pair_test->automaton_state, visited_pair->automaton_state) != 0 ||
         *(pair_test->atomic_propositions) != *(visited_pair->atomic_propositions) ||
-        not snapshot_equal(pair_test->graph_state->system_state_.get(), visited_pair->graph_state->system_state_.get()))
+        not mcapi::get().snapshot_equal(pair_test->graph_state->system_state_.get(), visited_pair->graph_state->system_state_.get()))
       continue;
     if (pair_test->other_num == -1)
       visited_pair->other_num = pair_test->num;
@@ -209,7 +203,7 @@ void LivenessChecker::purge_visited_pairs()
   }
 }
 
-LivenessChecker::LivenessChecker(Session& s) : Checker(s)
+LivenessChecker::LivenessChecker() : Checker()
 {
 }
 
@@ -375,7 +369,7 @@ void LivenessChecker::run()
         this->previous_request_.clear();
       }
       this->previous_pair_    = current_pair->num;
-      this->previous_request_ = request_get_dot_output(req, req_num);
+      this->previous_request_ = mcapi::get().request_get_dot_output(req, req_num);
       if (current_pair->search_cycle)
         fprintf(dot_output, "%d [shape=doublecircle];\n", current_pair->num);
       fflush(dot_output);
@@ -384,15 +378,16 @@ void LivenessChecker::run()
     XBT_DEBUG("Execute: %s", mcapi::get().request_to_string(req, req_num, RequestType::simix).c_str());
 
     /* Update stats */
-    mc_model_checker->executed_transitions++;
+    mcapi::get().mc_inc_executed_trans();
+
     if (not current_pair->exploration_started)
       visited_pairs_count_++;
 
     /* Answer the request */
-    mc_model_checker->handle_simcall(current_pair->graph_state->transition_);
+    mcapi::get().handle_simcall(current_pair->graph_state->transition_);
 
     /* Wait for requests (schedules processes) */
-    mc_model_checker->wait_for_requests();
+    mcapi::get().mc_wait_for_requests();
 
     current_pair->requests--;
     current_pair->exploration_started = true;
@@ -402,21 +397,21 @@ void LivenessChecker::run()
 
     // For each enabled transition in the property automaton, push a
     // (application_state, automaton_state) pair to the exploration stack:
-    for (int i = xbt_dynar_length(current_pair->automaton_state->out) - 1; i >= 0; i--) {
-      const xbt_automaton_transition* transition_succ =
-          xbt_dynar_get_as(current_pair->automaton_state->out, i, xbt_automaton_transition_t);
-      if (evaluate_label(transition_succ->label, *prop_values))
-        exploration_stack_.push_back(this->create_pair(current_pair.get(), transition_succ->dst, prop_values));
-     }
+    for (int i = mcapi::get().get_dynar_length(current_pair->automaton_state->out) - 1; i >= 0; i--) {
+      auto transition_succ_label = mcapi::get().get_automaton_transition_label(current_pair->automaton_state->out, i);
+      auto transition_succ_dst = mcapi::get().get_automaton_transition_dst(current_pair->automaton_state->out, i);      
+      if (evaluate_label(transition_succ_label, *prop_values))
+        exploration_stack_.push_back(this->create_pair(current_pair.get(), transition_succ_dst, prop_values));
+    }
   }
 
   XBT_INFO("No property violation found.");
-  mc::session->log_state();
+  mcapi::get().log_state();
 }
 
-Checker* createLivenessChecker(Session& s)
+Checker* createLivenessChecker()
 {
-  return new LivenessChecker(s);
+  return new LivenessChecker();
 }
 
 } // namespace mc