From: Martin Quinson Date: Sat, 6 Aug 2022 23:05:56 +0000 (+0200) Subject: Move mc:api::get_remote_heap_bytes() to RemoteProcess X-Git-Tag: v3.32~86 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/77385a2b4bc1518d701cbf33acc04d16ae3b640b Move mc:api::get_remote_heap_bytes() to RemoteProcess --- diff --git a/src/mc/VisitedState.cpp b/src/mc/VisitedState.cpp index 790d90afb2..7c81cc7632 100644 --- a/src/mc/VisitedState.cpp +++ b/src/mc/VisitedState.cpp @@ -20,7 +20,7 @@ namespace simgrid::mc { VisitedState::VisitedState(unsigned long state_number, unsigned int actor_count) : actor_count_(actor_count), num(state_number) { - this->heap_bytes_used = Api::get().get_remote_heap_bytes(); + this->heap_bytes_used = mc_model_checker->get_remote_process().get_remote_heap_bytes(); this->system_state = std::make_shared(state_number); } diff --git a/src/mc/api.cpp b/src/mc/api.cpp deleted file mode 100644 index d866d445e1..0000000000 --- a/src/mc/api.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2020-2022. 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. */ - -#include "api.hpp" - -#include "src/kernel/activity/MailboxImpl.hpp" -#include "src/kernel/activity/MutexImpl.hpp" -#include "src/kernel/actor/SimcallObserver.hpp" -#include "src/mc/api/RemoteApp.hpp" -#include "src/mc/explo/Exploration.hpp" -#include "src/mc/mc_base.hpp" -#include "src/mc/mc_exit.hpp" -#include "src/mc/mc_private.hpp" -#include "src/mc/remote/RemoteProcess.hpp" -#include "src/surf/HostImpl.hpp" - -#include -#include -#include "simgrid/s4u/Host.hpp" -#include "xbt/string.hpp" -#if HAVE_SMPI -#include "src/smpi/include/smpi_request.hpp" -#endif - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(Api, mc, "Logging specific to MC Facade APIs "); -XBT_LOG_EXTERNAL_CATEGORY(mc_global); - -namespace simgrid::mc { - -std::size_t Api::get_remote_heap_bytes() const -{ - RemoteProcess& process = mc_model_checker->get_remote_process(); - auto heap_bytes_used = mmalloc_get_bytes_used_remote(process.get_heap()->heaplimit, process.get_malloc_info()); - return heap_bytes_used; -} -} // namespace simgrid::mc diff --git a/src/mc/api.hpp b/src/mc/api.hpp index b5422c2469..9a47ed89bf 100644 --- a/src/mc/api.hpp +++ b/src/mc/api.hpp @@ -19,8 +19,6 @@ namespace simgrid::mc { -XBT_DECLARE_ENUM_CLASS(ExplorationAlgorithm, Safety, UDPOR, Liveness, CommDeterminism); - /* ** This class aimes to implement FACADE APIs for simgrid. The FACADE layer sits between the CheckerSide ** (Unfolding_Checker, DPOR, ...) layer and the @@ -41,19 +39,12 @@ private: }; public: - // No copy: - Api(Api const&) = delete; - void operator=(Api const&) = delete; - static Api& get() { static Api api; return api; } - // REMOTE APIs - std::size_t get_remote_heap_bytes() const; - // AUTOMATION APIs inline DerefAndCompareByActorsCountAndUsedHeap compare_pair() const { diff --git a/src/mc/explo/LivenessChecker.cpp b/src/mc/explo/LivenessChecker.cpp index fac533429a..8730db9e79 100644 --- a/src/mc/explo/LivenessChecker.cpp +++ b/src/mc/explo/LivenessChecker.cpp @@ -25,7 +25,7 @@ VisitedPair::VisitedPair(int pair_num, xbt_automaton_state_t prop_state, this->app_state_ = std::move(app_state); if (not this->app_state_->get_system_state()) this->app_state_->set_system_state(std::make_shared(pair_num)); - this->heap_bytes_used = Api::get().get_remote_heap_bytes(); + this->heap_bytes_used = mc_model_checker->get_remote_process().get_remote_heap_bytes(); this->actor_count_ = app_state_->get_actor_count(); this->other_num = -1; this->atomic_propositions = std::move(atomic_propositions); diff --git a/src/mc/remote/RemoteProcess.cpp b/src/mc/remote/RemoteProcess.cpp index ac1e9b2bb3..324e5edaa1 100644 --- a/src/mc/remote/RemoteProcess.cpp +++ b/src/mc/remote/RemoteProcess.cpp @@ -167,6 +167,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() diff --git a/src/mc/remote/RemoteProcess.hpp b/src/mc/remote/RemoteProcess.hpp index b2c7558133..c2244f35a2 100644 --- a/src/mc/remote/RemoteProcess.hpp +++ b/src/mc/remote/RemoteProcess.hpp @@ -125,6 +125,8 @@ public: this->refresh_malloc_info(); return this->heap_info.data(); } + /* Get the amount of memory mallocated in the remote process (requires mmalloc) */ + std::size_t get_remote_heap_bytes(); void clear_cache() { this->cache_flags_ = RemoteProcess::cache_none; } diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index f1b2fa5934..28adc9a2de 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -637,7 +637,6 @@ set(MC_SRC src/mc/ModelChecker.hpp src/mc/VisitedState.cpp src/mc/VisitedState.hpp - src/mc/api.cpp src/mc/api.hpp src/mc/api/ActorState.hpp src/mc/api/State.cpp