Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'noRngStream' into 'master'
[simgrid.git] / src / mc / remote / Client.cpp
index 4a9f0bf..06916a4 100644 (file)
@@ -6,10 +6,11 @@
 #include "src/mc/remote/Client.hpp"
 #include "src/internal_config.h"
 #include <simgrid/modelchecker.h>
-#include <xbt/system_error.hpp>
 
+#include <cerrno>
 #include <cstdlib>
 #include <cstring>
+#include <sys/ptrace.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 
@@ -56,8 +57,16 @@ Client* Client::initialize()
   instance_.reset(new simgrid::mc::Client(fd));
 
   // Wait for the model-checker:
-  if (raise(SIGSTOP) != 0)
-    throw simgrid::xbt::errno_error("Could not wait for the model-checker");
+  errno = 0;
+#if defined __linux__
+  ptrace(PTRACE_TRACEME, 0, nullptr, nullptr);
+#elif defined BSD
+  ptrace(PT_TRACE_ME, 0, nullptr, 0);
+#else
+#error "no ptrace equivalent coded for this platform"
+#endif
+  if (errno != 0 || raise(SIGSTOP) != 0)
+    xbt_die("Could not wait for the model-checker (errno = %d: %s)", errno, strerror(errno));
 
   instance_->handle_messages();
   return instance_.get();
@@ -88,7 +97,7 @@ void Client::handle_simcall(s_mc_message_simcall_handle_t* message)
   smx_actor_t process = SIMIX_process_from_PID(message->pid);
   if (not process)
     xbt_die("Invalid pid %lu", (unsigned long)message->pid);
-  SIMIX_simcall_handle(&process->simcall, message->value);
+  process->simcall_handle(message->value);
   if (channel_.send(MC_MESSAGE_WAITING))
     xbt_die("Could not send MESSAGE_WAITING to model-checker");
 }