Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Private Process::pid
[simgrid.git] / src / mc / mc_process.cpp
index 66bb067..0b4a9ba 100644 (file)
@@ -191,7 +191,7 @@ Process::Process(pid_t pid, int sockfd)
 
   process->process_flags = MC_PROCESS_NO_FLAG;
   process->socket = sockfd;
-  process->pid = pid;
+  process->pid_ = pid;
   if (pid==getpid())
     process->process_flags |= MC_PROCESS_SELF_FLAG;
   process->running = true;
@@ -206,7 +206,7 @@ Process::Process(pid_t pid, int sockfd)
   if (process->is_self())
     process->memory_file = -1;
   else {
-    int fd = open_vm(process->pid, O_RDWR);
+    int fd = open_vm(process->pid_, O_RDWR);
     if (fd<0)
       xbt_die("Could not open file for process virtual address space");
     process->memory_file = fd;
@@ -225,8 +225,6 @@ Process::Process(pid_t pid, int sockfd)
   process->smx_process_infos = MC_smx_process_info_list_new();
   process->smx_old_process_infos = MC_smx_process_info_list_new();
 
-  process->checkpoint_ignore = MC_checkpoint_ignore_new();
-
   process->unw_addr_space = unw_create_addr_space(&mc_unw_accessors  , __BYTE_ORDER);
   if (process->process_flags & MC_PROCESS_SELF_FLAG) {
     process->unw_underlying_addr_space = unw_local_addr_space;
@@ -242,7 +240,7 @@ Process::~Process()
   Process* process = this;
 
   process->process_flags = MC_PROCESS_NO_FLAG;
-  process->pid = 0;
+  process->pid_ = 0;
 
   MC_free_memory_map(process->memory_map);
   process->memory_map = NULL;
@@ -250,8 +248,6 @@ Process::~Process()
   process->maestro_stack_start = NULL;
   process->maestro_stack_end = NULL;
 
-  xbt_dynar_free(&process->checkpoint_ignore);
-
   xbt_dynar_free(&process->smx_process_infos);
   xbt_dynar_free(&process->smx_old_process_infos);
 
@@ -554,7 +550,7 @@ const void *Process::read_bytes(void* buffer, std::size_t size,
     }
   } else {
     if (pread_whole(this->memory_file, buffer, size, (off_t) address.address()) < 0)
-      xbt_die("Read from process %lli failed", (long long) this->pid);
+      xbt_die("Read from process %lli failed", (long long) this->pid_);
     return buffer;
   }
 }
@@ -572,7 +568,7 @@ void Process::write_bytes(const void* buffer, size_t len, remote_ptr<void> addre
     memcpy((void*)address.address(), buffer, len);
   } else {
     if (pwrite_whole(this->memory_file, buffer, len, address.address()) < 0)
-      xbt_die("Write to process %lli failed", (long long) this->pid);
+      xbt_die("Write to process %lli failed", (long long) this->pid_);
   }
 }
 
@@ -591,5 +587,53 @@ void Process::clear_bytes(remote_ptr<void> address, size_t len)
   }
 }
 
+void Process::ignore_region(std::uint64_t addr, std::size_t size)
+{
+  IgnoredRegion region;
+  region.addr = addr;
+  region.size = size;
+
+  if (ignored_regions_.empty()) {
+    ignored_regions_.push_back(region);
+    return;
+  }
+
+  unsigned int cursor = 0;
+  IgnoredRegion* current_region = nullptr;
+
+  int start = 0;
+  int end = ignored_regions_.size() - 1;
+  while (start <= end) {
+    cursor = (start + end) / 2;
+    current_region = &ignored_regions_[cursor];
+    if (current_region->addr == addr) {
+      if (current_region->size == size)
+        return;
+      else if (current_region->size < size)
+        start = cursor + 1;
+      else
+        end = cursor - 1;
+    } else if (current_region->addr < addr)
+      start = cursor + 1;
+    else
+      end = cursor - 1;
+  }
+
+  std::size_t position;
+  if (current_region->addr == addr) {
+    if (current_region->size < size) {
+      position = cursor + 1;
+    } else {
+      position = cursor;
+    }
+  } else if (current_region->addr < addr) {
+    position = cursor + 1;
+  } else {
+    position = cursor;
+  }
+  ignored_regions_.insert(
+    ignored_regions_.begin() + position, region);
+}
+
 }
 }