X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ef1af4e53dff6d26dcfabafed5e78b461866071f..5010356b3ded0a463dae327544f6898d57c1e275:/src/mc/remote/RemoteProcess.cpp diff --git a/src/mc/remote/RemoteProcess.cpp b/src/mc/remote/RemoteProcess.cpp index 4411375eef..ad816fc361 100644 --- a/src/mc/remote/RemoteProcess.cpp +++ b/src/mc/remote/RemoteProcess.cpp @@ -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. */ @@ -105,11 +105,10 @@ int open_vm(pid_t pid, int flags) RemoteProcess::RemoteProcess(pid_t pid) : AddressSpace(this), pid_(pid), running_(true) {} -void RemoteProcess::init(xbt_mheap_t mmalloc_default_mdp, unsigned long* maxpid, xbt_dynar_t actors) +void RemoteProcess::init(xbt_mheap_t mmalloc_default_mdp, unsigned long* maxpid) { this->heap_address = remote(mmalloc_default_mdp); this->maxpid_addr_ = remote(maxpid); - this->actors_addr_ = remote(actors); this->memory_map_ = simgrid::xbt::get_memory_map(this->pid_); this->init_memory_map_info(); @@ -118,7 +117,6 @@ void RemoteProcess::init(xbt_mheap_t mmalloc_default_mdp, unsigned long* maxpid, xbt_assert(fd >= 0, "Could not open file for process virtual address space"); this->memory_file = fd; - this->smx_actors_infos.clear(); this->unw_addr_space = simgrid::mc::UnwindContext::createUnwindAddressSpace(); this->unw_underlying_addr_space = simgrid::unw::create_addr_space(); this->unw_underlying_context = simgrid::unw::create_context(this->unw_underlying_addr_space, this->pid_); @@ -147,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(); this->read(this->heap.get(), this->heap_address); this->cache_flags_ |= RemoteProcess::cache_heap; } @@ -169,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() @@ -317,7 +317,7 @@ std::string RemoteProcess::read_string(RemotePtr 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()) @@ -410,40 +410,6 @@ void RemoteProcess::ignore_local_variable(const char* var_name, const char* fram info->remove_local_variable(var_name, frame_name); } -/** Load the remote list of actors into the Checker process - * - * FIXME: This shall die alltogether and be reimplemented with a networked communication to not suppose anything about - * the memory layout of the checked App if avoidable. - * - * Liveness checking will always require to explore the memory of the App, but safety checking doesn't. - */ - -std::vector& RemoteProcess::actors() -{ - if (not(this->cache_flags_ & RemoteProcess::cache_simix_processes)) { - smx_actors_infos.clear(); - - s_xbt_dynar_t dynar; - read_bytes(&dynar, sizeof(dynar), actors_addr_); - - auto* data = static_cast(::operator new(dynar.elmsize* dynar.used)); - read_bytes(data, dynar.elmsize * dynar.used, simgrid::mc::RemotePtr(dynar.data)); - - // Load each element of the vector from the MCed process: - for (unsigned int i = 0; i < dynar.used; ++i) { - simgrid::mc::ActorInformation info; - - info.address = simgrid::mc::RemotePtr(data[i]); - read_bytes(&info.copy, sizeof(info.copy), simgrid::mc::remote(data[i])); - smx_actors_infos.push_back(std::move(info)); - } - ::operator delete(data); - - this->cache_flags_ |= RemoteProcess::cache_simix_processes; - } - return smx_actors_infos; -} - void RemoteProcess::dump_stack() const { unw_addr_space_t as = unw_create_addr_space(&_UPT_accessors, BYTE_ORDER);