Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mc: change 3 static functions into private methods
[simgrid.git] / src / mc / sosp / mc_snapshot.hpp
index 35d07cb..233b19c 100644 (file)
@@ -35,8 +35,8 @@ static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, simgr
     case simgrid::mc::StorageType::Privatized: {
       xbt_assert(process_index >= 0, "Missing process index for privatized region");
       xbt_assert((size_t)process_index < region->privatized_data().size(), "Out of range process index");
-      simgrid::mc::RegionSnapshot& subregion = region->privatized_data()[process_index];
-      return mc_translate_address_region(addr, &subregion, process_index);
+      simgrid::mc::RegionSnapshot* subregion = region->privatized_data()[process_index].get();
+      return mc_translate_address_region(addr, subregion, process_index);
     }
     default: // includes StorageType::NoData
       xbt_die("Storage type not supported");
@@ -74,7 +74,6 @@ struct s_local_variable_t {
   std::string name;
   simgrid::mc::Type* type;
   void* address;
-  int region;
 };
 typedef s_local_variable_t* local_variable_t;
 
@@ -91,30 +90,35 @@ namespace mc {
 
 class XBT_PRIVATE Snapshot final : public AddressSpace {
 public:
-  Snapshot(RemoteClient* process, int num_state);
+  Snapshot(int num_state, RemoteClient* process = &mc_model_checker->process());
   ~Snapshot() = default;
 
   /* Initialization */
-  void add_region(RegionType type, ObjectInformation* object_info, void* start_addr, void* permanent_addr,
-                  std::size_t size);
 
   /* Regular use */
   const void* read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, int process_index = ProcessIndexAny,
                          ReadOptions options = ReadOptions::none()) const override;
   RegionSnapshot* get_region(const void* addr, int process_index) const;
   RegionSnapshot* get_region(const void* addr, int process_index, RegionSnapshot* hinted_region) const;
+  void restore(RemoteClient* process);
 
   // To be private
   int num_state_;
   std::size_t heap_bytes_used_;
   std::vector<std::unique_ptr<RegionSnapshot>> snapshot_regions_;
   std::set<pid_t> enabled_processes_;
-  int privatization_index_;
+  int privatization_index_ = 0;
   std::vector<std::size_t> stack_sizes_;
   std::vector<s_mc_snapshot_stack_t> stacks_;
   std::vector<simgrid::mc::IgnoredHeapRegion> to_ignore_;
   std::uint64_t hash_ = 0;
   std::vector<s_mc_snapshot_ignored_data_t> ignored_data_;
+
+private:
+  void add_region(RegionType type, ObjectInformation* object_info, void* start_addr, void* permanent_addr,
+                  std::size_t size);
+  void snapshot_regions(simgrid::mc::RemoteClient* process);
+  void snapshot_stacks(simgrid::mc::RemoteClient* process);
 };
 } // namespace mc
 } // namespace simgrid
@@ -125,7 +129,6 @@ namespace simgrid {
 namespace mc {
 
 XBT_PRIVATE std::shared_ptr<Snapshot> take_snapshot(int num_state);
-XBT_PRIVATE void restore_snapshot(std::shared_ptr<Snapshot> snapshot);
 } // namespace mc
 } // namespace simgrid