Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Add AddressSpace::process() method
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 6 Oct 2015 10:21:13 +0000 (12:21 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 9 Oct 2015 12:11:23 +0000 (14:11 +0200)
src/mc/AddressSpace.hpp
src/mc/Process.cpp
src/mc/Process.hpp
src/mc/mc_checkpoint.cpp
src/mc/mc_snapshot.cpp
src/mc/mc_snapshot.h

index 2dea315..e23e9ac 100644 (file)
@@ -127,6 +127,8 @@ const int ProcessIndexDisabled = -2;
 const int ProcessIndexAny = 0;
 
 class AddressSpace {
+private:
+  Process* process_;
 public:
   enum ReadMode {
     Normal,
@@ -135,7 +137,10 @@ public:
      */
     Lazy
   };
+  AddressSpace(Process* process) : process_(process) {}
   virtual ~AddressSpace();
+
+  simgrid::mc::Process* process() { return process_; }
   virtual const void* read_bytes(void* buffer, std::size_t size,
     remote_ptr<void> address, int process_index = ProcessIndexAny,
     ReadMode mode = Normal) const = 0;
index fbf411d..78f4b45 100644 (file)
@@ -206,7 +206,7 @@ int open_vm(pid_t pid, int flags)
 namespace simgrid {
 namespace mc {
 
-Process::Process(pid_t pid, int sockfd)
+Process::Process(pid_t pid, int sockfd) : AddressSpace(this)
 {
   Process* process = this;
   process->socket_ = sockfd;
index 819e8ec..af42a12 100644 (file)
@@ -58,6 +58,11 @@ public:
   Process(pid_t pid, int sockfd);
   ~Process();
 
+  Process(Process const&) = delete;
+  Process(Process &&) = delete;
+  Process& operator=(Process const&) = delete;
+  Process& operator=(Process &&) = delete;
+
   // Read memory:
   const void* read_bytes(void* buffer, std::size_t size,
     remote_ptr<void> address, int process_index = ProcessIndexAny,
index 8c64e1b..aadcea8 100644 (file)
@@ -487,7 +487,7 @@ static std::vector<s_mc_heap_ignore_region_t> MC_take_snapshot_ignore()
 
 static void MC_snapshot_handle_ignore(mc_snapshot_t snapshot)
 {
-  xbt_assert(snapshot->process);
+  xbt_assert(snapshot->process());
   
   // Copy the memory:
   for (auto const& region : mc_model_checker->process().ignored_regions()) {
@@ -495,7 +495,7 @@ static void MC_snapshot_handle_ignore(mc_snapshot_t snapshot)
     ignored_data.start = (void*)region.addr;
     ignored_data.data.resize(region.size);
     // TODO, we should do this once per privatization segment:
-    snapshot->process->read_bytes(
+    snapshot->process()->read_bytes(
       ignored_data.data.data(), region.size, remote(region.addr),
       simgrid::mc::ProcessIndexDisabled);
     snapshot->ignored_data.push_back(std::move(ignored_data));
@@ -503,7 +503,7 @@ static void MC_snapshot_handle_ignore(mc_snapshot_t snapshot)
 
   // Zero the memory:
   for(auto const& region : mc_model_checker->process().ignored_regions()) {
-    snapshot->process->clear_bytes(remote(region.addr), region.size);
+    snapshot->process()->clear_bytes(remote(region.addr), region.size);
   }
 
 }
@@ -511,7 +511,7 @@ static void MC_snapshot_handle_ignore(mc_snapshot_t snapshot)
 static void MC_snapshot_ignore_restore(mc_snapshot_t snapshot)
 {
   for (auto const& ignored_data : snapshot->ignored_data)
-    snapshot->process->write_bytes(
+    snapshot->process()->write_bytes(
       ignored_data.data.data(), ignored_data.data.size(),
       remote(ignored_data.start));
 }
@@ -601,9 +601,8 @@ mc_snapshot_t MC_take_snapshot(int num_state)
 
   simgrid::mc::Process* mc_process = &mc_model_checker->process();
 
-  mc_snapshot_t snapshot = new simgrid::mc::Snapshot();
+  mc_snapshot_t snapshot = new simgrid::mc::Snapshot(mc_process);
 
-  snapshot->process = mc_process;
   snapshot->num_state = num_state;
 
   smx_process_t process;
index c4662ec..324c6ea 100644 (file)
@@ -153,8 +153,8 @@ int MC_snapshot_memcmp(
 namespace simgrid {
 namespace mc {
 
-Snapshot::Snapshot() :
-  process(nullptr),
+Snapshot::Snapshot(Process* process) :
+  AddressSpace(process),
   num_state(0),
   heap_bytes_used(0),
   enabled_processes(),
index d9ee92c..cf2dc5a 100644 (file)
@@ -142,13 +142,12 @@ namespace mc {
 
 class XBT_PRIVATE Snapshot final : public AddressSpace {
 public:
-  Snapshot();
+  Snapshot(Process* process);
   ~Snapshot();
   const void* read_bytes(void* buffer, std::size_t size,
     remote_ptr<void> address, int process_index = ProcessIndexAny,
     ReadMode mode = Normal) const override;
 public: // To be private
-  simgrid::mc::Process* process;
   int num_state;
   size_t heap_bytes_used;
   std::vector<std::unique_ptr<s_mc_mem_region_t>> snapshot_regions;