From c9e3badfcca0d44e112171cefd237ed3f0ae01ca Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 7 Dec 2017 16:35:14 +0100 Subject: [PATCH] Add explicit keyword to simgrid::mc::RemotePtr constructor. --- src/mc/RegionSnapshot.cpp | 4 ++-- src/mc/checker/CommunicationDeterminismChecker.cpp | 10 +++++----- src/mc/compare.cpp | 4 ++-- src/mc/mc_comm_pattern.cpp | 2 +- src/mc/mc_smx.cpp | 7 +++---- src/mc/remote/RemoteClient.cpp | 2 +- src/mc/remote/RemoteClient.hpp | 2 +- src/mc/remote/RemotePtr.hpp | 12 +++++++++--- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/mc/RegionSnapshot.cpp b/src/mc/RegionSnapshot.cpp index 69a40e1300..4ebfbe1729 100644 --- a/src/mc/RegionSnapshot.cpp +++ b/src/mc/RegionSnapshot.cpp @@ -137,8 +137,8 @@ RegionSnapshot sparse_region(RegionType region_type, "Not at the beginning of a page"); size_t page_count = simgrid::mc::mmu::chunkCount(size); - simgrid::mc::ChunkedData page_data( - mc_model_checker->page_store(), *process, permanent_addr, page_count); + simgrid::mc::ChunkedData page_data(mc_model_checker->page_store(), *process, RemotePtr(permanent_addr), + page_count); simgrid::mc::RegionSnapshot region( region_type, start_addr, permanent_addr, size); diff --git a/src/mc/checker/CommunicationDeterminismChecker.cpp b/src/mc/checker/CommunicationDeterminismChecker.cpp index 955a2f2cf1..4fedf30dda 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.cpp +++ b/src/mc/checker/CommunicationDeterminismChecker.cpp @@ -194,13 +194,13 @@ void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_sim static_cast(temp_synchro.getBuffer()); char* remote_name = mc_model_checker->process().read( - (std::uint64_t)(synchro->mbox ? &synchro->mbox->name_ : &synchro->mbox_cpy->name_)); - pattern->rdv = mc_model_checker->process().read_string(remote_name); + RemotePtr((uint64_t)(synchro->mbox ? &synchro->mbox->name_ : &synchro->mbox_cpy->name_))); + pattern->rdv = mc_model_checker->process().read_string(RemotePtr(remote_name)); pattern->src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(synchro->src_proc))->pid; pattern->src_host = MC_smx_actor_get_host_name(issuer); - simgrid::smpi::Request mpi_request = - mc_model_checker->process().read((std::uint64_t)simcall_comm_isend__get__data(request)); + simgrid::smpi::Request mpi_request = mc_model_checker->process().read( + RemotePtr((std::uint64_t)simcall_comm_isend__get__data(request))); pattern->tag = mpi_request.tag(); if (synchro->src_buff != nullptr) { @@ -239,7 +239,7 @@ void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_sim mc_model_checker->process().read( &remote_name, remote(comm->mbox ? &simgrid::xbt::string::to_string_data(comm->mbox->name_).data : &simgrid::xbt::string::to_string_data(comm->mbox_cpy->name_).data)); - pattern->rdv = mc_model_checker->process().read_string(remote_name); + pattern->rdv = mc_model_checker->process().read_string(RemotePtr(remote_name)); pattern->dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->dst_proc))->pid; pattern->dst_host = MC_smx_actor_get_host_name(issuer); } else diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index ab4bc29dc1..4cdf76a96c 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -344,9 +344,9 @@ int mmalloc_compare_heap( // This is in snapshot do not use them directly: const malloc_info* heapinfos1 = snapshot1->read( - (std::uint64_t)heapinfo_address, simgrid::mc::ProcessIndexMissing); + RemotePtr((std::uint64_t)heapinfo_address), simgrid::mc::ProcessIndexMissing); const malloc_info* heapinfos2 = snapshot2->read( - (std::uint64_t)heapinfo_address, simgrid::mc::ProcessIndexMissing); + RemotePtr((std::uint64_t)heapinfo_address), simgrid::mc::ProcessIndexMissing); while (i1 < state.heaplimit) { diff --git a/src/mc/mc_comm_pattern.cpp b/src/mc/mc_comm_pattern.cpp index 48608a8e20..3e7a72936e 100644 --- a/src/mc/mc_comm_pattern.cpp +++ b/src/mc/mc_comm_pattern.cpp @@ -85,7 +85,7 @@ void MC_handle_comm_pattern( case MC_CALL_TYPE_WAIT: case MC_CALL_TYPE_WAITANY: { - simgrid::mc::RemotePtr comm_addr = nullptr; + simgrid::mc::RemotePtr comm_addr{nullptr}; if (call_type == MC_CALL_TYPE_WAIT) comm_addr = remote(static_cast(simcall_comm_wait__getraw__comm(req))); diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index bcdec8bd9b..9cc4241903 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -41,13 +41,13 @@ static void MC_process_refresh_simix_actor_dynar(simgrid::mc::RemoteClient* proc process->read_bytes(&dynar, sizeof(dynar), remote_dynar); smx_actor_t* data = static_cast(::operator new(dynar.elmsize * dynar.used)); - process->read_bytes(data, dynar.elmsize * dynar.used, dynar.data); + process->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 = data[i]; + info.address = simgrid::mc::RemotePtr(data[i]); info.hostname = nullptr; process->read_bytes(&info.copy, sizeof(info.copy), remote(data[i])); target.push_back(std::move(info)); @@ -71,8 +71,7 @@ void RemoteClient::refresh_simix() static_assert(sizeof(simix_global) == sizeof(simgrid::simix::Global*), "Bad size for simix_global"); - RemotePtr simix_global_p = - this->read_variable("simix_global"); + RemotePtr simix_global_p{this->read_variable("simix_global")}; // simix_global = REMOTE(*simix_global) Remote simix_global = diff --git a/src/mc/remote/RemoteClient.cpp b/src/mc/remote/RemoteClient.cpp index 0172d7064e..7f8877f1cb 100644 --- a/src/mc/remote/RemoteClient.cpp +++ b/src/mc/remote/RemoteClient.cpp @@ -443,7 +443,7 @@ const void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr const& info = this->find_object_info_rw((void*)address.address()); + std::shared_ptr const& info = this->find_object_info_rw(address); // Segment overlap is not handled. #if HAVE_SMPI if (info.get() && this->privatized(*info)) { diff --git a/src/mc/remote/RemoteClient.hpp b/src/mc/remote/RemoteClient.hpp index 1f3809efb5..b681e59b31 100644 --- a/src/mc/remote/RemoteClient.hpp +++ b/src/mc/remote/RemoteClient.hpp @@ -44,7 +44,7 @@ namespace mc { class ActorInformation { public: /** MCed address of the process */ - RemotePtr address = nullptr; + RemotePtr address{nullptr}; Remote copy; /** Hostname (owned by `mc_modelchecker->hostnames`) */ diff --git a/src/mc/remote/RemotePtr.hpp b/src/mc/remote/RemotePtr.hpp index d92eb7a2a5..d6d763b562 100644 --- a/src/mc/remote/RemotePtr.hpp +++ b/src/mc/remote/RemotePtr.hpp @@ -81,9 +81,10 @@ template class RemotePtr { public: RemotePtr() : address_(0) {} - RemotePtr(std::uint64_t address) : address_(address) {} - RemotePtr(T* address) : address_((std::uintptr_t)address) {} - RemotePtr(Remote p) : RemotePtr(*p.getBuffer()) {} + explicit RemotePtr(std::nullptr_t) : address_(0) {} + explicit RemotePtr(std::uint64_t address) : address_(address) {} + explicit RemotePtr(T* address) : address_((std::uintptr_t)address) {} + explicit RemotePtr(Remote p) : RemotePtr(*p.getBuffer()) {} std::uint64_t address() const { return address_; } /** Turn into a local pointer @@ -94,6 +95,11 @@ public: operator bool() const { return address_; } bool operator!() const { return not address_; } operator RemotePtr() const { return RemotePtr(address_); } + RemotePtr& operator=(std::nullptr_t) + { + address_ = 0; + return *this; + } RemotePtr operator+(std::uint64_t n) const { return RemotePtr(address_ + n * sizeof(T)); } RemotePtr operator-(std::uint64_t n) const { return RemotePtr(address_ - n * sizeof(T)); } RemotePtr& operator+=(std::uint64_t n) -- 2.20.1