X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/41966a6d30f870c0c7cc5ad5e64c0263e63970a8..50753d5f8442a47c17c4035724201a18a7ff6146:/src/mc/api/RemoteApp.cpp diff --git a/src/mc/api/RemoteApp.cpp b/src/mc/api/RemoteApp.cpp index 2ddd5c0876..45e595eed6 100644 --- a/src/mc/api/RemoteApp.cpp +++ b/src/mc/api/RemoteApp.cpp @@ -29,22 +29,31 @@ XBT_LOG_EXTERNAL_CATEGORY(mc_global); namespace simgrid::mc { -RemoteApp::RemoteApp(const std::vector& args) +RemoteApp::RemoteApp(const std::vector& args, bool need_memory_introspection) { - checker_side_ = std::make_unique(args); + for (auto* arg : args) + app_args_.push_back(arg); - initial_snapshot_ = std::make_shared(0, page_store_, checker_side_->get_remote_memory()); + checker_side_ = std::make_unique(app_args_, need_memory_introspection); + + if (need_memory_introspection) + initial_snapshot_ = std::make_shared(0, page_store_, *checker_side_->get_remote_memory()); } RemoteApp::~RemoteApp() { initial_snapshot_ = nullptr; - shutdown(); + checker_side_ = nullptr; } -void RemoteApp::restore_initial_state() const +void RemoteApp::restore_initial_state() { - this->initial_snapshot_->restore(checker_side_->get_remote_memory()); + if (initial_snapshot_ == nullptr) { // No memory introspection + // We need to destroy the existing CheckerSide before creating the new one, or libevent gets crazy + checker_side_.reset(nullptr); + checker_side_.reset(new simgrid::mc::CheckerSide(app_args_, true)); + } else + initial_snapshot_->restore(*checker_side_->get_remote_memory()); } unsigned long RemoteApp::get_maxpid() const @@ -168,18 +177,6 @@ void RemoteApp::wait_for_requests() checker_side_->wait_for_requests(); } -void RemoteApp::shutdown() -{ - XBT_DEBUG("Shutting down model-checker"); - - if (checker_side_->running()) { - XBT_DEBUG("Killing process"); - finalize_app(true); - kill(checker_side_->get_pid(), SIGKILL); - checker_side_->terminate(); - } -} - Transition* RemoteApp::handle_simcall(aid_t aid, int times_considered, bool new_transition) { s_mc_message_simcall_execute_t m = {}; @@ -188,7 +185,8 @@ Transition* RemoteApp::handle_simcall(aid_t aid, int times_considered, bool new_ m.times_considered_ = times_considered; checker_side_->get_channel().send(m); - get_remote_process_memory().clear_cache(); + if (auto* memory = get_remote_process_memory(); memory != nullptr) + memory->clear_cache(); if (checker_side_->running()) checker_side_->dispatch_events(); // The app may send messages while processing the transition @@ -209,18 +207,7 @@ Transition* RemoteApp::handle_simcall(aid_t aid, int times_considered, bool new_ void RemoteApp::finalize_app(bool terminate_asap) { - s_mc_message_int_t m = {}; - m.type = MessageType::FINALIZE; - m.value = terminate_asap; - xbt_assert(checker_side_->get_channel().send(m) == 0, "Could not ask the app to finalize on need"); - - s_mc_message_t answer; - ssize_t s = checker_side_->get_channel().receive(answer); - xbt_assert(s != -1, "Could not receive answer to FINALIZE"); - xbt_assert(s == sizeof answer, "Broken message (size=%zd; expected %zu)", s, sizeof answer); - xbt_assert(answer.type == MessageType::FINALIZE_REPLY, - "Received unexpected message %s (%i); expected MessageType::FINALIZE_REPLY (%i)", to_c_str(answer.type), - (int)answer.type, (int)MessageType::FINALIZE_REPLY); + checker_side_->finalize(terminate_asap); } } // namespace simgrid::mc