Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove useless declaration of default destructor.
[simgrid.git] / src / mc / remote / RemoteSimulation.cpp
index 385bd6c..f2a3430 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -7,7 +7,6 @@
 
 #include "src/mc/remote/RemoteSimulation.hpp"
 
-#include "src/mc/mc_smx.hpp"
 #include "src/mc/sosp/Snapshot.hpp"
 #include "xbt/file.hpp"
 #include "xbt/log.h"
@@ -16,7 +15,9 @@
 #include <libunwind-ptrace.h>
 #include <sys/mman.h> // PROT_*
 
+#include <algorithm>
 #include <memory>
+#include <string>
 
 using simgrid::mc::remote;
 
@@ -41,6 +42,7 @@ static const std::vector<std::string> filtered_libraries = {
 #endif
     "libargp", /* workarounds for glibc-less systems */
     "libasan", /* gcc sanitizers */
+    "libasn1",
     "libboost_chrono",
     "libboost_context",
     "libboost_context-mt",
@@ -77,7 +79,12 @@ static const std::vector<std::string> filtered_libraries = {
     "libgcrypt",
     "libgfortran",
     "libgpg-error",
+    "libgssapi",
     "libgssapi_krb5",
+    "libhcrypto",
+    "libheimbase",
+    "libheimntlm",
+    "libhx509",
     "libhogweed",
     "libidn2",
     "libimf",
@@ -107,10 +114,12 @@ static const std::vector<std::string> filtered_libraries = {
     "libpthread",
     "libquadmath",
     "libresolv",
+    "libroken",
     "librt",
     "librtmp",
     "libsasl2",
     "libselinux",
+    "libsqlite3",
     "libssh",
     "libssh2",
     "libssl",
@@ -124,14 +133,10 @@ static const std::vector<std::string> filtered_libraries = {
     "libunwind-ptrace",
     "libunwind-x86",
     "libunwind-x86_64",
+    "libwind",
     "libz",
     "libzstd"};
 
-static bool is_simgrid_lib(const std::string& libname)
-{
-  return libname == "libsimgrid";
-}
-
 static bool is_filtered_lib(const std::string& libname)
 {
   return std::find(begin(filtered_libraries), end(filtered_libraries), libname) != end(filtered_libraries);
@@ -214,14 +219,8 @@ static void zero_buffer_init()
 
 int open_vm(pid_t pid, int flags)
 {
-  const size_t buffer_size = 30;
-  char buffer[buffer_size];
-  int res = snprintf(buffer, buffer_size, "/proc/%lli/mem", (long long)pid);
-  if (res < 0 || (size_t)res >= buffer_size) {
-    errno = ENAMETOOLONG;
-    return -1;
-  }
-  return open(buffer, flags);
+  std::string buffer = "/proc/" + std::to_string(pid) + "/mem";
+  return open(buffer.c_str(), flags);
 }
 
 // ***** RemoteSimulation
@@ -304,7 +303,6 @@ void RemoteSimulation::init_memory_map_info()
   this->maestro_stack_end_   = nullptr;
   this->object_infos.resize(0);
   this->binary_info     = nullptr;
-  this->libsimgrid_info = nullptr;
 
   std::vector<simgrid::xbt::VmMap> const& maps = this->memory_map_;
 
@@ -353,8 +351,6 @@ void RemoteSimulation::init_memory_map_info()
     this->object_infos.push_back(info);
     if (is_executable)
       this->binary_info = info;
-    else if (is_simgrid_lib(libname))
-      this->libsimgrid_info = info;
   }
 
   // Resolve time (including across different objects):
@@ -493,102 +489,32 @@ void RemoteSimulation::ignore_region(std::uint64_t addr, std::size_t size)
   region.addr = addr;
   region.size = size;
 
-  if (ignored_regions_.empty()) {
-    ignored_regions_.push_back(region);
-    return;
-  }
-
-  unsigned int cursor                 = 0;
-  const 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);
+  auto pos = std::lower_bound(ignored_regions_.begin(), ignored_regions_.end(), region,
+                              [](auto const& reg1, auto const& reg2) {
+                                return reg1.addr < reg2.addr || (reg1.addr == reg2.addr && reg1.size < reg2.size);
+                              });
+  if (pos == ignored_regions_.end() || pos->addr != addr || pos->size != size)
+    ignored_regions_.insert(pos, region);
 }
 
 void RemoteSimulation::ignore_heap(IgnoredHeapRegion const& region)
 {
-  if (ignored_heap_.empty()) {
-    ignored_heap_.push_back(std::move(region));
-    return;
-  }
-
-  typedef std::vector<IgnoredHeapRegion>::size_type size_type;
-
-  size_type start = 0;
-  size_type end   = ignored_heap_.size() - 1;
-
   // Binary search the position of insertion:
-  size_type cursor;
-  while (start <= end) {
-    cursor                     = start + (end - start) / 2;
-    auto const& current_region = ignored_heap_[cursor];
-    if (current_region.address == region.address)
-      return;
-    else if (current_region.address < region.address)
-      start = cursor + 1;
-    else if (cursor != 0)
-      end = cursor - 1;
-    // Avoid underflow:
-    else
-      break;
+  auto pos = std::lower_bound(ignored_heap_.begin(), ignored_heap_.end(), region.address,
+                              [](auto const& reg, auto const* addr) { return reg.address < addr; });
+  if (pos == ignored_heap_.end() || pos->address != region.address) {
+    // Insert it:
+    ignored_heap_.insert(pos, region);
   }
-
-  // Insert it mc_heap_ignore_region_t:
-  if (ignored_heap_[cursor].address < region.address)
-    ++cursor;
-  ignored_heap_.insert(ignored_heap_.begin() + cursor, region);
 }
 
 void RemoteSimulation::unignore_heap(void* address, size_t size)
 {
-  typedef std::vector<IgnoredHeapRegion>::size_type size_type;
-
-  size_type start = 0;
-  size_type end   = ignored_heap_.size() - 1;
-
   // Binary search:
-  size_type cursor;
-  while (start <= end) {
-    cursor             = (start + end) / 2;
-    auto const& region = ignored_heap_[cursor];
-    if (region.address < address)
-      start = cursor + 1;
-    else if ((char*)region.address <= ((char*)address + size)) {
-      ignored_heap_.erase(ignored_heap_.begin() + cursor);
-      return;
-    } else if (cursor != 0)
-      end = cursor - 1;
-    // Avoid underflow:
-    else
-      break;
-  }
+  auto pos = std::lower_bound(ignored_heap_.begin(), ignored_heap_.end(), address,
+                              [](auto const& reg, auto const* addr) { return reg.address < addr; });
+  if (pos != ignored_heap_.end() && static_cast<char*>(pos->address) <= static_cast<char*>(address) + size)
+    ignored_heap_.erase(pos);
 }
 
 void RemoteSimulation::ignore_local_variable(const char* var_name, const char* frame_name) const