Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ignore empty replay path + hide a global (to avoid init fiasco)
[simgrid.git] / src / mc / remote / AppSide.cpp
index f6b53c968628e3045a39a0f8a733ed2e9705c8c6..3c5b688f19139c9a4b48c6e464e0e1ee89c65c98 100644 (file)
@@ -40,16 +40,18 @@ namespace simgrid::mc {
 
 std::unique_ptr<AppSide> AppSide::instance_;
 
-AppSide* AppSide::initialize()
+AppSide* AppSide::get()
 {
-  if (not std::getenv(MC_ENV_SOCKET_FD)) // We are not in MC mode: don't initialize the MC world
+  // Only initialize the MC world once
+  if (instance_ != nullptr)
+    return instance_.get();
+
+  if (std::getenv(MC_ENV_SOCKET_FD) == nullptr) // We are not in MC mode: don't initialize the MC world
     return nullptr;
 
-  // Do not break if we are called multiple times:
-  if (instance_)
-    return instance_.get();
+  XBT_DEBUG("Initialize the MC world. MC_NEED_PTRACE=%s", std::getenv("MC_NEED_PTRACE"));
 
-  simgrid::mc::model_checking_mode = ModelCheckingMode::APP_SIDE;
+  simgrid::mc::set_model_checking_mode(ModelCheckingMode::APP_SIDE);
 
   setvbuf(stdout, nullptr, _IOLBF, 0);
 
@@ -176,6 +178,8 @@ void AppSide::handle_fork(const s_mc_message_int_t* msg)
     answer.type               = MessageType::FORK_REPLY;
     answer.value              = getpid();
     xbt_assert(channel_.send(answer) == 0, "Could not send response to WAIT_CHILD_REPLY: %s", strerror(errno));
+  } else {
+    XBT_DEBUG("App %d forks subprocess %d.", getpid(), pid);
   }
 }
 void AppSide::handle_wait_child(const s_mc_message_int_t* msg)