process.ignore_global_variable("counter");
}
-void ModelChecker::shutdown()
-{
- XBT_DEBUG("Shutting down model-checker");
-
- RemoteProcessMemory& process = get_remote_process_memory();
- if (process.running()) {
- XBT_DEBUG("Killing process");
- finalize_app(true);
- kill(process.pid(), SIGKILL);
- process.terminate();
- }
-}
-
void ModelChecker::resume()
{
if (checker_side_.get_channel().send(MessageType::CONTINUE) != 0)
/** Terminate the model-checker application */
void ModelChecker::exit(int status)
{
- shutdown();
+ get_exploration()->get_remote_app().shutdown();
::exit(status);
}
return nullptr;
}
-void ModelChecker::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);
-}
-
} // namespace simgrid::mc
Channel& channel() { return checker_side_.get_channel(); }
void start();
- void shutdown();
void resume();
void wait_for_requests();
/* Interactions with the simcall observer */
XBT_ATTRIB_NORETURN void exit(int status);
- void finalize_app(bool terminate_asap = false);
-
Exploration* get_exploration() const { return exploration_; }
void set_exploration(Exploration* exploration) { exploration_ = exploration; }
{
initial_snapshot_ = nullptr;
if (model_checker_) {
- model_checker_->shutdown();
+ shutdown();
model_checker_ = nullptr;
mc_model_checker = nullptr;
}
throw DeadlockError();
}
}
+
+void RemoteApp::shutdown()
+{
+ XBT_DEBUG("Shutting down model-checker");
+
+ RemoteProcessMemory& process = get_remote_process_memory();
+ if (process.running()) {
+ XBT_DEBUG("Killing process");
+ finalize_app(true);
+ kill(process.pid(), SIGKILL);
+ process.terminate();
+ }
+}
+
+void RemoteApp::finalize_app(bool terminate_asap)
+{
+ s_mc_message_int_t m = {};
+ m.type = MessageType::FINALIZE;
+ m.value = terminate_asap;
+ xbt_assert(model_checker_->channel().send(m) == 0, "Could not ask the app to finalize on need");
+
+ s_mc_message_t answer;
+ ssize_t s = model_checker_->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);
+}
+
} // namespace simgrid::mc
/** Ask to the application to check for a deadlock. If so, do an error message and throw a DeadlockError. */
void check_deadlock() const;
+ /** Ask the application to run post-mortem analysis, and maybe to stop ASAP */
+ void finalize_app(bool terminate_asap = false);
+ /** Forcefully kill the application (after running post-mortem analysis)*/
+ void shutdown();
+
/** Retrieve the max PID of the running actors */
unsigned long get_maxpid() const;
stack_.size() + 1);
if (state->get_actor_count() == 0) {
- mc_model_checker->finalize_app();
+ get_remote_app().finalize_app();
XBT_VERB("Execution came to an end at %s (state: %ld, depth: %zu)", get_record_trace().to_string().c_str(),
state->get_num(), stack_.size());