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 62fad58..a2cef85 100644 (file)
@@ -22,7 +22,7 @@
 #include <xbt/dynar.h>
 #include <xbt/mmalloc.h>
 
-#ifdef HAVE_MC
+#if HAVE_MC
 #include "src/xbt/mmalloc/mmprivate.h"
 #endif
 
@@ -49,6 +49,26 @@ typedef int mc_process_cache_flags_t;
 namespace simgrid {
 namespace mc {
 
+class SimixProcessInformation {
+public:
+  /** MCed address of the process */
+  void* address = nullptr;
+  union {
+    /** (Flat) Copy of the process data structure */
+    struct s_smx_process copy;
+  };
+  /** Hostname (owned by `mc_modelchecker->hostnames`) */
+  const char* hostname = nullptr;
+  std::string name;
+
+  void clear()
+  {
+    name.clear();
+    address = nullptr;
+    hostname = nullptr;
+  }
+};
+
 struct IgnoredRegion {
   std::uint64_t addr;
   std::size_t size;
@@ -62,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:
@@ -194,11 +227,14 @@ public:
 
   void ignore_local_variable(const char *var_name, const char *frame_name);
   int socket() { return socket_; }
+  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;
@@ -225,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;