X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ea9cce21b6d3f37823143217f1ca183bb2f0c9ac..20c4a4134847860ac7093fa36623e47b35888558:/src/mc/mc_client.cpp diff --git a/src/mc/mc_client.cpp b/src/mc/mc_client.cpp index 984a221ac0..12edc6bfa1 100644 --- a/src/mc/mc_client.cpp +++ b/src/mc/mc_client.cpp @@ -4,11 +4,11 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include -#include +#include +#include #include +#include #include #include @@ -21,7 +21,6 @@ // We won't need those once the separation MCer/MCed is complete: #include "mc_mmalloc.h" #include "mc_ignore.h" -#include "mc_model_checker.h" #include "mc_private.h" // MC_deadlock_check() #include "mc_smx.h" @@ -33,12 +32,18 @@ mc_client_t mc_client; void MC_client_init(void) { + if (mc_mode != MC_MODE_NONE) + return; + if (!getenv(MC_ENV_SOCKET_FD)) + return; + mc_mode = MC_MODE_CLIENT; + if (mc_client) { XBT_WARN("MC_client_init called more than once."); return; } - char* fd_env = getenv(MC_ENV_SOCKET_FD); + char* fd_env = std::getenv(MC_ENV_SOCKET_FD); if (!fd_env) xbt_die("MC socket not found"); @@ -56,12 +61,11 @@ void MC_client_init(void) mc_client = xbt_new0(s_mc_client_t, 1); mc_client->fd = fd; mc_client->active = 1; -} -void MC_client_hello(void) -{ - if (MC_protocol_hello(mc_client->fd) != 0) - xbt_die("Could not say hello the MC server"); + // Waiting for the model-checker: + if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) == -1 || raise(SIGSTOP) != 0) + xbt_die("Could not wait for the model-checker"); + MC_client_handle_messages(); } void MC_client_send_message(void* message, size_t size) @@ -120,6 +124,16 @@ void MC_client_handle_messages(void) } break; + case MC_MESSAGE_RESTORE: + { + s_mc_restore_message_t message; + if (s != sizeof(message)) + xbt_die("Unexpected size for SIMCALL_HANDLE"); + memcpy(&message, message_buffer, sizeof(message)); + smpi_really_switch_data_segment(message.index); + } + break; + default: xbt_die("%s received unexpected message %s (%i)", MC_mode_name(mc_mode),