Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Mark some Process attributes as private
[simgrid.git] / src / mc / mc_process.h
index c21e951..5879580 100644 (file)
@@ -10,6 +10,8 @@
 #include <stdbool.h>
 #include <sys/types.h>
 
+#include <vector>
+
 #include "simgrid_config.h"
 #include <sys/types.h>
 
@@ -47,6 +49,11 @@ typedef struct s_mc_smx_process_info s_mc_smx_process_info_t, *mc_smx_process_in
 namespace simgrid {
 namespace mc {
 
+struct IgnoredRegion {
+  std::uint64_t addr;
+  size_t size;
+};
+
 /** Representation of a process
  */
 class Process : public AddressSpace {
@@ -62,8 +69,16 @@ public:
   // Read memory:
   const void* read_bytes(void* buffer, std::size_t size,
     remote_ptr<void> address, int process_index = ProcessIndexAny,
-    ReadMode mode = Normal) const override;
+    ReadMode mode = Normal) const MC_OVERRIDE;
   void read_variable(const char* name, void* target, size_t size) const;
+  template<class T>
+  T read_variable(const char *name) const
+  {
+    static_assert(std::is_trivial<T>::value, "Cannot read a non-trivial type");
+    T res;
+    read_variable(name, &res, sizeof(T));
+    return res;
+  }
   char* read_string(remote_ptr<void> address) const;
 
   // Write memory:
@@ -91,24 +106,60 @@ public:
     return this->heap_info;
   }
 
+  std::vector<IgnoredRegion> const& ignored_regions() const
+  {
+    return ignored_regions_;
+  }
+  void ignore_region(std::uint64_t address, std::size_t size);
+
+  pid_t pid() const { return pid_; }
+
+  bool in_maestro_stack(remote_ptr<void> p) const
+  {
+    return p >= this->maestro_stack_start_ && p < this->maestro_stack_end_;
+  }
+
+  bool running() const
+  {
+    return running_;
+  }
+
+  void terminate(int status)
+  {
+    status_ = status;
+    running_ = false;
+  }
+
+  int status() const
+  {
+    return status_;
+  }
+
 private:
   void init_memory_map_info();
   void refresh_heap();
   void refresh_malloc_info();
-public: // to be private
+private:
   mc_process_flags_t process_flags;
-  pid_t pid;
+  pid_t pid_;
+public: // to be private
   int socket;
-  int status;
-  bool running;
+private:
+  int status_;
+  bool running_;
   memory_map_t memory_map;
-  void *maestro_stack_start, *maestro_stack_end;
+  remote_ptr<void> maestro_stack_start_, maestro_stack_end_;
+  int memory_file;
+  std::vector<IgnoredRegion> ignored_regions_;
+
+public: // object info
+  // TODO, make private (first, objectify mc_object_info_t)
   mc_object_info_t libsimgrid_info;
   mc_object_info_t binary_info;
   mc_object_info_t* object_infos;
   size_t object_infos_size;
-  int memory_file;
 
+public: // Copies of MCed SMX data structures
   /** Copy of `simix_global->process_list`
    *
    *  See mc_smx.c.
@@ -143,7 +194,7 @@ public: // to be private
    */
   malloc_info* heap_info;
 
-  // ***** Libunwind-data
+public: // Libunwind-data
 
   /** Full-featured MC-aware libunwind address space for the process
    *
@@ -163,8 +214,6 @@ public: // to be private
   /** The corresponding context
    */
   void* unw_underlying_context;
-
-  xbt_dynar_t checkpoint_ignore;
 };
 
 /** Open a FD to a remote process memory (`/dev/$pid/mem`)
@@ -176,11 +225,6 @@ int open_vm(pid_t pid, int flags);
 
 SG_BEGIN_DECL()
 
-XBT_INTERNAL const void* MC_process_read_dynar_element(mc_process_t process,
-  void* local, const void* remote_dynar, size_t i, size_t len);
-XBT_INTERNAL unsigned long MC_process_read_dynar_length(mc_process_t process,
-  const void* remote_dynar);
-
 XBT_INTERNAL void MC_invalidate_cache(void);
 
 SG_END_DECL()