#include "src/mc/remote/Client.hpp"
#include "src/mc/remote/mc_protocol.h"
-#include "src/smpi/private.hpp"
+#include "src/smpi/include/private.hpp"
// We won't need those once the separation MCer/MCed is complete:
#include "src/mc/mc_smx.h"
namespace simgrid {
namespace mc {
-std::unique_ptr<Client> Client::client_;
+std::unique_ptr<Client> Client::instance_;
Client* Client::initialize()
{
return nullptr;
// Do not break if we are called multiple times:
- if (client_)
- return client_.get();
+ if (instance_)
+ return instance_.get();
_sg_do_model_check = 1;
socklen_t socklen = sizeof(type);
if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &socklen) != 0)
xbt_die("Could not check socket type");
- if (type != SOCK_DGRAM)
+ if (type != SOCK_SEQPACKET)
xbt_die("Unexpected socket type %i", type);
XBT_DEBUG("Model-checked application found expected socket type");
- client_ = std::unique_ptr<Client>(new simgrid::mc::Client(fd));
+ instance_ = std::unique_ptr<Client>(new simgrid::mc::Client(fd));
// Wait for the model-checker:
errno = 0;
if (errno != 0 || raise(SIGSTOP) != 0)
xbt_die("Could not wait for the model-checker");
- client_->handleMessages();
- return client_.get();
+ instance_->handleMessages();
+ return instance_.get();
}
void Client::handleDeadlockCheck(mc_message_t* msg)
bool deadlock = false;
if (not simix_global->process_list.empty()) {
deadlock = true;
- for (auto kv : simix_global->process_list)
+ for (auto const& kv : simix_global->process_list)
if (simgrid::mc::actor_is_enabled(kv.second)) {
deadlock = false;
break;
}
void Client::handleContinue(mc_message_t* msg)
{
+ /* Nothing to do */
}
void Client::handleSimcall(s_mc_message_simcall_handle_t* message)
{
smpi_really_switch_data_segment(message->index);
#endif
}
+void Client::handleActorEnabled(s_mc_message_actor_enabled_t* msg)
+{
+ bool res = simgrid::mc::actor_is_enabled(SIMIX_process_from_PID(msg->aid));
+ s_mc_message_int answer{MC_MESSAGE_ACTOR_ENABLED_REPLY, res};
+ channel_.send(answer);
+}
void Client::handleMessages()
{
switch (message->type) {
case MC_MESSAGE_DEADLOCK_CHECK:
- xbt_assert(received_size == sizeof(mc_message_t), "Unexpected size for DEADLOCK_CHECK (%zu != %zu)",
+ xbt_assert(received_size == sizeof(mc_message_t), "Unexpected size for DEADLOCK_CHECK (%zd != %zu)",
received_size, sizeof(mc_message_t));
handleDeadlockCheck(message);
break;
case MC_MESSAGE_CONTINUE:
- xbt_assert(received_size == sizeof(mc_message_t), "Unexpected size for MESSAGE_CONTINUE (%zu != %zu)",
+ xbt_assert(received_size == sizeof(mc_message_t), "Unexpected size for MESSAGE_CONTINUE (%zd != %zu)",
received_size, sizeof(mc_message_t));
handleContinue(message);
return;
case MC_MESSAGE_SIMCALL_HANDLE:
xbt_assert(received_size == sizeof(s_mc_message_simcall_handle_t),
- "Unexpected size for SIMCALL_HANDLE (%zu != %zu)", received_size,
+ "Unexpected size for SIMCALL_HANDLE (%zd != %zu)", received_size,
sizeof(s_mc_message_simcall_handle_t));
handleSimcall((s_mc_message_simcall_handle_t*)message_buffer);
break;
case MC_MESSAGE_RESTORE:
- xbt_assert(received_size == sizeof(mc_message_t), "Unexpected size for MESSAGE_RESTORE (%zu != %zu)",
+ xbt_assert(received_size == sizeof(mc_message_t), "Unexpected size for MESSAGE_RESTORE (%zd != %zu)",
received_size, sizeof(mc_message_t));
handleRestore((s_mc_message_restore_t*)message_buffer);
break;
+ case MC_MESSAGE_ACTOR_ENABLED:
+ xbt_assert(received_size == sizeof(s_mc_message_actor_enabled_t),
+ "Unexpected size for ACTOR_ENABLED (%zd != %zu)", received_size,
+ sizeof(s_mc_message_actor_enabled_t));
+ handleActorEnabled((s_mc_message_actor_enabled_t*)message_buffer);
+ break;
+
default:
xbt_die("Received unexpected message %s (%i)", MC_message_type_name(message->type), message->type);
break;
void Client::declareSymbol(const char* name, int* value)
{
- s_mc_register_symbol_message_t message;
+ s_mc_message_register_symbol_t message;
message.type = MC_MESSAGE_REGISTER_SYMBOL;
if (strlen(name) + 1 > sizeof(message.name))
xbt_die("Symbol is too long");