]> AND Public Git Repository - simgrid.git/blobdiff - src/mc/remote/AppSide.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename mc::RemoteSimulation into mc::RemoteProcess
[simgrid.git] / src / mc / remote / AppSide.cpp
index c09923341f4e32cacf8e53dfe9a4223dde7c6ee1..7448d7ce99877acf0f908669bdc9ae68d7436d58 100644 (file)
@@ -6,7 +6,8 @@
 #include "src/mc/remote/AppSide.hpp"
 #include "src/internal_config.h"
 #include "src/kernel/actor/ActorImpl.hpp"
-#include "src/mc/checker/SimcallInspector.hpp"
+#include "src/mc/checker/SimcallObserver.hpp"
+#include "src/mc/remote/RemoteProcess.hpp"
 #include <simgrid/modelchecker.h>
 
 #include <cerrno>
@@ -17,9 +18,6 @@
 #include <sys/socket.h>
 #include <sys/types.h>
 
-// We won't need those once the separation MCer/MCed is complete:
-#include "src/mc/mc_smx.hpp"
-
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client, mc, "MC client logic");
 
 namespace simgrid {
@@ -91,9 +89,9 @@ void AppSide::handle_continue(const s_mc_message_t*) const
 }
 void AppSide::handle_simcall(const s_mc_message_simcall_handle_t* message) const
 {
-  kernel::actor::ActorImpl* process = kernel::actor::ActorImpl::by_PID(message->pid);
-  xbt_assert(process != nullptr, "Invalid pid %lu", message->pid);
-  process->simcall_handle(message->value);
+  kernel::actor::ActorImpl* process = kernel::actor::ActorImpl::by_PID(message->pid_);
+  xbt_assert(process != nullptr, "Invalid pid %lu", message->pid_);
+  process->simcall_handle(message->times_considered_);
   if (channel_.send(MessageType::WAITING))
     xbt_die("Could not send MESSAGE_WAITING to model-checker");
 }
@@ -136,27 +134,13 @@ void AppSide::handle_messages() const
         handle_simcall((s_mc_message_simcall_handle_t*)message_buffer.data());
         break;
 
-      case MessageType::SIMCALL_IS_PENDING: {
-        assert_msg_size("SIMCALL_IS_PENDING", s_mc_message_simcall_is_pending_t);
-        auto msg_simcall                = (s_mc_message_simcall_is_pending_t*)message_buffer.data();
-        kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_PID(msg_simcall->aid);
-        xbt_assert(actor != nullptr, "Invalid pid %d", msg_simcall->aid);
-        xbt_assert(actor->simcall_.inspector_, "The transition of %s has no inspector", actor->get_cname());
-        bool value = actor->simcall_.inspector_->is_pending(msg_simcall->time_considered);
-
-        // Send result:
-        s_mc_message_simcall_is_pending_answer_t answer{MessageType::SIMCALL_IS_PENDING_ANSWER, value};
-        xbt_assert(channel_.send(answer) == 0, "Could not send response");
-        break;
-      }
-
       case MessageType::SIMCALL_IS_VISIBLE: {
         assert_msg_size("SIMCALL_IS_VISIBLE", s_mc_message_simcall_is_visible_t);
         auto msg_simcall                = (s_mc_message_simcall_is_visible_t*)message_buffer.data();
-        kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_PID(msg_simcall->aid);
+        const kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_PID(msg_simcall->aid);
         xbt_assert(actor != nullptr, "Invalid pid %d", msg_simcall->aid);
-        xbt_assert(actor->simcall_.inspector_, "The transition of %s has no inspector", actor->get_cname());
-        bool value = actor->simcall_.inspector_->is_visible();
+        xbt_assert(actor->simcall_.observer_, "The transition of %s has no observer", actor->get_cname());
+        bool value = actor->simcall_.observer_->is_visible();
 
         // Send result:
         s_mc_message_simcall_is_visible_answer_t answer{MessageType::SIMCALL_IS_VISIBLE_ANSWER, value};
@@ -167,18 +151,14 @@ void AppSide::handle_messages() const
       case MessageType::SIMCALL_TO_STRING: {
         assert_msg_size("SIMCALL_TO_STRING", s_mc_message_simcall_to_string_t);
         auto msg_simcall                = (s_mc_message_simcall_to_string_t*)message_buffer.data();
-        kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_PID(msg_simcall->aid);
+        const kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_PID(msg_simcall->aid);
         xbt_assert(actor != nullptr, "Invalid pid %d", msg_simcall->aid);
-        //        xbt_assert(actor->simcall_.inspector_, "The transition of %s has no inspector", actor->get_cname());
-        std::string value;
-        if (actor->simcall_.inspector_ == nullptr)
-          value = "no inspector, no string. Please report that bug.";
-        else
-          value = actor->simcall_.inspector_->to_string(msg_simcall->time_considered);
+        xbt_assert(actor->simcall_.observer_, "The transition of %s has no observer", actor->get_cname());
+        std::string value = actor->simcall_.observer_->to_string(msg_simcall->time_considered);
 
         // Send result:
         s_mc_message_simcall_to_string_answer_t answer{MessageType::SIMCALL_TO_STRING_ANSWER, {0}};
-        strcat(answer.value, value.c_str());
+        value.copy(answer.value, (sizeof answer.value) - 1); // last byte was set to '\0' by initialization above
         xbt_assert(channel_.send(answer) == 0, "Could not send response");
         break;
       }
@@ -186,14 +166,14 @@ void AppSide::handle_messages() const
       case MessageType::SIMCALL_DOT_LABEL: {
         assert_msg_size("SIMCALL_DOT_LABEL", s_mc_message_simcall_to_string_t);
         auto msg_simcall                = (s_mc_message_simcall_to_string_t*)message_buffer.data();
-        kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_PID(msg_simcall->aid);
+        const kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_PID(msg_simcall->aid);
         xbt_assert(actor != nullptr, "Invalid pid %d", msg_simcall->aid);
-        xbt_assert(actor->simcall_.inspector_, "The transition of %s has no inspector", actor->get_cname());
-        std::string value = actor->simcall_.inspector_->dot_label();
+        xbt_assert(actor->simcall_.observer_, "The transition of %s has no observer", actor->get_cname());
+        std::string value = actor->simcall_.observer_->dot_label();
 
         // Send result:
         s_mc_message_simcall_to_string_answer_t answer{MessageType::SIMCALL_TO_STRING_ANSWER, {0}};
-        strcat(answer.value, value.c_str());
+        value.copy(answer.value, (sizeof answer.value) - 1); // last byte was set to '\0' by initialization above
         xbt_assert(channel_.send(answer) == 0, "Could not send response");
         break;
       }