From: Martin Quinson Date: Sun, 16 Jul 2017 16:00:35 +0000 (+0200) Subject: MC: rename process into RemoteClient X-Git-Tag: v3_17~390 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/35d84011da1f114490d6eb4d77e214edf56c810f MC: rename process into RemoteClient This is a proxy to the Client (ie the MCed), as seen from the server (ie, the MCer) --- diff --git a/src/mc/AddressSpace.hpp b/src/mc/AddressSpace.hpp index c4985e286f..758d12ce6c 100644 --- a/src/mc/AddressSpace.hpp +++ b/src/mc/AddressSpace.hpp @@ -109,16 +109,17 @@ public: */ class AddressSpace { private: - Process* process_; + RemoteClient* process_; + public: - explicit AddressSpace(Process* process) : process_(process) {} + explicit AddressSpace(RemoteClient* process) : process_(process) {} virtual ~AddressSpace() = default; - /** The process of this addres space + /** The process of this address space * * This is where we can get debug informations, memory layout, etc. */ - simgrid::mc::Process* process() const { return process_; } + simgrid::mc::RemoteClient* process() const { return process_; } /** Read data from the address space * diff --git a/src/mc/ModelChecker.cpp b/src/mc/ModelChecker.cpp index fcc85efd39..339d6377a5 100644 --- a/src/mc/ModelChecker.cpp +++ b/src/mc/ModelChecker.cpp @@ -46,13 +46,13 @@ using simgrid::mc::remote; namespace simgrid { namespace mc { -ModelChecker::ModelChecker(std::unique_ptr process) : - base_(nullptr), - socket_event_(nullptr), - signal_event_(nullptr), - page_store_(500), - process_(std::move(process)), - parent_snapshot_(nullptr) +ModelChecker::ModelChecker(std::unique_ptr process) + : base_(nullptr) + , socket_event_(nullptr) + , signal_event_(nullptr) + , page_store_(500) + , process_(std::move(process)) + , parent_snapshot_(nullptr) { } @@ -131,7 +131,7 @@ static const std::pair ignored_local_variables[] = { void ModelChecker::setup_ignore() { - Process& process = this->process(); + RemoteClient& process = this->process(); for (std::pair const& var : ignored_local_variables) process.ignore_local_variable(var.first, var.second); @@ -144,7 +144,7 @@ void ModelChecker::shutdown() { XBT_DEBUG("Shuting down model-checker"); - simgrid::mc::Process* process = &this->process(); + simgrid::mc::RemoteClient* process = &this->process(); if (process->running()) { XBT_DEBUG("Killing process"); kill(process->pid(), SIGTERM); @@ -152,7 +152,7 @@ void ModelChecker::shutdown() } } -void ModelChecker::resume(simgrid::mc::Process& process) +void ModelChecker::resume(simgrid::mc::RemoteClient& process) { int res = process.getChannel().send(MC_MESSAGE_CONTINUE); if (res) @@ -262,7 +262,7 @@ bool ModelChecker::handle_message(char* buffer, ssize_t size) if (simgrid::mc::property_automaton == nullptr) simgrid::mc::property_automaton = xbt_automaton_new(); - simgrid::mc::Process* process = &this->process(); + simgrid::mc::RemoteClient* process = &this->process(); simgrid::mc::RemotePtr address = simgrid::mc::remote((int*) message.data); simgrid::xbt::add_proposition(simgrid::mc::property_automaton, @@ -387,7 +387,7 @@ void ModelChecker::on_signal(int signo) } } -void ModelChecker::wait_client(simgrid::mc::Process& process) +void ModelChecker::wait_client(simgrid::mc::RemoteClient& process) { this->resume(process); if (this->process().running()) diff --git a/src/mc/ModelChecker.hpp b/src/mc/ModelChecker.hpp index c238d12c20..95543458ec 100644 --- a/src/mc/ModelChecker.hpp +++ b/src/mc/ModelChecker.hpp @@ -19,9 +19,9 @@ #include #include "src/mc/PageStore.hpp" -#include "src/mc/Process.hpp" #include "src/mc/Transition.hpp" #include "src/mc/mc_forward.hpp" +#include "src/mc/remote/RemoteClient.hpp" #include "src/mc/remote/mc_protocol.h" namespace simgrid { @@ -38,7 +38,7 @@ class ModelChecker { std::set hostnames_; // This is the parent snapshot of the current state: PageStore page_store_; - std::unique_ptr process_; + std::unique_ptr process_; Checker* checker_ = nullptr; public: std::shared_ptr parent_snapshot_; @@ -46,13 +46,10 @@ public: public: ModelChecker(ModelChecker const&) = delete; ModelChecker& operator=(ModelChecker const&) = delete; - explicit ModelChecker(std::unique_ptr process); + explicit ModelChecker(std::unique_ptr process); ~ModelChecker(); - Process& process() - { - return *process_; - } + RemoteClient& process() { return *process_; } PageStore& page_store() { return page_store_; @@ -69,10 +66,10 @@ public: void start(); void shutdown(); - void resume(simgrid::mc::Process& process); + void resume(simgrid::mc::RemoteClient& process); void loop(); void handle_events(int fd, short events); - void wait_client(simgrid::mc::Process& process); + void wait_client(simgrid::mc::RemoteClient& process); void handle_simcall(Transition const& transition); void wait_for_requests() { diff --git a/src/mc/ObjectInformation.hpp b/src/mc/ObjectInformation.hpp index bfebc40bbf..21ed47157a 100644 --- a/src/mc/ObjectInformation.hpp +++ b/src/mc/ObjectInformation.hpp @@ -165,9 +165,7 @@ XBT_PRIVATE std::shared_ptr createObjectInformation( std::vector const& maps, const char* name); /** Augment the current module with informations about the other ones */ -XBT_PRIVATE void postProcessObjectInformation( - simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info); - +XBT_PRIVATE void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info); } } diff --git a/src/mc/RegionSnapshot.cpp b/src/mc/RegionSnapshot.cpp index 3fbfe3e54e..104e8ffc46 100644 --- a/src/mc/RegionSnapshot.cpp +++ b/src/mc/RegionSnapshot.cpp @@ -128,7 +128,7 @@ RegionSnapshot region( RegionSnapshot sparse_region(RegionType region_type, void *start_addr, void* permanent_addr, size_t size) { - simgrid::mc::Process* process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* process = &mc_model_checker->process(); assert(process != nullptr); xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize-1)) == 0, diff --git a/src/mc/Session.cpp b/src/mc/Session.cpp index 7dc4a66399..84a2105e51 100644 --- a/src/mc/Session.cpp +++ b/src/mc/Session.cpp @@ -85,7 +85,7 @@ pid_t do_fork(F code) Session::Session(pid_t pid, int socket) { - std::unique_ptr process(new simgrid::mc::Process(pid, socket)); + std::unique_ptr process(new simgrid::mc::RemoteClient(pid, socket)); // TODO, automatic detection of the config from the process process->privatized(smpi_privatize_global_variables != SMPI_PRIVATIZE_NONE); modelChecker_ = std::unique_ptr( diff --git a/src/mc/VisitedState.cpp b/src/mc/VisitedState.cpp index a59df31fa7..017e9f204b 100644 --- a/src/mc/VisitedState.cpp +++ b/src/mc/VisitedState.cpp @@ -13,11 +13,11 @@ #include "xbt/log.h" #include "xbt/sysdep.h" +#include "src/mc/VisitedState.hpp" #include "src/mc/mc_comm_pattern.h" #include "src/mc/mc_private.h" -#include "src/mc/Process.hpp" #include "src/mc/mc_smx.h" -#include "src/mc/VisitedState.hpp" +#include "src/mc/remote/RemoteClient.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_VisitedState, mc, "Logging specific to state equality detection mechanisms"); @@ -36,7 +36,7 @@ static int snapshot_compare(simgrid::mc::VisitedState* state1, simgrid::mc::Visi /** @brief Save the current state */ VisitedState::VisitedState(unsigned long state_number) { - simgrid::mc::Process* process = &(mc_model_checker->process()); + simgrid::mc::RemoteClient* process = &(mc_model_checker->process()); this->heap_bytes_used = mmalloc_get_bytes_used_remote( process->get_heap()->heaplimit, process->get_malloc_info()); diff --git a/src/mc/checker/LivenessChecker.cpp b/src/mc/checker/LivenessChecker.cpp index f65fff1d61..01ab0accd8 100644 --- a/src/mc/checker/LivenessChecker.cpp +++ b/src/mc/checker/LivenessChecker.cpp @@ -44,7 +44,7 @@ VisitedPair::VisitedPair( std::shared_ptr> atomic_propositions, std::shared_ptr graph_state) { - simgrid::mc::Process* process = &(mc_model_checker->process()); + simgrid::mc::RemoteClient* process = &(mc_model_checker->process()); this->graph_state = std::move(graph_state); if(this->graph_state->system_state == nullptr) diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index e5a873b8f9..fdc6c5c08b 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -316,7 +316,7 @@ static int mmalloc_compare_heap( simgrid::mc::StateComparator& state, simgrid::mc::Snapshot* snapshot1, simgrid::mc::Snapshot* snapshot2) { - simgrid::mc::Process* process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* process = &mc_model_checker->process(); /* Start comparison */ size_t i1; @@ -609,7 +609,7 @@ static int compare_heap_area_without_type( HeapLocationPairs* previous, int size, int check_ignore) { - simgrid::mc::Process* process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* process = &mc_model_checker->process(); mc_mem_region_t heap_region1 = MC_get_heap_region(snapshot1); mc_mem_region_t heap_region2 = MC_get_heap_region(snapshot2); @@ -965,7 +965,7 @@ int compare_heap_area(simgrid::mc::StateComparator& state, int process_index, HeapLocationPairs* previous, simgrid::mc::Type* type, int pointer_level) { - simgrid::mc::Process* process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* process = &mc_model_checker->process(); int res_compare; ssize_t block1; @@ -1276,7 +1276,7 @@ static int compare_areas_with_type(simgrid::mc::StateComparator& state, void* real_area2, simgrid::mc::Snapshot* snapshot2, mc_mem_region_t region2, simgrid::mc::Type* type, int pointer_level) { - simgrid::mc::Process* process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* process = &mc_model_checker->process(); simgrid::mc::Type* subtype; simgrid::mc::Type* subsubtype; @@ -1557,7 +1557,7 @@ int snapshot_compare(int num1, simgrid::mc::Snapshot* s1, int num2, simgrid::mc: else state_comparator->clear(); - simgrid::mc::Process* process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* process = &mc_model_checker->process(); int errors = 0; diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index f367c99118..067a29f63f 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -164,7 +164,7 @@ bool request_is_enabled(smx_simcall_t req) return true; #if SIMGRID_HAVE_MC else if (mc_model_checker != nullptr) { - simgrid::mc::Process& modelchecked = mc_model_checker->process(); + simgrid::mc::RemoteClient& modelchecked = mc_model_checker->process(); // TODO, *(mutex->owner) :/ return modelchecked.resolveActor(simgrid::mc::remote(mutex->owner))->pid == modelchecked.resolveActor(simgrid::mc::remote(req->issuer))->pid; diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index f05cfcdf19..28e8e0cbf3 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -142,7 +142,7 @@ void add_region(int index, simgrid::mc::Snapshot* snapshot, return; } -static void get_memory_regions(simgrid::mc::Process* process, simgrid::mc::Snapshot* snapshot) +static void get_memory_regions(simgrid::mc::RemoteClient* process, simgrid::mc::Snapshot* snapshot) { const size_t n = process->object_infos.size(); snapshot->snapshot_regions.resize(n + 1); @@ -283,7 +283,7 @@ static void fill_local_variables_values(mc_stack_frame_t stack_frame, int process_index, std::vector& result) { - simgrid::mc::Process* process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* process = &mc_model_checker->process(); if (not scope || not scope->range.contain(stack_frame->ip)) return; @@ -347,7 +347,7 @@ static std::vector get_local_variables_values( static std::vector unwind_stack_frames(simgrid::mc::UnwindContext* stack_context) { - simgrid::mc::Process* process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* process = &mc_model_checker->process(); std::vector result; unw_cursor_t c = stack_context->cursor(); @@ -555,7 +555,7 @@ std::shared_ptr take_snapshot(int num_state) { XBT_DEBUG("Taking snapshot %i", num_state); - simgrid::mc::Process* mc_process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* mc_process = &mc_model_checker->process(); std::shared_ptr snapshot = std::make_shared(mc_process, num_state); diff --git a/src/mc/mc_dwarf.cpp b/src/mc/mc_dwarf.cpp index 8cc387cfa0..47b5771e50 100644 --- a/src/mc/mc_dwarf.cpp +++ b/src/mc/mc_dwarf.cpp @@ -28,9 +28,9 @@ #include "src/mc/mc_private.h" #include "src/mc/mc_dwarf.hpp" -#include "src/mc/Process.hpp" #include "src/mc/ObjectInformation.hpp" #include "src/mc/Variable.hpp" +#include "src/mc/remote/RemoteClient.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dwarf, mc, "DWARF processing"); @@ -1371,7 +1371,7 @@ std::shared_ptr createObjectInformation( /*************************************************************************/ -void postProcessObjectInformation(simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info) +void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info) { for (auto& i : info->types) { diff --git a/src/mc/mc_forward.hpp b/src/mc/mc_forward.hpp index 8bc8105575..6471c6fa78 100644 --- a/src/mc/mc_forward.hpp +++ b/src/mc/mc_forward.hpp @@ -19,7 +19,7 @@ class PageStore; class ChunkedData; class ModelChecker; class AddressSpace; -class Process; +class RemoteClient; class Snapshot; class ObjectInformation; class Member; diff --git a/src/mc/mc_page_snapshot.cpp b/src/mc/mc_page_snapshot.cpp index 7677ad1fe0..5c6f2bf96d 100644 --- a/src/mc/mc_page_snapshot.cpp +++ b/src/mc/mc_page_snapshot.cpp @@ -30,8 +30,8 @@ extern "C" { * @param page_count Number of pages of the region * @param pagenos */ -void mc_restore_page_snapshot_region(simgrid::mc::Process* process, - void* start_addr, simgrid::mc::ChunkedData const& pages_copy) +void mc_restore_page_snapshot_region(simgrid::mc::RemoteClient* process, void* start_addr, + simgrid::mc::ChunkedData const& pages_copy) { for (size_t i = 0; i != pages_copy.page_count(); ++i) { // Otherwise, copy the page: @@ -43,7 +43,7 @@ void mc_restore_page_snapshot_region(simgrid::mc::Process* process, // ***** High level API -void mc_region_restore_sparse(simgrid::mc::Process* process, mc_mem_region_t reg) +void mc_region_restore_sparse(simgrid::mc::RemoteClient* process, mc_mem_region_t reg) { xbt_assert(((reg->permanent_address().address()) & (xbt_pagesize-1)) == 0, "Not at the beginning of a page"); diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index 0bcc7ea4ec..cd22b6b26c 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -31,7 +31,7 @@ static inline simgrid::mc::ActorInformation* actor_info_cast(smx_actor_t actor) * @param target Local vector (to be filled with copies of `s_smx_actor_t`) * @param remote_swag Address of the process SWAG in the remote list */ -static void MC_process_refresh_simix_process_list(simgrid::mc::Process* process, +static void MC_process_refresh_simix_process_list(simgrid::mc::RemoteClient* process, std::vector& target, simgrid::mc::RemotePtr remote_swag) { @@ -57,7 +57,7 @@ static void MC_process_refresh_simix_process_list(simgrid::mc::Process* process, assert(i == swag.count); } -static void MC_process_refresh_simix_actor_dynar(simgrid::mc::Process* process, +static void MC_process_refresh_simix_actor_dynar(simgrid::mc::RemoteClient* process, std::vector& target, simgrid::mc::RemotePtr remote_dynar) { @@ -83,9 +83,9 @@ static void MC_process_refresh_simix_actor_dynar(simgrid::mc::Process* process, namespace simgrid { namespace mc { -void Process::refresh_simix() +void RemoteClient::refresh_simix() { - if (this->cache_flags_ & Process::cache_simix_processes) + if (this->cache_flags_ & RemoteClient::cache_simix_processes) return; // TODO, avoid to reload `&simix_global`, `simix_global`, `*simix_global` @@ -109,7 +109,7 @@ void Process::refresh_simix() MC_process_refresh_simix_process_list(this, this->smx_dead_actors_infos, remote(simix_global.getBuffer()->process_to_destroy)); - this->cache_flags_ |= Process::cache_simix_processes; + this->cache_flags_ |= RemoteClient::cache_simix_processes; } } @@ -147,7 +147,7 @@ const char* MC_smx_actor_get_host_name(smx_actor_t actor) if (mc_model_checker == nullptr) return actor->host->getCname(); - simgrid::mc::Process* process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* process = &mc_model_checker->process(); /* HACK, Horrible hack to find the offset of the id in the simgrid::s4u::Host. @@ -179,7 +179,7 @@ const char* MC_smx_actor_get_host_name(smx_actor_t actor) const char* MC_smx_actor_get_name(smx_actor_t actor) { - simgrid::mc::Process* process = &mc_model_checker->process(); + simgrid::mc::RemoteClient* process = &mc_model_checker->process(); if (mc_model_checker == nullptr) return actor->name.c_str(); diff --git a/src/mc/mc_smx.h b/src/mc/mc_smx.h index 28d20b7b47..be72eaa617 100644 --- a/src/mc/mc_smx.h +++ b/src/mc/mc_smx.h @@ -6,7 +6,7 @@ #ifndef SIMGRID_MC_SMX_H #define SIMGRID_MC_SMX_H -#include "src/mc/Process.hpp" +#include "src/mc/remote/RemoteClient.hpp" /** @file * @brief (Cross-process, MCer/MCed) Access to SMX structures diff --git a/src/mc/mc_snapshot.cpp b/src/mc/mc_snapshot.cpp index 80c0817be5..a79de0e12c 100644 --- a/src/mc/mc_snapshot.cpp +++ b/src/mc/mc_snapshot.cpp @@ -159,7 +159,7 @@ int MC_snapshot_memcmp( namespace simgrid { namespace mc { -Snapshot::Snapshot(Process* process, int _num_state) +Snapshot::Snapshot(RemoteClient* process, int _num_state) : AddressSpace(process) , num_state(_num_state) , heap_bytes_used(0) @@ -234,7 +234,7 @@ static void test_snapshot(bool sparse_checkpoint) { xbt_assert(xbt_pagesize == getpagesize()); xbt_assert(1 << xbt_pagebits == xbt_pagesize); - std::unique_ptr process(new simgrid::mc::Process(getpid(), -1)); + std::unique_ptr process(new simgrid::mc::RemoteClient(getpid(), -1)); process->init(); mc_model_checker = new ::simgrid::mc::ModelChecker(std::move(process)); diff --git a/src/mc/mc_snapshot.h b/src/mc/mc_snapshot.h index a5c7c17560..03a47e55d1 100644 --- a/src/mc/mc_snapshot.h +++ b/src/mc/mc_snapshot.h @@ -20,7 +20,7 @@ SG_BEGIN_DECL() // ***** Snapshot region -XBT_PRIVATE void mc_region_restore_sparse(simgrid::mc::Process* process, mc_mem_region_t reg); +XBT_PRIVATE void mc_region_restore_sparse(simgrid::mc::RemoteClient* process, mc_mem_region_t reg); static XBT_ALWAYS_INLINE void* mc_translate_address_region_chunked(uintptr_t addr, mc_mem_region_t region) { @@ -118,7 +118,7 @@ namespace mc { class XBT_PRIVATE Snapshot final : public AddressSpace { public: - Snapshot(Process* process, int num_state); + Snapshot(RemoteClient* process, int num_state); ~Snapshot() = default; const void* read_bytes(void* buffer, std::size_t size, RemotePtr address, int process_index = ProcessIndexAny, @@ -170,9 +170,8 @@ XBT_PRIVATE void restore_snapshot(std::shared_ptr snapsho extern "C" { -XBT_PRIVATE void mc_restore_page_snapshot_region( - simgrid::mc::Process* process, - void* start_addr, simgrid::mc::ChunkedData const& pagenos); +XBT_PRIVATE void mc_restore_page_snapshot_region(simgrid::mc::RemoteClient* process, void* start_addr, + simgrid::mc::ChunkedData const& pagenos); const void* MC_region_read_fragmented( mc_mem_region_t region, void* target, const void* addr, std::size_t size); diff --git a/src/mc/mc_unw.cpp b/src/mc/mc_unw.cpp index f172da799c..6b2d206517 100644 --- a/src/mc/mc_unw.cpp +++ b/src/mc/mc_unw.cpp @@ -22,9 +22,9 @@ typedef register_t greg_t; #include -#include "src/mc/Process.hpp" -#include "src/mc/mc_unw.h" #include "src/mc/Frame.hpp" +#include "src/mc/mc_unw.h" +#include "src/mc/remote/RemoteClient.hpp" using simgrid::mc::remote; @@ -236,7 +236,7 @@ void UnwindContext::clear() process_ = nullptr; } -void UnwindContext::initialize(simgrid::mc::Process* process, unw_context_t* c) +void UnwindContext::initialize(simgrid::mc::RemoteClient* process, unw_context_t* c) { clear(); diff --git a/src/mc/mc_unw.h b/src/mc/mc_unw.h index 2200b5f91d..8227402c38 100644 --- a/src/mc/mc_unw.h +++ b/src/mc/mc_unw.h @@ -44,13 +44,13 @@ namespace mc { class UnwindContext { simgrid::mc::AddressSpace* addressSpace_ = nullptr; - simgrid::mc::Process* process_ = nullptr; + simgrid::mc::RemoteClient* process_ = nullptr; unw_context_t unwindContext_; public: UnwindContext() = default; ~UnwindContext() { clear(); } - void initialize(simgrid::mc::Process* process, unw_context_t* c); + void initialize(simgrid::mc::RemoteClient* process, unw_context_t* c); void clear(); unw_cursor_t cursor(); diff --git a/src/mc/mc_unw_vmread.cpp b/src/mc/mc_unw_vmread.cpp index 148a2f5995..f9115be55e 100644 --- a/src/mc/mc_unw_vmread.cpp +++ b/src/mc/mc_unw_vmread.cpp @@ -11,8 +11,8 @@ #include #include -#include "src/mc/Process.hpp" #include "src/mc/mc_unw.h" +#include "src/mc/remote/RemoteClient.hpp" /** \file * Libunwind namespace implementation using process_vm_readv. diff --git a/src/mc/Process.cpp b/src/mc/remote/RemoteClient.cpp similarity index 72% rename from src/mc/Process.cpp rename to src/mc/remote/RemoteClient.cpp index d4d71ea8cd..6046e09772 100644 --- a/src/mc/Process.cpp +++ b/src/mc/remote/RemoteClient.cpp @@ -6,44 +6,43 @@ #define _FILE_OFFSET_BITS 64 /* needed for pread_whole to work as expected on 32bits */ #include +#include #include #include -#include #include #include -#include #include -#include #include #include // PROT_* +#include +#include #include #include -#include #include +#include #include "xbt/base.h" #include "xbt/log.h" #include -#include "src/mc/mc_unw.h" -#include "src/mc/mc_snapshot.h" #include "src/mc/mc_smx.h" +#include "src/mc/mc_snapshot.h" +#include "src/mc/mc_unw.h" -#include "src/mc/Process.hpp" #include "src/mc/AddressSpace.hpp" #include "src/mc/ObjectInformation.hpp" #include "src/mc/Variable.hpp" +#include "src/mc/remote/RemoteClient.hpp" using simgrid::mc::remote; -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_process, mc, - "MC process information"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_process, mc, "MC process information"); // ***** Helper stuff @@ -107,7 +106,7 @@ static bool is_simgrid_lib(const char* libname) static bool is_filtered_lib(const char* libname) { for (const char* filtered_lib : filtered_libraries) - if (strcmp(libname, filtered_lib)==0) + if (strcmp(libname, filtered_lib) == 0) return true; return false; } @@ -122,7 +121,7 @@ static char* get_lib_name(const char* pathname, struct s_mc_memory_map_re* res) char* map_basename = xbt_basename(pathname); regmatch_t match; - if(regexec(&res->so_re, map_basename, 1, &match, 0)) { + if (regexec(&res->so_re, map_basename, 1, &match, 0)) { free(map_basename); return nullptr; } @@ -134,24 +133,24 @@ static char* get_lib_name(const char* pathname, struct s_mc_memory_map_re* res) // Strip the version suffix: if (libname && not regexec(&res->version_re, libname, 1, &match, 0)) { char* temp = libname; - libname = strndup(temp, match.rm_so); + libname = strndup(temp, match.rm_so); free(temp); } return libname; } -static ssize_t pread_whole(int fd, void *buf, size_t count, off_t offset) +static ssize_t pread_whole(int fd, void* buf, size_t count, off_t offset) { - char* buffer = (char*) buf; + char* buffer = (char*)buf; ssize_t real_count = count; while (count) { ssize_t res = pread(fd, buffer, count, offset); if (res > 0) { - count -= res; + count -= res; buffer += res; offset += res; - } else if (res==0) + } else if (res == 0) return -1; else if (errno != EINTR) { perror("pread_whole"); @@ -161,17 +160,17 @@ static ssize_t pread_whole(int fd, void *buf, size_t count, off_t offset) return real_count; } -static ssize_t pwrite_whole(int fd, const void *buf, size_t count, off_t offset) +static ssize_t pwrite_whole(int fd, const void* buf, size_t count, off_t offset) { - const char* buffer = (const char*) buf; + const char* buffer = (const char*)buf; ssize_t real_count = count; while (count) { ssize_t res = pwrite(fd, buffer, count, offset); if (res > 0) { - count -= res; + count -= res; buffer += res; offset += res; - } else if (res==0) + } else if (res == 0) return -1; else if (errno != EINTR) return -1; @@ -186,7 +185,7 @@ static const size_t zero_buffer_size = 10 * 4096; static void zero_buffer_init() { int fd = open("/dev/zero", O_RDONLY); - if (fd<0) + if (fd < 0) xbt_die("Could not open /dev/zero"); zero_buffer = mmap(nullptr, zero_buffer_size, PROT_READ, MAP_SHARED, fd, 0); if (zero_buffer == MAP_FAILED) @@ -198,8 +197,8 @@ 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) { + int res = snprintf(buffer, buffer_size, "/proc/%lli/mem", (long long)pid); + if (res < 0 || (size_t)res >= buffer_size) { errno = ENAMETOOLONG; return -1; } @@ -208,17 +207,17 @@ int open_vm(pid_t pid, int flags) // ***** Process -Process::Process(pid_t pid, int sockfd) : - AddressSpace(this), pid_(pid), channel_(sockfd), running_(true) -{} +RemoteClient::RemoteClient(pid_t pid, int sockfd) : AddressSpace(this), pid_(pid), channel_(sockfd), running_(true) +{ +} -void Process::init() +void RemoteClient::init() { this->memory_map_ = simgrid::xbt::get_memory_map(this->pid_); this->init_memory_map_info(); int fd = open_vm(this->pid_, O_RDWR); - if (fd<0) + if (fd < 0) xbt_die("Could not open file for process virtual address space"); this->memory_file = fd; @@ -228,19 +227,17 @@ void Process::init() xbt_die("No heap information in the target process"); if (not std_heap_var->address) xbt_die("No constant address for this variable"); - this->read_bytes(&this->heap_address, sizeof(struct mdesc*), - remote(std_heap_var->address), - simgrid::mc::ProcessIndexDisabled); + this->read_bytes(&this->heap_address, sizeof(struct mdesc*), remote(std_heap_var->address), + simgrid::mc::ProcessIndexDisabled); this->smx_actors_infos.clear(); this->smx_dead_actors_infos.clear(); - this->unw_addr_space = simgrid::mc::UnwindContext::createUnwindAddressSpace(); + 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_); + this->unw_underlying_context = simgrid::unw::create_context(this->unw_underlying_addr_space, this->pid_); } -Process::~Process() +RemoteClient::~RemoteClient() { if (this->memory_file >= 0) close(this->memory_file); @@ -260,14 +257,14 @@ Process::~Process() * Do not use directly, this is used by the getters when appropriate * in order to have fresh data. */ -void Process::refresh_heap() +void RemoteClient::refresh_heap() { // Read/dereference/refresh the std_heap pointer: if (not this->heap) this->heap = std::unique_ptr(new s_xbt_mheap_t()); - this->read_bytes(this->heap.get(), sizeof(struct mdesc), - remote(this->heap_address), simgrid::mc::ProcessIndexDisabled); - this->cache_flags_ |= Process::cache_heap; + this->read_bytes(this->heap.get(), sizeof(struct mdesc), remote(this->heap_address), + simgrid::mc::ProcessIndexDisabled); + this->cache_flags_ |= RemoteClient::cache_heap; } /** Refresh the information about the process @@ -275,32 +272,32 @@ void Process::refresh_heap() * Do not use direclty, this is used by the getters when appropriate * in order to have fresh data. * */ -void Process::refresh_malloc_info() +void RemoteClient::refresh_malloc_info() { // Refresh process->heapinfo: - if (this->cache_flags_ & Process::cache_malloc) + if (this->cache_flags_ & RemoteClient::cache_malloc) return; size_t count = this->heap->heaplimit + 1; if (this->heap_info.size() < count) this->heap_info.resize(count); - this->read_bytes(this->heap_info.data(), count * sizeof(malloc_info), - remote(this->heap->heapinfo), simgrid::mc::ProcessIndexDisabled); - this->cache_flags_ |= Process::cache_malloc; + this->read_bytes(this->heap_info.data(), count * sizeof(malloc_info), remote(this->heap->heapinfo), + simgrid::mc::ProcessIndexDisabled); + this->cache_flags_ |= RemoteClient::cache_malloc; } /** @brief Finds the range of the different memory segments and binary paths */ -void Process::init_memory_map_info() +void RemoteClient::init_memory_map_info() { XBT_DEBUG("Get debug information ..."); this->maestro_stack_start_ = nullptr; - this->maestro_stack_end_ = nullptr; + this->maestro_stack_end_ = nullptr; this->object_infos.resize(0); - this->binary_info = nullptr; + this->binary_info = nullptr; this->libsimgrid_info = nullptr; struct s_mc_memory_map_re res; - if(regcomp(&res.so_re, SO_RE, 0) || regcomp(&res.version_re, VERSION_RE, 0)) + if (regcomp(&res.so_re, SO_RE, 0) || regcomp(&res.version_re, VERSION_RE, 0)) xbt_die(".so regexp did not compile"); std::vector const& maps = this->memory_map_; @@ -309,9 +306,9 @@ void Process::init_memory_map_info() this->object_infos.clear(); - for (size_t i=0; i < maps.size(); i++) { + for (size_t i = 0; i < maps.size(); i++) { simgrid::xbt::VmMap const& reg = maps[i]; - const char* pathname = maps[i].pathname.c_str(); + const char* pathname = maps[i].pathname.c_str(); // Nothing to do if (maps[i].pathname.empty()) { @@ -323,13 +320,13 @@ void Process::init_memory_map_info() if (pathname[0] == '[') { if ((reg.prot & PROT_WRITE) && not memcmp(pathname, "[stack]", 7)) { this->maestro_stack_start_ = remote(reg.start_addr); - this->maestro_stack_end_ = remote(reg.end_addr); + this->maestro_stack_end_ = remote(reg.end_addr); } current_name = nullptr; continue; } - if (current_name && strcmp(current_name, pathname)==0) + if (current_name && strcmp(current_name, pathname) == 0) continue; current_name = pathname; @@ -337,7 +334,7 @@ void Process::init_memory_map_info() continue; const bool is_executable = not i; - char* libname = nullptr; + char* libname = nullptr; if (not is_executable) { libname = get_lib_name(pathname, &res); if (not libname) @@ -349,7 +346,7 @@ void Process::init_memory_map_info() } std::shared_ptr info = - simgrid::mc::createObjectInformation(this->memory_map_, pathname); + simgrid::mc::createObjectInformation(this->memory_map_, pathname); this->object_infos.push_back(info); if (is_executable) this->binary_info = info; @@ -371,42 +368,39 @@ void Process::init_memory_map_info() XBT_DEBUG("Get debug information done !"); } -std::shared_ptr Process::find_object_info(RemotePtr addr) const +std::shared_ptr RemoteClient::find_object_info(RemotePtr addr) const { for (auto const& object_info : this->object_infos) - if (addr.address() >= (std::uint64_t)object_info->start - && addr.address() <= (std::uint64_t)object_info->end) + if (addr.address() >= (std::uint64_t)object_info->start && addr.address() <= (std::uint64_t)object_info->end) return object_info; return nullptr; } -std::shared_ptr Process::find_object_info_exec(RemotePtr addr) const +std::shared_ptr RemoteClient::find_object_info_exec(RemotePtr addr) const { for (std::shared_ptr const& info : this->object_infos) - if (addr.address() >= (std::uint64_t) info->start_exec - && addr.address() <= (std::uint64_t) info->end_exec) + if (addr.address() >= (std::uint64_t)info->start_exec && addr.address() <= (std::uint64_t)info->end_exec) return info; return nullptr; } -std::shared_ptr Process::find_object_info_rw(RemotePtr addr) const +std::shared_ptr RemoteClient::find_object_info_rw(RemotePtr addr) const { for (std::shared_ptr const& info : this->object_infos) - if (addr.address() >= (std::uint64_t)info->start_rw - && addr.address() <= (std::uint64_t)info->end_rw) + if (addr.address() >= (std::uint64_t)info->start_rw && addr.address() <= (std::uint64_t)info->end_rw) return info; return nullptr; } -simgrid::mc::Frame* Process::find_function(RemotePtr ip) const +simgrid::mc::Frame* RemoteClient::find_function(RemotePtr ip) const { std::shared_ptr info = this->find_object_info_exec(ip); - return info ? info->find_function((void*) ip.address()) : nullptr; + return info ? info->find_function((void*)ip.address()) : nullptr; } /** Find (one occurrence of) the named variable definition */ -simgrid::mc::Variable* Process::find_variable(const char* name) const +simgrid::mc::Variable* RemoteClient::find_variable(const char* name) const { // First lookup the variable in the executable shared object. // A global variable used directly by the executable code from a library @@ -414,7 +408,7 @@ simgrid::mc::Variable* Process::find_variable(const char* name) const // We need to look up the variable in the executable first. if (this->binary_info) { std::shared_ptr const& info = this->binary_info; - simgrid::mc::Variable* var = info->find_variable(name); + simgrid::mc::Variable* var = info->find_variable(name); if (var) return var; } @@ -428,7 +422,7 @@ simgrid::mc::Variable* Process::find_variable(const char* name) const return nullptr; } -void Process::read_variable(const char* name, void* target, size_t size) const +void RemoteClient::read_variable(const char* name, void* target, size_t size) const { simgrid::mc::Variable* var = this->find_variable(name); xbt_assert(var->address, "No simple location for this variable"); @@ -438,7 +432,7 @@ void Process::read_variable(const char* name, void* target, size_t size) const this->read_bytes(target, size, remote(var->address)); } -std::string Process::read_string(RemotePtr address) const +std::string RemoteClient::read_string(RemotePtr address) const { if (not address) return {}; @@ -448,14 +442,14 @@ std::string Process::read_string(RemotePtr address) const off_t off = 0; while (1) { - ssize_t c = pread(this->memory_file, res.data() + off, res.size() - off, (off_t) address.address() + off); + ssize_t c = pread(this->memory_file, res.data() + off, res.size() - off, (off_t)address.address() + off); if (c == -1) { if (errno == EINTR) continue; else xbt_die("Could not read from from remote process"); } - if (c==0) + if (c == 0) xbt_die("Could not read string from remote process"); void* p = memchr(res.data() + off, '\0', c); @@ -463,42 +457,39 @@ std::string Process::read_string(RemotePtr address) const return std::string(res.data()); off += c; - if (off == (off_t) res.size()) + if (off == (off_t)res.size()) res.resize(res.size() * 2); } } -const void *Process::read_bytes(void* buffer, std::size_t size, - RemotePtr address, int process_index, - ReadOptions options) const +const void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr address, int process_index, + ReadOptions options) const { if (process_index != simgrid::mc::ProcessIndexDisabled) { - std::shared_ptr const& info = - this->find_object_info_rw((void*)address.address()); - // Segment overlap is not handled. + std::shared_ptr const& info = this->find_object_info_rw((void*)address.address()); +// Segment overlap is not handled. #if HAVE_SMPI if (info.get() && this->privatized(*info)) { if (process_index < 0) xbt_die("Missing process index"); - if (process_index >= (int) MC_smpi_process_count()) + if (process_index >= (int)MC_smpi_process_count()) xbt_die("Invalid process index"); // Read smpi_privatization_regions from MCed: smpi_privatization_region_t remote_smpi_privatization_regions = - mc_model_checker->process().read_variable( - "smpi_privatization_regions"); + mc_model_checker->process().read_variable("smpi_privatization_regions"); s_smpi_privatization_region_t privatization_region = - mc_model_checker->process().read( - remote(remote_smpi_privatization_regions + process_index)); + mc_model_checker->process().read( + remote(remote_smpi_privatization_regions + process_index)); // Address translation in the privatization segment: size_t offset = address.address() - (std::uint64_t)info->start_rw; - address = remote((char*)privatization_region.address + offset); + address = remote((char*)privatization_region.address + offset); } #endif } - if (pread_whole(this->memory_file, buffer, size, (size_t) address.address()) < 0) + if (pread_whole(this->memory_file, buffer, size, (size_t)address.address()) < 0) xbt_die("Read at %p from process %lli failed", (void*)address.address(), (long long)this->pid_); return buffer; } @@ -509,24 +500,24 @@ const void *Process::read_bytes(void* buffer, std::size_t size, * @param len data size * @param address target process memory address (target) */ -void Process::write_bytes(const void* buffer, size_t len, RemotePtr address) +void RemoteClient::write_bytes(const void* buffer, size_t len, RemotePtr address) { - if (pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) < 0) - xbt_die("Write to process %lli failed", (long long) this->pid_); + if (pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) < 0) + xbt_die("Write to process %lli failed", (long long)this->pid_); } -void Process::clear_bytes(RemotePtr address, size_t len) +void RemoteClient::clear_bytes(RemotePtr address, size_t len) { pthread_once(&zero_buffer_flag, zero_buffer_init); while (len) { size_t s = len > zero_buffer_size ? zero_buffer_size : len; this->write_bytes(zero_buffer, s, address); - address = remote((char*) address.address() + s); + address = remote((char*)address.address() + s); len -= s; } } -void Process::ignore_region(std::uint64_t addr, std::size_t size) +void RemoteClient::ignore_region(std::uint64_t addr, std::size_t size) { IgnoredRegion region; region.addr = addr; @@ -537,13 +528,13 @@ void Process::ignore_region(std::uint64_t addr, std::size_t size) return; } - unsigned int cursor = 0; + unsigned int cursor = 0; IgnoredRegion* current_region = nullptr; int start = 0; - int end = ignored_regions_.size() - 1; + int end = ignored_regions_.size() - 1; while (start <= end) { - cursor = (start + end) / 2; + cursor = (start + end) / 2; current_region = &ignored_regions_[cursor]; if (current_region->addr == addr) { if (current_region->size == size) @@ -568,11 +559,10 @@ void Process::ignore_region(std::uint64_t addr, std::size_t size) position = cursor + 1; else position = cursor; - ignored_regions_.insert( - ignored_regions_.begin() + position, region); + ignored_regions_.insert(ignored_regions_.begin() + position, region); } -void Process::ignore_heap(IgnoredHeapRegion const& region) +void RemoteClient::ignore_heap(IgnoredHeapRegion const& region) { if (ignored_heap_.empty()) { ignored_heap_.push_back(std::move(region)); @@ -582,12 +572,12 @@ void Process::ignore_heap(IgnoredHeapRegion const& region) typedef std::vector::size_type size_type; size_type start = 0; - size_type end = ignored_heap_.size() - 1; + size_type end = ignored_heap_.size() - 1; // Binary search the position of insertion: size_type cursor; while (start <= end) { - cursor = start + (end - start) / 2; + cursor = start + (end - start) / 2; auto& current_region = ignored_heap_[cursor]; if (current_region.address == region.address) return; @@ -603,27 +593,27 @@ void Process::ignore_heap(IgnoredHeapRegion const& region) // Insert it mc_heap_ignore_region_t: if (ignored_heap_[cursor].address < region.address) ++cursor; - ignored_heap_.insert( ignored_heap_.begin() + cursor, region); + ignored_heap_.insert(ignored_heap_.begin() + cursor, region); } -void Process::unignore_heap(void *address, size_t size) +void RemoteClient::unignore_heap(void* address, size_t size) { typedef std::vector::size_type size_type; size_type start = 0; - size_type end = ignored_heap_.size() - 1; + size_type end = ignored_heap_.size() - 1; // Binary search: size_type cursor; while (start <= end) { - cursor = (start + end) / 2; + cursor = (start + end) / 2; auto& region = ignored_heap_[cursor]; if (region.address == address) { ignored_heap_.erase(ignored_heap_.begin() + cursor); return; } else if (region.address < address) start = cursor + 1; - else if ((char *) region.address <= ((char *) address + size)) { + else if ((char*)region.address <= ((char*)address + size)) { ignored_heap_.erase(ignored_heap_.begin() + cursor); return; } else if (cursor != 0) @@ -634,28 +624,27 @@ void Process::unignore_heap(void *address, size_t size) } } -void Process::ignore_local_variable(const char *var_name, const char *frame_name) +void RemoteClient::ignore_local_variable(const char* var_name, const char* frame_name) { if (frame_name != nullptr && strcmp(frame_name, "*") == 0) frame_name = nullptr; - for (std::shared_ptr const& info : - this->object_infos) + for (std::shared_ptr const& info : this->object_infos) info->remove_local_variable(var_name, frame_name); } -std::vector& Process::actors() +std::vector& RemoteClient::actors() { this->refresh_simix(); return smx_actors_infos; } -std::vector& Process::dead_actors() +std::vector& RemoteClient::dead_actors() { this->refresh_simix(); return smx_dead_actors_infos; } -void Process::dumpStack() +void RemoteClient::dumpStack() { unw_addr_space_t as = unw_create_addr_space(&_UPT_accessors, BYTE_ORDER); if (as == nullptr) { @@ -684,6 +673,5 @@ void Process::dumpStack() unw_destroy_addr_space(as); return; } - } } diff --git a/src/mc/Process.hpp b/src/mc/remote/RemoteClient.hpp similarity index 75% rename from src/mc/Process.hpp rename to src/mc/remote/RemoteClient.hpp index 19c2e5eb4e..34c31b698f 100644 --- a/src/mc/Process.hpp +++ b/src/mc/remote/RemoteClient.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2008-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2008-2017. 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,13 +6,13 @@ #ifndef SIMGRID_MC_PROCESS_H #define SIMGRID_MC_PROCESS_H -#include #include +#include -#include -#include #include #include +#include +#include #include @@ -27,9 +26,9 @@ #include "src/mc/remote/Channel.hpp" #include "src/mc/remote/RemotePtr.hpp" -#include #include "src/simix/popping_private.h" #include "src/simix/smx_private.h" +#include #include "src/xbt/memory_map.hpp" @@ -55,7 +54,7 @@ public: void clear() { name.clear(); - address = nullptr; + address = nullptr; hostname = nullptr; } }; @@ -68,11 +67,11 @@ struct IgnoredRegion { struct IgnoredHeapRegion { int block; int fragment; - void *address; + void* address; std::size_t size; }; -/** Representation of a process +/** The Model-Checked process, seen from the MCer perspective * * This class is mixing a lot of different responsibilities and is tied * to SIMIX. It should probably be split into different classes. @@ -87,36 +86,35 @@ struct IgnoredHeapRegion { * - stack unwinding; * - etc. */ -class Process final : public AddressSpace { +class RemoteClient final : public AddressSpace { private: // Those flags are used to track down which cached information // is still up to date and which information needs to be updated. - static constexpr int cache_none = 0; - static constexpr int cache_heap = 1; - static constexpr int cache_malloc = 2; + static constexpr int cache_none = 0; + static constexpr int cache_heap = 1; + static constexpr int cache_malloc = 2; static constexpr int cache_simix_processes = 4; + public: - Process(pid_t pid, int sockfd); - ~Process(); + RemoteClient(pid_t pid, int sockfd); + ~RemoteClient(); void init(); - Process(Process const&) = delete; - Process(Process &&) = delete; - Process& operator=(Process const&) = delete; - Process& operator=(Process &&) = delete; + RemoteClient(RemoteClient const&) = delete; + RemoteClient(RemoteClient&&) = delete; + RemoteClient& operator=(RemoteClient const&) = delete; + RemoteClient& operator=(RemoteClient&&) = delete; // Read memory: - const void* read_bytes(void* buffer, std::size_t size, - RemotePtr address, int process_index = ProcessIndexAny, - ReadOptions options = ReadOptions::none()) const override; + const void* read_bytes(void* buffer, std::size_t size, RemotePtr address, int process_index = ProcessIndexAny, + ReadOptions options = ReadOptions::none()) const override; void read_variable(const char* name, void* target, size_t size) const; - template void read_variable(const char* name, T* target) const + template void read_variable(const char* name, T* target) const { read_variable(name, target, sizeof(*target)); } - template - Remote read_variable(const char *name) const + template Remote read_variable(const char* name) const { Remote res; read_variable(name, res.getBuffer(), sizeof(T)); @@ -143,29 +141,23 @@ public: // Heap access: xbt_mheap_t get_heap() { - if (not(this->cache_flags_ & Process::cache_heap)) + if (not(this->cache_flags_ & RemoteClient::cache_heap)) this->refresh_heap(); return this->heap.get(); } const malloc_info* get_malloc_info() { - if (not(this->cache_flags_ & Process::cache_malloc)) + if (not(this->cache_flags_ & RemoteClient::cache_malloc)) this->refresh_malloc_info(); return this->heap_info.data(); } - void clear_cache() - { - this->cache_flags_ = Process::cache_none; - } + void clear_cache() { this->cache_flags_ = RemoteClient::cache_none; } Channel const& getChannel() const { return channel_; } Channel& getChannel() { return channel_; } - std::vector const& ignored_regions() const - { - return ignored_regions_; - } + std::vector const& ignored_regions() const { return ignored_regions_; } void ignore_region(std::uint64_t address, std::size_t size); pid_t pid() const { return pid_; } @@ -175,50 +167,28 @@ public: return p >= this->maestro_stack_start_ && p < this->maestro_stack_end_; } - bool running() const - { - return running_; - } + bool running() const { return running_; } - void terminate() - { - running_ = false; - } + void terminate() { running_ = false; } - bool privatized(ObjectInformation const& info) const - { - return privatized_ && info.executable(); - } - bool privatized() const - { - return privatized_; - } + bool privatized(ObjectInformation const& info) const { return privatized_ && info.executable(); } + bool privatized() const { return privatized_; } void privatized(bool privatized) { privatized_ = privatized; } void ignore_global_variable(const char* name) { - for (std::shared_ptr const& info : - this->object_infos) + for (std::shared_ptr const& info : this->object_infos) info->remove_global_variable(name); } - std::vector& stack_areas() - { - return stack_areas_; - } - std::vector const& stack_areas() const - { - return stack_areas_; - } + std::vector& stack_areas() { return stack_areas_; } + std::vector const& stack_areas() const { return stack_areas_; } - std::vector const& ignored_heap() const - { - return ignored_heap_; - } + std::vector const& ignored_heap() const { return ignored_heap_; } void ignore_heap(IgnoredHeapRegion const& region); - void unignore_heap(void *address, size_t size); + void unignore_heap(void* address, size_t size); - void ignore_local_variable(const char *var_name, const char *frame_name); + void ignore_local_variable(const char* var_name, const char* frame_name); std::vector& actors(); std::vector& dead_actors(); @@ -276,10 +246,10 @@ public: // object info std::shared_ptr binary_info; public: // Copies of MCed SMX data structures - /** Copy of `simix_global->process_list` - * - * See mc_smx.c. - */ + /** Copy of `simix_global->process_list` + * + * See mc_smx.c. + */ std::vector smx_actors_infos; /** Copy of `simix_global->process_to_destroy` @@ -290,7 +260,7 @@ public: // Copies of MCed SMX data structures private: /** State of the cache (which variables are up to date) */ - int cache_flags_ = Process::cache_none; + int cache_flags_ = RemoteClient::cache_none; public: /** Address of the heap structure in the MCed process. */ @@ -302,7 +272,7 @@ public: * This is not used if the process is the current one: * use `get_heap_info()` in order to use it. */ - std::unique_ptr heap; + std::unique_ptr heap; /** Copy of the allocation info structure * @@ -313,13 +283,12 @@ public: std::vector heap_info; public: // Libunwind-data - - /** Full-featured MC-aware libunwind address space for the process - * - * This address space is using a simgrid::mc::UnwindContext* - * (with simgrid::mc::Process* / simgrid::mc::AddressSpace* - * and unw_context_t). - */ + /** Full-featured MC-aware libunwind address space for the process + * + * This address space is using a simgrid::mc::UnwindContext* + * (with simgrid::mc::Process* / simgrid::mc::AddressSpace* + * and unw_context_t). + */ unw_addr_space_t unw_addr_space; /** Underlying libunwind address-space @@ -338,7 +307,6 @@ public: // Libunwind-data /** Open a FD to a remote process memory (`/dev/$pid/mem`) */ XBT_PRIVATE int open_vm(pid_t pid, int flags); - } } diff --git a/teshsuite/mc/dwarf-expression/dwarf-expression.cpp b/teshsuite/mc/dwarf-expression/dwarf-expression.cpp index f059b2c058..afc7d12c9a 100644 --- a/teshsuite/mc/dwarf-expression/dwarf-expression.cpp +++ b/teshsuite/mc/dwarf-expression/dwarf-expression.cpp @@ -14,12 +14,12 @@ #include "src/mc/mc_private.h" -#include "src/mc/Process.hpp" -#include "src/mc/Type.hpp" #include "src/mc/ObjectInformation.hpp" +#include "src/mc/Type.hpp" #include "src/mc/Variable.hpp" +#include "src/mc/remote/RemoteClient.hpp" -static simgrid::mc::Process* process; +static simgrid::mc::RemoteClient* process; static uintptr_t eval_binary_operation( @@ -149,7 +149,7 @@ void test_deref(simgrid::dwarf::ExpressionContext const& state) { } int main(int argc, char** argv) { - process = new simgrid::mc::Process(getpid(), -1); + process = new simgrid::mc::RemoteClient(getpid(), -1); process->init(); simgrid::dwarf::ExpressionContext state; diff --git a/teshsuite/mc/dwarf/dwarf.cpp b/teshsuite/mc/dwarf/dwarf.cpp index fca03b1355..20e0645030 100644 --- a/teshsuite/mc/dwarf/dwarf.cpp +++ b/teshsuite/mc/dwarf/dwarf.cpp @@ -16,10 +16,10 @@ #include "mc/datatypes.h" #include "src/mc/mc_private.h" -#include "src/mc/Process.hpp" -#include "src/mc/Type.hpp" #include "src/mc/ObjectInformation.hpp" +#include "src/mc/Type.hpp" #include "src/mc/Variable.hpp" +#include "src/mc/remote/RemoteClient.hpp" int test_some_array[4][5][6]; struct some_struct { @@ -77,9 +77,9 @@ static void test_local_variable(simgrid::mc::ObjectInformation* info, const char xbt_assert(location.address() == address, "Bad resolution of local variable %s of %s", variable, function); } -static simgrid::mc::Variable* test_global_variable( - simgrid::mc::Process& process, simgrid::mc::ObjectInformation* info, - const char* name, void* address, long byte_size) +static simgrid::mc::Variable* test_global_variable(simgrid::mc::RemoteClient& process, + simgrid::mc::ObjectInformation* info, const char* name, + void* address, long byte_size) { simgrid::mc::Variable* variable = info->find_variable(name); xbt_assert(variable, "Global variable %s was not found", name); @@ -107,7 +107,7 @@ int some_local_variable = 0; typedef struct foo {int i;} s_foo; -static void test_type_by_name(simgrid::mc::Process& process, s_foo my_foo) +static void test_type_by_name(simgrid::mc::RemoteClient& process, s_foo my_foo) { assert(process.binary_info->full_types_by_name.find("struct foo") != process.binary_info->full_types_by_name.end()); } @@ -119,7 +119,7 @@ int main(int argc, char** argv) simgrid::mc::Variable* var; simgrid::mc::Type* type; - simgrid::mc::Process process(getpid(), -1); + simgrid::mc::RemoteClient process(getpid(), -1); process.init(); test_global_variable(process, process.binary_info.get(), "some_local_variable", &some_local_variable, sizeof(int)); diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 6415bbbe5b..52445fd497 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -579,6 +579,8 @@ set(MC_SRC src/mc/remote/Channel.hpp src/mc/remote/Client.cpp src/mc/remote/Client.hpp + src/mc/remote/RemoteClient.hpp + src/mc/remote/RemoteClient.cpp src/mc/remote/RemotePtr.hpp src/mc/remote/mc_protocol.h src/mc/remote/mc_protocol.cpp @@ -599,8 +601,6 @@ set(MC_SRC src/mc/Type.hpp src/mc/Variable.hpp src/mc/mc_forward.hpp - src/mc/Process.hpp - src/mc/Process.cpp src/mc/Session.cpp src/mc/Session.hpp src/mc/mc_unw.h