Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move the logic of Api::get_maxpid() to RemoteProcess where it belongs
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 14 Mar 2021 14:35:23 +0000 (15:35 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 14 Mar 2021 20:05:02 +0000 (21:05 +0100)
src/mc/api.cpp
src/mc/remote/RemoteProcess.cpp
src/mc/remote/RemoteProcess.hpp

index cb0d23e..d5ef4b6 100644 (file)
@@ -458,15 +458,7 @@ std::vector<simgrid::mc::ActorInformation>& Api::get_actors() const
 
 unsigned long Api::get_maxpid() const
 {
-  static const char* name = nullptr;
-  if (not name) {
-    name = "simgrid::kernel::actor::maxpid";
-    if (mc_model_checker->get_remote_process().find_variable(name) == nullptr)
-      name = "maxpid"; // We seem to miss the namespaces when compiling with GCC
-  }
-  unsigned long maxpid;
-  mc_model_checker->get_remote_process().read_variable(name, &maxpid, sizeof(maxpid));
-  return maxpid;
+  return mc_model_checker->get_remote_process().get_maxpid();
 }
 
 int Api::get_actors_size() const
index 41cacdc..dd80f7e 100644 (file)
@@ -569,5 +569,19 @@ void RemoteProcess::dump_stack() const
   _UPT_destroy(context);
   unw_destroy_addr_space(as);
 }
+
+unsigned long RemoteProcess::get_maxpid() const
+{
+  static const char* name = nullptr;
+  if (not name) {
+    name = "simgrid::kernel::actor::maxpid";
+    if (find_variable(name) == nullptr)
+      name = "maxpid"; // We seem to miss the namespaces when compiling with GCC
+  }
+  unsigned long maxpid;
+  read_variable(name, &maxpid, sizeof(maxpid));
+  return maxpid;
+}
+
 } // namespace mc
 } // namespace simgrid
index 3e35f7f..78bb6b7 100644 (file)
@@ -82,6 +82,10 @@ public:
   RemoteProcess& operator=(RemoteProcess const&) = delete;
   RemoteProcess& operator=(RemoteProcess&&) = delete;
 
+  /* ************* */
+  /* Low-level API */
+  /* ************* */
+
   // Read memory:
   void* read_bytes(void* buffer, std::size_t size, RemotePtr<void> address,
                    ReadOptions options = ReadOptions::none()) const override;
@@ -156,6 +160,11 @@ public:
   void unignore_heap(void* address, size_t size);
 
   void ignore_local_variable(const char* var_name, const char* frame_name) const;
+
+  /* ***************** */
+  /* SIMIX-related API */
+  /* ***************** */
+
   std::vector<ActorInformation>& actors();
   std::vector<ActorInformation>& dead_actors();
 
@@ -185,6 +194,8 @@ public:
       return nullptr;
   }
 
+  unsigned long get_maxpid() const;
+
   void dump_stack() const;
 
 private: