X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4f0921c868b916da79370ef6ba03d368be06a6e3..603c44e45e00a577bccb42cf398a924178f17768:/src/mc/mc_client.cpp diff --git a/src/mc/mc_client.cpp b/src/mc/mc_client.cpp index 6865abda95..a173b8f884 100644 --- a/src/mc/mc_client.cpp +++ b/src/mc/mc_client.cpp @@ -8,29 +8,35 @@ #include #include +#include #include #include #include #include -#include "mc_protocol.h" -#include "mc_client.h" +#include "src/mc/mc_protocol.h" +#include "src/mc/mc_client.h" // We won't need those once the separation MCer/MCed is complete: -#include "mc_mmalloc.h" -#include "mc_ignore.h" -#include "mc_private.h" // MC_deadlock_check() -#include "mc_smx.h" - -extern "C" { +#include "src/mc/mc_ignore.h" +#include "src/mc/mc_private.h" // MC_deadlock_check() +#include "src/mc/mc_smx.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client, mc, "MC client logic"); +extern "C" { + 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; @@ -40,7 +46,7 @@ void MC_client_init(void) if (!fd_env) xbt_die("MC socket not found"); - int fd = atoi(fd_env); + int fd = xbt_str_parse_int(fd_env,bprintf("Variable %s should contain a number but contains '%%s'", MC_ENV_SOCKET_FD)); XBT_DEBUG("Model-checked application found socket FD %i", fd); int type; @@ -54,6 +60,11 @@ void MC_client_init(void) mc_client = xbt_new0(s_mc_client_t, 1); mc_client->fd = fd; mc_client->active = 1; + + // Waiting for the model-checker: + if (ptrace(PTRACE_TRACEME, 0, nullptr, 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) @@ -112,6 +123,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), @@ -127,7 +148,7 @@ void MC_client_main_loop(void) while (1) { MC_protocol_send_simple_message(mc_client->fd, MC_MESSAGE_WAITING); MC_client_handle_messages(); - MC_wait_for_requests(); + simgrid::mc::wait_for_requests(); } }