Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move some SIMIX inspection code in the Process class
[simgrid.git] / src / mc / Process.hpp
index 7c4c983..a2cef85 100644 (file)
 #include <vector>
 #include <memory>
 
-#include <boost/range/iterator_range.hpp>
-
 #include <sys/types.h>
 
 #include <simgrid_config.h>
 
 #include <xbt/base.h>
 #include <xbt/dynar.h>
-#include <xbt/dynar.hpp>
 #include <xbt/mmalloc.h>
 
-#ifdef HAVE_MC
+#if HAVE_MC
 #include "src/xbt/mmalloc/mmprivate.h"
 #endif
 
@@ -62,7 +59,14 @@ public:
   };
   /** Hostname (owned by `mc_modelchecker->hostnames`) */
   const char* hostname = nullptr;
-  char* name = nullptr;
+  std::string name;
+
+  void clear()
+  {
+    name.clear();
+    address = nullptr;
+    hostname = nullptr;
+  }
 };
 
 struct IgnoredRegion {
@@ -78,6 +82,19 @@ struct IgnoredHeapRegion {
 };
 
 /** Representation of a process
+ *
+ *  This class is mixing a lot of differents responsabilities and is tied
+ *  to SIMIX. It should probably split into different classes.
+ *
+ *  Responsabilities:
+ *
+ *  - reading from the process memory (`AddressSpace`);
+ *  - accessing the system state of the porcess (heap, …);
+ *  - storing the SIMIX state of the process;
+ *  - privatization;
+ *  - communication with the model-checked process;
+ *  - stack unwinding;
+ *  - etc.
  */
 class Process final : public AddressSpace {
 public:
@@ -210,12 +227,14 @@ public:
 
   void ignore_local_variable(const char *var_name, const char *frame_name);
   int socket() { return socket_; }
-  simgrid::xbt::DynarRange<s_mc_smx_process_info> simix_processes();
+  std::vector<simgrid::mc::SimixProcessInformation>& simix_processes();
+  std::vector<simgrid::mc::SimixProcessInformation>& old_simix_processes();
 
 private:
   void init_memory_map_info();
   void refresh_heap();
   void refresh_malloc_info();
+  void refresh_simix();
 
 private:
   pid_t pid_ = -1;
@@ -242,13 +261,13 @@ public: // Copies of MCed SMX data structures
    *
    *  See mc_smx.c.
    */
-  xbt_dynar_t smx_process_infos = nullptr;
+  std::vector<SimixProcessInformation> smx_process_infos;
 
   /** Copy of `simix_global->process_to_destroy`
    *
    *  See mc_smx.c.
    */
-  xbt_dynar_t smx_old_process_infos = nullptr;
+  std::vector<SimixProcessInformation> smx_old_process_infos;
 
   /** State of the cache (which variables are up to date) */
   mc_process_cache_flags_t cache_flags = MC_PROCESS_CACHE_FLAG_NONE;