Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Replace void* used for RemoteProcess pointers.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 6 Apr 2021 10:19:14 +0000 (12:19 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 7 Apr 2021 09:08:39 +0000 (11:08 +0200)
include/simgrid/simix.hpp
src/kernel/actor/ActorImpl.cpp
src/kernel/actor/ActorImpl.hpp
src/mc/mc_smx.cpp
src/mc/remote/RemoteProcess.cpp
src/mc/remote/RemoteProcess.hpp
src/mc/remote/mc_protocol.h
src/simix/smx_global.cpp

index 2039dbf..e931b83 100644 (file)
@@ -130,8 +130,8 @@ public:
 };
 
 // In MC mode, the application sends these pointers to the MC
-void* simix_global_get_actors_addr();
-void* simix_global_get_dead_actors_addr();
+xbt_dynar_t simix_global_get_actors_addr();
+xbt_dynar_t simix_global_get_dead_actors_addr();
 
 } // namespace simix
 } // namespace simgrid
index 3cfa311..5fb355b 100644 (file)
@@ -44,7 +44,7 @@ unsigned long get_maxpid()
 {
   return maxpid;
 }
-void* get_maxpid_addr()
+unsigned long* get_maxpid_addr()
 {
   return &maxpid;
 }
index ee6d968..b820560 100644 (file)
@@ -198,7 +198,7 @@ using SynchroList =
 
 XBT_PUBLIC void create_maestro(const std::function<void()>& code);
 XBT_PUBLIC unsigned long get_maxpid();
-XBT_PUBLIC void* get_maxpid_addr(); // In MC mode, the application sends this pointers to the MC
+XBT_PUBLIC unsigned long* get_maxpid_addr(); // In MC mode, the application sends this pointers to the MC
 
 } // namespace actor
 } // namespace kernel
index 337c820..ce5800f 100644 (file)
@@ -66,12 +66,8 @@ void RemoteProcess::refresh_simix()
   if (this->cache_flags_ & RemoteProcess::cache_simix_processes)
     return;
 
-  RemotePtr<s_xbt_dynar_t> actor_vector;
-  RemotePtr<s_xbt_dynar_t> dead_actor_vector;
-  get_actor_vectors(actor_vector, dead_actor_vector);
-
-  MC_process_refresh_simix_actor_dynar(this, this->smx_actors_infos, actor_vector);
-  MC_process_refresh_simix_actor_dynar(this, this->smx_dead_actors_infos, dead_actor_vector);
+  MC_process_refresh_simix_actor_dynar(this, this->smx_actors_infos, actors_addr_);
+  MC_process_refresh_simix_actor_dynar(this, this->smx_dead_actors_infos, dead_actors_addr_);
 
   this->cache_flags_ |= RemoteProcess::cache_simix_processes;
 }
index 167a484..eb8275f 100644 (file)
@@ -217,12 +217,13 @@ int open_vm(pid_t pid, int flags)
 
 RemoteProcess::RemoteProcess(pid_t pid) : AddressSpace(this), pid_(pid), running_(true) {}
 
-void RemoteProcess::init(xbt_mheap_t mmalloc_default_mdp, void* maxpid, void* actors, void* dead_actors)
+void RemoteProcess::init(xbt_mheap_t mmalloc_default_mdp, unsigned long* maxpid, xbt_dynar_t actors,
+                         xbt_dynar_t dead_actors)
 {
   this->heap_address      = remote(mmalloc_default_mdp);
-  this->maxpid_addr_      = maxpid;
-  this->actors_addr_      = actors;
-  this->dead_actors_addr_ = dead_actors;
+  this->maxpid_addr_      = remote(maxpid);
+  this->actors_addr_      = remote(actors);
+  this->dead_actors_addr_ = remote(dead_actors);
 
   this->memory_map_ = simgrid::xbt::get_memory_map(this->pid_);
   this->init_memory_map_info();
@@ -567,18 +568,5 @@ void RemoteProcess::dump_stack() const
   _UPT_destroy(context);
   unw_destroy_addr_space(as);
 }
