Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / mc / Process.hpp
index 5f2ba9a..36ef994 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
 #include "src/xbt/mmalloc/mmprivate.h"
-#endif
+#include "src/mc/Channel.hpp"
 
 #include <simgrid/simix.h>
 #include "src/simix/popping_private.h"
@@ -85,6 +81,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:
@@ -137,6 +146,9 @@ public:
     return this->heap_info.data();
   }
 
+  Channel const& getChannel() const { return channel_; }
+  Channel& getChannel() { return channel_; }
+
   std::vector<IgnoredRegion> const& ignored_regions() const
   {
     return ignored_regions_;
@@ -160,25 +172,6 @@ public:
     running_ = false;
   }
 
-  template<class M>
-  typename std::enable_if< std::is_class<M>::value && std::is_trivial<M>::value, int >::type
-  send_message(M const& m)
-  {
-    return MC_protocol_send(this->socket_, &m, sizeof(M));
-  }
-
-  int send_message(e_mc_message_type message_id)
-  {
-    return MC_protocol_send_simple_message(this->socket_, message_id);
-  }
-
-  template<class M>
-  typename std::enable_if< std::is_class<M>::value && std::is_trivial<M>::value, ssize_t >::type
-  receive_message(M& m)
-  {
-    return MC_receive_message(this->socket_, &m, sizeof(M), 0);
-  }
-
   void reset_soft_dirty();
   void read_pagemap(uint64_t* pagemap, size_t start_page, size_t page_count);
 
@@ -216,17 +209,18 @@ public:
   void unignore_heap(void *address, size_t size);
 
   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;
-  int socket_ = -1;
+  Channel channel_;
   bool running_ = false;
   std::vector<simgrid::xbt::VmMap> memory_map_;
   RemotePtr<void> maestro_stack_start_, maestro_stack_end_;
@@ -302,12 +296,6 @@ public: // Libunwind-data
   void* unw_underlying_context;
 };
 
-// TODO, remove this
-#define MC_PROCESS_FOREACH(xs, cursor, p) \
-  if (! xs.empty()) \
-  for (auto __it = (cursor = 0, p = &*xs.begin(), xs.begin()); \
-    __it != xs.end(); ++__it, ++cursor, p = &*__it)
-
 /** Open a FD to a remote process memory (`/dev/$pid/mem`)
  */
 XBT_PRIVATE int open_vm(pid_t pid, int flags);