Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move the PageStore from ModelChecker to RemoteApp
[simgrid.git] / src / mc / ModelChecker.hpp
1 /* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SIMGRID_MC_MODEL_CHECKER_HPP
7 #define SIMGRID_MC_MODEL_CHECKER_HPP
8
9 #include "src/mc/remote/CheckerSide.hpp"
10 #include "src/mc/remote/RemotePtr.hpp"
11 #include "src/mc/sosp/PageStore.hpp"
12 #include "xbt/base.h"
13
14 #include <memory>
15
16 namespace simgrid::mc {
17
18 /** State of the model-checker (global variables for the model checker)
19  */
20 class ModelChecker {
21   CheckerSide checker_side_;
22   std::unique_ptr<RemoteProcess> remote_process_;
23   Exploration* exploration_ = nullptr;
24
25 public:
26   ModelChecker(ModelChecker const&) = delete;
27   ModelChecker& operator=(ModelChecker const&) = delete;
28   explicit ModelChecker(std::unique_ptr<RemoteProcess> remote_simulation, int sockfd);
29
30   RemoteProcess& get_remote_process() { return *remote_process_; }
31   Channel& channel() { return checker_side_.get_channel(); }
32
33   void start();
34   void shutdown();
35   void resume();
36   void wait_for_requests();
37
38   /** Let the application take a transition. A new Transition is created iff the last parameter is true */
39   Transition* handle_simcall(aid_t aid, int times_considered, bool new_transition);
40
41   /* Interactions with the simcall observer */
42   XBT_ATTRIB_NORETURN void exit(int status);
43
44   void finalize_app(bool terminate_asap = false);
45
46   Exploration* get_exploration() const { return exploration_; }
47   void set_exploration(Exploration* exploration) { exploration_ = exploration; }
48
49 private:
50   void setup_ignore();
51   bool handle_message(const char* buffer, ssize_t size);
52   void handle_waitpid();
53 };
54
55 } // namespace simgrid::mc
56
57 #endif