-
-unsigned long RemoteProcess::get_maxpid() const
-{
-  unsigned long maxpid;
-  this->read_bytes(&maxpid, sizeof(unsigned long), remote(maxpid_addr_));
-  return maxpid;
-}
-
-void RemoteProcess::get_actor_vectors(RemotePtr<s_xbt_dynar_t>& actors, RemotePtr<s_xbt_dynar_t>& dead_actors)
-{
-  actors      = remote(static_cast<s_xbt_dynar_t*>(actors_addr_));
-  dead_actors = remote(static_cast<s_xbt_dynar_t*>(dead_actors_addr_));
-}
 } // namespace mc
 } // namespace simgrid
index eda86d9..c6b0e7e 100644 (file)
@@ -75,7 +75,7 @@ private:
 public:
   explicit RemoteProcess(pid_t pid);
   ~RemoteProcess() override;
-  void init(xbt_mheap_t mmalloc_default_mdp, void* maxpid, void* actors, void* dead_actors);
+  void init(xbt_mheap_t mmalloc_default_mdp, unsigned long* maxpid, xbt_dynar_t actors, xbt_dynar_t dead_actors);
 
   RemoteProcess(RemoteProcess const&) = delete;
   RemoteProcess(RemoteProcess&&)      = delete;
@@ -166,9 +166,9 @@ public:
   /* ***************** */
 private:
   // Cache the address of the variables we read directly in the memory of remote
-  void* maxpid_addr_;
-  void* actors_addr_;
-  void* dead_actors_addr_;
+  RemotePtr<unsigned long> maxpid_addr_;
+  RemotePtr<s_xbt_dynar_t> actors_addr_;
+  RemotePtr<s_xbt_dynar_t> dead_actors_addr_;
 
 public:
   std::vector<ActorInformation>& actors();
@@ -200,8 +200,7 @@ public:
       return nullptr;
   }
 
-  unsigned long get_maxpid() const;
-  void get_actor_vectors(RemotePtr<s_xbt_dynar_t>& actors, RemotePtr<s_xbt_dynar_t>& dead_actors);
+  unsigned long get_maxpid() const { return this->read(maxpid_addr_); }
 
   void dump_stack() const;
 
index ccecad9..4f506b5 100644 (file)
@@ -20,6 +20,7 @@
 #include "simgrid/forward.h" // aid_t
 #include <array>
 #include <cstdint>
+#include <xbt/dynar.h>
 #include <xbt/mmalloc.h>
 #include <xbt/utility.hpp>
 
@@ -61,9 +62,9 @@ struct s_mc_message_int_t {
 struct s_mc_message_initial_addresses_t {
   simgrid::mc::MessageType type;
   xbt_mheap_t mmalloc_default_mdp;
-  void* maxpid;
-  void* actors;
-  void* dead_actors;
+  unsigned long* maxpid;
+  xbt_dynar_t actors;
+  xbt_dynar_t dead_actors;
 };
 
 struct s_mc_message_ignore_heap_t {
index f3b5637..cf91c83 100644 (file)
@@ -39,7 +39,7 @@ namespace simgrid {
 namespace simix {
 config::Flag<bool> cfg_verbose_exit{"debug/verbose-exit", "Display the actor status at exit", true};
 
-void* simix_global_get_actors_addr()
+xbt_dynar_t simix_global_get_actors_addr()
 {
 #if SIMGRID_HAVE_MC
   return simix_global->actors_vector;
@@ -47,7 +47,7 @@ void* simix_global_get_actors_addr()
   xbt_die("This function is intended to be used when compiling with MC");
 #endif
 }
-void* simix_global_get_dead_actors_addr()
+xbt_dynar_t simix_global_get_dead_actors_addr()
 {
 #if SIMGRID_HAVE_MC
   return simix_global->dead_actors_vector;