xbt_assert(mc_model_checker == nullptr, "Did you manage to start the MC twice in this process?");
- checker_side_ = std::make_unique<simgrid::mc::CheckerSide>(sockets[1]);
- auto process = std::make_unique<simgrid::mc::RemoteProcessMemory>(pid);
- model_checker_ = std::make_unique<simgrid::mc::ModelChecker>(std::move(process));
-
+ auto memory = std::make_unique<simgrid::mc::RemoteProcessMemory>(pid);
+ model_checker_ = std::make_unique<simgrid::mc::ModelChecker>(std::move(memory));
mc_model_checker = model_checker_.get();
+ checker_side_ = std::make_unique<simgrid::mc::CheckerSide>(sockets[1], model_checker_.get());
+
start();
/* Take the initial snapshot */
}
void RemoteApp::start()
{
- checker_side_->start(
- [](evutil_socket_t sig, short events, void* arg) {
- auto checker = static_cast<simgrid::mc::CheckerSide*>(arg);
- if (events == EV_READ) {
- std::array<char, MC_MESSAGE_LENGTH> buffer;
- ssize_t size = recv(checker->get_channel().get_socket(), buffer.data(), buffer.size(), MSG_DONTWAIT);
- if (size == -1) {
- XBT_ERROR("Channel::receive failure: %s", strerror(errno));
- if (errno != EAGAIN)
- throw simgrid::xbt::errno_error();
- }
-
- if (not mc_model_checker->handle_message(buffer.data(), size))
- checker->break_loop();
- } else {
- xbt_die("Unexpected event");
- }
- },
- [](evutil_socket_t sig, short events, void* arg) {
- auto mc = static_cast<simgrid::mc::ModelChecker*>(arg);
- if (events == EV_SIGNAL) {
- if (sig == SIGCHLD)
- mc->handle_waitpid();
- else
- xbt_die("Unexpected signal: %d", sig);
- } else {
- xbt_die("Unexpected event");
- }
- },
- model_checker_.get());
-
XBT_DEBUG("Waiting for the model-checked process");
int status;
to_c_str(message.type), (int)message.type, (int)MessageType::DEADLOCK_CHECK_REPLY);
if (message.value != 0) {
+ auto* explo = Exploration::get_instance();
XBT_CINFO(mc_global, "Counter-example execution trace:");
- for (auto const& frame : model_checker_->get_exploration()->get_textual_trace())
+ for (auto const& frame : explo->get_textual_trace())
XBT_CINFO(mc_global, " %s", frame.c_str());
XBT_INFO("You can debug the problem (and see the whole details) by rerunning out of simgrid-mc with "
"--cfg=model-check/replay:'%s'",
- model_checker_->get_exploration()->get_record_trace().to_string().c_str());
- model_checker_->get_exploration()->log_state();
+ explo->get_record_trace().to_string().c_str());
+ explo->log_state();
throw DeadlockError();
}
}
get_remote_process_memory().clear_cache();
if (this->get_remote_process_memory().running())
- checker_side_->dispatch();
+ checker_side_->dispatch_events();
}
void RemoteApp::shutdown()
get_remote_process_memory().clear_cache();
if (this->get_remote_process_memory().running())
- checker_side_->dispatch(); // The app may send messages while processing the transition
+ checker_side_->dispatch_events(); // The app may send messages while processing the transition
s_mc_message_simcall_execute_answer_t answer;
ssize_t s = checker_side_->get_channel().receive(answer);