Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: actually remove the comm channel from RemoteClientMemory
[simgrid.git] / src / mc / ModelChecker.hpp
1 /* Copyright (c) 2007-2020. 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/sosp/PageStore.hpp"
11 #include "xbt/base.h"
12
13 #include <memory>
14 #include <set>
15 #include <string>
16
17 namespace simgrid {
18 namespace mc {
19
20 /** State of the model-checker (global variables for the model checker)
21  */
22 class ModelChecker {
23   CheckerSide event_loop_;
24   /** String pool for host names */
25   std::set<std::string> hostnames_;
26   // This is the parent snapshot of the current state:
27   PageStore page_store_{500};
28   std::unique_ptr<RemoteClientMemory> process_;
29   Checker* checker_ = nullptr;
30
31 public:
32   ModelChecker(ModelChecker const&) = delete;
33   ModelChecker& operator=(ModelChecker const&) = delete;
34   explicit ModelChecker(std::unique_ptr<RemoteClientMemory> process, int sockfd);
35
36   RemoteClientMemory& process() { return *process_; }
37   Channel& channel() { return event_loop_.get_channel(); }
38   PageStore& page_store()
39   {
40     return page_store_;
41   }
42
43   std::string const& get_host_name(std::string const& hostname)
44   {
45     return *this->hostnames_.insert(hostname).first;
46   }
47
48   void start();
49   void shutdown();
50   void resume(simgrid::mc::RemoteClientMemory& process);
51   void handle_events(int fd, short events);
52   void wait_for_requests();
53   void handle_simcall(Transition const& transition);
54
55   XBT_ATTRIB_NORETURN void exit(int status);
56
57   bool checkDeadlock();
58
59   Checker* getChecker() const { return checker_; }
60   void setChecker(Checker* checker) { checker_ = checker; }
61
62 private:
63   void setup_ignore();
64   bool handle_message(const char* buffer, ssize_t size);
65   void handle_waitpid();
66
67 public:
68   unsigned long visited_states = 0;
69   unsigned long executed_transitions = 0;
70 };
71
72 }
73 }
74
75 #endif