#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");
// Make sure we do not outlive our parent:
if (prctl(PR_SET_PDEATHSIG, SIGHUP) != 0) {
std::perror("simgrid-mc");
- return SIMGRID_ERROR;
+ return SIMGRID_MC_EXIT_ERROR;
}
#endif
int fdflags = fcntl(socket, F_GETFD, 0);
if (fdflags == -1) {
std::perror("simgrid-mc");
- return SIMGRID_ERROR;
+ return SIMGRID_MC_EXIT_ERROR;
}
if (fcntl(socket, F_SETFD, fdflags & ~FD_CLOEXEC) == -1) {
std::perror("simgrid-mc");
- return SIMGRID_ERROR;
+ return SIMGRID_MC_EXIT_ERROR;
}
XBT_DEBUG("CLOEXEC removed on socket %i", socket);
char buffer[64];
res = std::snprintf(buffer, sizeof(buffer), "%i", socket);
if ((size_t) res >= sizeof(buffer) || res == -1)
- return SIMGRID_ERROR;
+ return SIMGRID_MC_EXIT_ERROR;
setenv(MC_ENV_SOCKET_FD, buffer, 1);
execvp(argv[1], argv+1);
XBT_ERROR("Could not execute the child process");
- return SIMGRID_ERROR;
+ 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();
+ mc_model_checker = new simgrid::mc::ModelChecker(child, socket);
+ 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_ERROR);
}
static char** argvdup(int argc, char** argv)
res = socketpair(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0, sockets);
if (res == -1) {
perror("simgrid-mc");
- return SIMGRID_ERROR;
+ return SIMGRID_MC_EXIT_ERROR;
}
XBT_DEBUG("Created socketpair");
pid_t pid = fork();
if (pid < 0) {
perror("simgrid-mc");
- return SIMGRID_ERROR;
+ return SIMGRID_MC_EXIT_ERROR;
} else if (pid == 0) {
close(sockets[1]);
int res = do_child(sockets[0], argv);