X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d51a876f765fc68b3e1e667f867b91a1b4987a85..27f768c6fbe663c6de000473c44a61222b77d481:/src/mc/ModelChecker.cpp diff --git a/src/mc/ModelChecker.cpp b/src/mc/ModelChecker.cpp index 15d5d835fc..15f6d234c8 100644 --- a/src/mc/ModelChecker.cpp +++ b/src/mc/ModelChecker.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "simgrid/sg_config.h" @@ -83,7 +84,7 @@ void ModelChecker::start() sigemptyset(&set); sigaddset(&set, SIGCHLD); if (sigprocmask(SIG_BLOCK, &set, nullptr) == -1) - throw std::system_error(errno, std::system_category()); + throw simgrid::xbt::errno_error(errno); sigset_t full_set; sigfillset(&full_set); @@ -97,7 +98,7 @@ void ModelChecker::start() int signal_fd = signalfd(-1, &set, 0); if (signal_fd == -1) - throw std::system_error(errno, std::system_category()); + throw simgrid::xbt::errno_error(errno); struct pollfd* signalfd_pollfd = &fds_[SIGNAL_FD_INDEX]; signalfd_pollfd->fd = signal_fd; @@ -178,7 +179,7 @@ void ModelChecker::resume(simgrid::mc::Process& process) { int res = process.send_message(MC_MESSAGE_CONTINUE); if (res) - throw std::system_error(res, std::system_category()); + throw simgrid::xbt::errno_error(res); process.cache_flags = (mc_process_cache_flags_t) 0; } @@ -189,7 +190,7 @@ void throw_socket_error(int fd) socklen_t errlen = sizeof(error); if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&error, &errlen) == -1) error = errno; - throw std::system_error(error, std::system_category()); + throw simgrid::xbt::errno_error(errno); } bool ModelChecker::handle_message(char* buffer, ssize_t size) @@ -262,7 +263,7 @@ bool ModelChecker::handle_message(char* buffer, ssize_t size) _mc_property_automaton = xbt_automaton_new(); simgrid::mc::Process* process = &this->process(); - simgrid::mc::remote_ptr address + simgrid::mc::RemotePtr address = simgrid::mc::remote((int*) message.data); simgrid::xbt::add_proposition(_mc_property_automaton, message.name, @@ -277,7 +278,7 @@ bool ModelChecker::handle_message(char* buffer, ssize_t size) case MC_MESSAGE_ASSERTION_FAILED: MC_report_assertion_error(); - ::exit(SIMGRID_MC_EXIT_SAFETY); + this->exit(SIMGRID_MC_EXIT_SAFETY); break; default: @@ -287,6 +288,15 @@ bool ModelChecker::handle_message(char* buffer, ssize_t size) return true; } +/** Terminate the model-checker aplication */ +void ModelChecker::exit(int status) +{ + // TODO, terminate the model checker politely instead of exiting rudel + if (process().running()) + kill(process().pid(), SIGKILL); + ::exit(status); +} + bool ModelChecker::handle_events() { char buffer[MC_MESSAGE_LENGTH]; @@ -298,7 +308,7 @@ bool ModelChecker::handle_events() case EINTR: continue; default: - throw std::system_error(errno, std::system_category()); + throw simgrid::xbt::errno_error(errno); } } @@ -306,7 +316,7 @@ bool ModelChecker::handle_events() if (socket_pollfd->revents & POLLIN) { ssize_t size = MC_receive_message(socket_pollfd->fd, buffer, sizeof(buffer), MSG_DONTWAIT); if (size == -1 && errno != EAGAIN) - throw std::system_error(errno, std::system_category()); + throw simgrid::xbt::errno_error(errno); return handle_message(buffer, size); } if (socket_pollfd->revents & POLLERR) { @@ -347,7 +357,7 @@ void ModelChecker::handle_signals() if (errno == EINTR) continue; else - throw std::system_error(errno, std::system_category()); + throw simgrid::xbt::errno_error(errno); } else if (size != sizeof(info)) return throw std::runtime_error( "Bad communication with model-checked application"); @@ -372,7 +382,7 @@ void ModelChecker::handle_waitpid() break; } else { XBT_ERROR("Could not wait for pid"); - throw std::system_error(errno, std::system_category()); + throw simgrid::xbt::errno_error(errno); } } @@ -384,7 +394,7 @@ void ModelChecker::handle_waitpid() xbt_die("Could not get exit status"); if (WIFSIGNALED(status)) { MC_report_crash(status); - ::exit(SIMGRID_MC_EXIT_PROGRAM_CRASH); + mc_model_checker->exit(SIMGRID_MC_EXIT_PROGRAM_CRASH); } }