- 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");
-
- client_->handleMessages();
- return client_.get();
+ if (raise(SIGSTOP) != 0)
+ throw simgrid::xbt::errno_error("Could not wait for the model-checker");
+
+ instance_->handle_messages();
+ return instance_.get();
+}
+
+void Client::handle_deadlock_check(s_mc_message_t*)
+{
+ bool deadlock = false;
+ if (not simix_global->process_list.empty()) {
+ deadlock = true;
+ for (auto const& kv : simix_global->process_list)
+ if (simgrid::mc::actor_is_enabled(kv.second)) {
+ deadlock = false;
+ break;
+ }
+ }
+
+ // Send result:
+ s_mc_message_int_t answer{MC_MESSAGE_DEADLOCK_CHECK_REPLY, deadlock};
+ xbt_assert(channel_.send(answer) == 0, "Could not send response");
+}
+void Client::handle_continue(s_mc_message_t*)
+{
+ /* Nothing to do */
+}
+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);
+ if (channel_.send(MC_MESSAGE_WAITING))
+ xbt_die("Could not send MESSAGE_WAITING to model-checker");
+}
+
+void Client::handle_actor_enabled(s_mc_message_actor_enabled_t* msg)
+{
+ bool res = simgrid::mc::actor_is_enabled(SIMIX_process_from_PID(msg->aid));
+ s_mc_message_int_t answer{MC_MESSAGE_ACTOR_ENABLED_REPLY, res};
+ channel_.send(answer);