#include "simgrid/sg_config.h"
#include "src/xbt_modinter.h"
-#include "mc_base.h"
-#include "mc_private.h"
-#include "mc_protocol.h"
-#include "src/mc/Server.hpp"
-#include "mc_safety.h"
-#include "mc_comm_pattern.h"
-#include "mc_liveness.h"
+#include "src/mc/mc_base.h"
+#include "src/mc/mc_private.h"
+#include "src/mc/mc_protocol.h"
+#include "src/mc/mc_safety.h"
+#include "src/mc/mc_comm_pattern.h"
+#include "src/mc/mc_liveness.h"
+#include "src/mc/mc_exit.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_main, mc, "Entry point for simgrid-mc");
#ifdef __linux__
// Make sure we do not outlive our parent:
+ sigset_t mask;
+ sigemptyset (&mask);
+ if (sigprocmask(SIG_SETMASK, &mask, nullptr) < 0) {
+ std::perror ("sigprocmask");
+ return SIMGRID_MC_EXIT_ERROR;
+ }
+
if (prctl(PR_SET_PDEATHSIG, SIGHUP) != 0) {
std::perror("simgrid-mc");
return SIMGRID_MC_EXIT_ERROR;
static int do_parent(int socket, pid_t child)
{
XBT_DEBUG("Inside the parent process");
- if (simgrid::mc::server)
+ if (mc_model_checker)
xbt_die("MC server already present");
try {
mc_mode = MC_MODE_SERVER;
- simgrid::mc::server = new simgrid::mc::Server(child, socket);
- simgrid::mc::server->start();
+ std::unique_ptr<simgrid::mc::Process> process(new simgrid::mc::Process(child, socket));
+ process->privatized(sg_cfg_get_boolean("smpi/privatize_global_variables"));
+ mc_model_checker = new simgrid::mc::ModelChecker(std::move(process));
+ mc_model_checker->start();
+ int res = 0;
if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
- MC_modelcheck_comm_determinism();
+ res = MC_modelcheck_comm_determinism();
else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0')
- MC_modelcheck_safety();
+ res = MC_modelcheck_safety();
else
- MC_modelcheck_liveness();
- simgrid::mc::server->shutdown();
- simgrid::mc::server->exit();
+ res = MC_modelcheck_liveness();
+ mc_model_checker->shutdown();
+ return res;
}
catch(std::exception& e) {
XBT_ERROR("Exception: %s", e.what());
+ return SIMGRID_MC_EXIT_ERROR;
}
- exit(SIMGRID_MC_EXIT_ERROR);
}
static char** argvdup(int argc, char** argv)