Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Differ the creation of the RemoteProcessMemory to when we have enough information
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 19 Mar 2023 15:18:05 +0000 (16:18 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 19 Mar 2023 15:18:05 +0000 (16:18 +0100)
src/mc/api/RemoteApp.cpp
src/mc/remote/CheckerSide.cpp
src/mc/remote/CheckerSide.hpp
src/mc/sosp/RemoteProcessMemory.cpp
src/mc/sosp/RemoteProcessMemory.hpp
src/mc/sosp/Snapshot_test.cpp
teshsuite/mc/dwarf-expression/dwarf-expression.cpp
teshsuite/mc/dwarf/dwarf.cpp

index df0c81f..ba3a14f 100644 (file)
@@ -289,7 +289,7 @@ void RemoteApp::wait_for_requests()
   /* Resume the application */
   if (checker_side_->get_channel().send(MessageType::CONTINUE) != 0)
     throw xbt::errno_error();
-  get_remote_process_memory().clear_cache();
+  checker_side_->clear_memory_cache();
 
   if (checker_side_->running())
     checker_side_->dispatch_events();
index 1660265..9c04307 100644 (file)
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkerside, mc, "MC communication with the application");
 
 namespace simgrid::mc {
-CheckerSide::CheckerSide(int sockfd, pid_t pid)
-    : remote_memory_(std::make_unique<simgrid::mc::RemoteProcessMemory>(pid))
-    , channel_(sockfd)
-    , running_(true)
-    , pid_(pid)
+CheckerSide::CheckerSide(int sockfd, pid_t pid) : channel_(sockfd), running_(true), pid_(pid)
 {
   auto* base = event_base_new();
   base_.reset(base);
@@ -88,8 +84,8 @@ bool CheckerSide::handle_message(const char* buffer, ssize_t size)
       xbt_assert(size == sizeof(message), "Broken message. Got %d bytes instead of %d.", (int)size,
                  (int)sizeof(message));
       memcpy(&message, buffer, sizeof(message));
-
-      get_remote_memory().init(message.mmalloc_default_mdp);
+      /* Create the memory address space, now that we have the mandatory information */
+      remote_memory_ = std::make_unique<simgrid::mc::RemoteProcessMemory>(pid_, message.mmalloc_default_mdp);
       break;
     }
 
@@ -154,6 +150,12 @@ bool CheckerSide::handle_message(const char* buffer, ssize_t size)
   return true;
 }
 
+void CheckerSide::clear_memory_cache()
+{
+  if (remote_memory_)
+    remote_memory_->clear_cache();
+}
+
 void CheckerSide::handle_waitpid()
 {
   XBT_DEBUG("Check for wait event");
index 53f121c..d3e571b 100644 (file)
@@ -47,8 +47,9 @@ public:
   pid_t get_pid() const { return pid_; }
   bool running() const { return running_; }
   void terminate() { running_ = false; }
-  RemoteProcessMemory& get_remote_memory() { return *remote_memory_.get(); }
   void handle_waitpid();
+  RemoteProcessMemory& get_remote_memory() { return *remote_memory_.get(); }
+  void clear_memory_cache();
 };
 
 } // namespace simgrid::mc
index 0a06fb4..18093b3 100644 (file)
@@ -106,9 +106,7 @@ int open_vm(pid_t pid, int flags)
 
 // ***** RemoteProcessMemory
 
-RemoteProcessMemory::RemoteProcessMemory(pid_t pid) : AddressSpace(this), pid_(pid) {}
-
-void RemoteProcessMemory::init(xbt_mheap_t mmalloc_default_mdp)
+RemoteProcessMemory::RemoteProcessMemory(pid_t pid, xbt_mheap_t mmalloc_default_mdp) : AddressSpace(this), pid_(pid)
 {
   this->heap_address = remote(mmalloc_default_mdp);
 
index 7b4dff5..eeff932 100644 (file)
@@ -50,9 +50,8 @@ private:
   static constexpr int cache_malloc = 2;
 
 public:
-  explicit RemoteProcessMemory(pid_t pid);
+  explicit RemoteProcessMemory(pid_t pid, xbt_mheap_t mmalloc_default_mdp);
   ~RemoteProcessMemory() override;
-  void init(xbt_mheap_t mmalloc_default_mdp);
 
   RemoteProcessMemory(RemoteProcessMemory const&)            = delete;
   RemoteProcessMemory(RemoteProcessMemory&&)                 = delete;
index 0883e1e..237065b 100644 (file)
@@ -55,8 +55,7 @@ void snap_test_helper::Init()
   REQUIRE(xbt_pagesize == getpagesize());
   REQUIRE(1 << xbt_pagebits == xbt_pagesize);
 
-  memory_ = std::make_unique<simgrid::mc::RemoteProcessMemory>(getpid());
-  memory_->init(nullptr);
+  memory_ = std::make_unique<simgrid::mc::RemoteProcessMemory>(getpid(), nullptr);
 }
 
 snap_test_helper::prologue_return snap_test_helper::prologue(int n)
index 2e50663..cccdce3 100644 (file)
@@ -148,8 +148,7 @@ static void test_deref(simgrid::dwarf::ExpressionContext const& state)
 
 int main()
 {
-  auto* process = new simgrid::mc::RemoteProcessMemory(getpid());
-  process->init(nullptr);
+  auto* process = new simgrid::mc::RemoteProcessMemory(getpid(), nullptr);
 
   simgrid::dwarf::ExpressionContext state;
   state.address_space = (simgrid::mc::AddressSpace*) process;
index b564b1c..aa86545 100644 (file)
@@ -122,8 +122,7 @@ int main(int argc, char** argv)
   const simgrid::mc::Variable* var;
   simgrid::mc::Type* type;
 
-  simgrid::mc::RemoteProcessMemory process(getpid());
-  process.init(nullptr);
+  simgrid::mc::RemoteProcessMemory process(getpid(), nullptr);
 
   test_global_variable(process, process.binary_info.get(), "some_local_variable", &some_local_variable, sizeof(int));