]> AND Public Git Repository - simgrid.git/blobdiff - src/mc/remote/RemoteProcess.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / src / mc / remote / RemoteProcess.cpp
index ac1e9b2bb3170c5f94feb93999fd3985bde2f4b2..ad816fc361201280173bc68b6abf87f22cf4b6a2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2023. 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. */
@@ -145,8 +145,6 @@ RemoteProcess::~RemoteProcess()
 void RemoteProcess::refresh_heap()
 {
   // Read/dereference/refresh the std_heap pointer:
-  if (not this->heap)
-    this->heap = std::make_unique<s_xbt_mheap_t>();
   this->read(this->heap.get(), this->heap_address);
   this->cache_flags_ |= RemoteProcess::cache_heap;
 }
@@ -167,6 +165,10 @@ void RemoteProcess::refresh_malloc_info()
   this->read_bytes(this->heap_info.data(), count * sizeof(malloc_info), remote(this->heap->heapinfo));
   this->cache_flags_ |= RemoteProcess::cache_malloc;
 }
+std::size_t RemoteProcess::get_remote_heap_bytes()
+{
+  return mmalloc_get_bytes_used_remote(get_heap()->heaplimit, get_malloc_info());
+}
 
 /** @brief Finds the range of the different memory segments and binary paths */
 void RemoteProcess::init_memory_map_info()
@@ -315,7 +317,7 @@ std::string RemoteProcess::read_string(RemotePtr<char> address) const
     xbt_assert(c > 0, "Could not read string from remote process");
 
     if (memchr(res.data() + off, '\0', c))
-      return std::string(res.data());
+      return res.data();
 
     off += c;
     if (off == (off_t)res.size())