X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c3ac58f9e63770cca194ec50390ac8ccc8e499e8..3d845df082d79ab89649c1a8829eea201ae01085:/src/mc/simgrid_mc.cpp diff --git a/src/mc/simgrid_mc.cpp b/src/mc/simgrid_mc.cpp index b70091d5f7..f56cc71cce 100644 --- a/src/mc/simgrid_mc.cpp +++ b/src/mc/simgrid_mc.cpp @@ -19,6 +19,10 @@ #include #include +#ifdef __linux__ +#include +#endif + #include #include "simgrid/sg_config.h" @@ -28,16 +32,24 @@ #include "mc_private.h" #include "mc_protocol.h" #include "mc_server.h" -#include "mc_model_checker.h" #include "mc_safety.h" +#include "mc_comm_pattern.h" +#include "mc_liveness.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_main, mc, "Entry point for simgrid-mc"); -static const bool trace = true; - static int do_child(int socket, char** argv) { XBT_DEBUG("Inside the child process PID=%i", (int) getpid()); + +#ifdef __linux__ + // Make sure we do not outlive our parent: + if (prctl(PR_SET_PDEATHSIG, SIGHUP) != 0) { + std::perror("simgrid-mc"); + return MC_SERVER_ERROR; + } +#endif + int res; // Remove CLOEXEC in order to pass the socket to the exec-ed program: @@ -56,6 +68,11 @@ static int do_child(int socket, char** argv) // Set environment: setenv(MC_ENV_VARIABLE, "1", 1); + // Disable lazy relocation in the model-ched process. + // We don't want the model-checked process to modify its .got.plt during + // snapshot. + setenv("LC_BIND_NOW", "1", 1); + char buffer[64]; res = std::snprintf(buffer, sizeof(buffer), "%i", socket); if ((size_t) res >= sizeof(buffer) || res == -1) @@ -76,27 +93,18 @@ static int do_parent(int socket, pid_t child) mc_mode = MC_MODE_SERVER; mc_server = new s_mc_server(child, socket); mc_server->start(); - MC_init_pid(child, socket); - - if (_sg_mc_comms_determinism || _sg_mc_send_determinism) { - mc_server->loop(); - } - - else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0') { - if (mc_reduce_kind == e_mc_reduce_unset) - mc_reduce_kind = e_mc_reduce_dpor; - MC_do_the_modelcheck_for_real(); - } - - else { - mc_server->loop(); - } - + MC_init_model_checker(child, socket); + if (_sg_mc_comms_determinism || _sg_mc_send_determinism) + MC_modelcheck_comm_determinism(); + else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0') + MC_modelcheck_safety(); + else + MC_modelcheck_liveness(); mc_server->shutdown(); mc_server->exit(); } catch(std::exception& e) { - XBT_ERROR(e.what()); + XBT_ERROR("Exception: %s", e.what()); } exit(MC_SERVER_ERROR); } @@ -111,6 +119,8 @@ static char** argvdup(int argc, char** argv) int main(int argc, char** argv) { + _sg_do_model_check = 1; + // We need to keep the original parameters in order to pass them to the // model-checked process: int argc_copy = argc; @@ -121,25 +131,6 @@ int main(int argc, char** argv) if (argc < 2) xbt_die("Missing arguments.\n"); - bool server_mode = true; - char* env = std::getenv("SIMGRID_MC_MODE"); - if (env) { - if (std::strcmp(env, "server") == 0) - server_mode = true; - else if (std::strcmp(env, "standalone") == 0) - server_mode = false; - else - xbt_die("Unrecognised value for SIMGRID_MC_MODE (server/standalone)"); - } - - if (!server_mode) { - setenv(MC_ENV_VARIABLE, "1", 1); - execvp(argv[1], argv+1); - - std::perror("simgrid-mc"); - return 127; - } - // Create a AF_LOCAL socketpair: int res;