From: Arnaud Giersch Date: Thu, 11 Jul 2019 14:44:13 +0000 (+0200) Subject: mc: const seems wrong here. X-Git-Tag: v3.24~310 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/51944fbb208aeba94040ac47118d748f2cb5c854 mc: const seems wrong here. --- diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index b913fae342..d5fd2eb32e 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -1284,10 +1284,12 @@ bool snapshot_equal(Snapshot* s1, Snapshot* s2) } /* Init heap information used in heap comparison algorithm */ - xbt_mheap_t heap1 = (xbt_mheap_t)s1->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc), - remote(process.heap_address), simgrid::mc::ReadOptions::lazy()); - xbt_mheap_t heap2 = (xbt_mheap_t)s2->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc), - remote(process.heap_address), simgrid::mc::ReadOptions::lazy()); + xbt_mheap_t heap1 = + static_cast(s1->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc), + remote(process.heap_address), simgrid::mc::ReadOptions::lazy())); + xbt_mheap_t heap2 = + static_cast(s2->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc), + remote(process.heap_address), simgrid::mc::ReadOptions::lazy())); if (state_comparator.initHeapInformation(heap1, heap2, &s1->to_ignore_, &s2->to_ignore_) == -1) { XBT_VERB("(%d - %d) Different heap information", s1->num_state_, s2->num_state_); return false; diff --git a/src/mc/remote/RemoteClient.cpp b/src/mc/remote/RemoteClient.cpp index 4412b4fd0c..b90b22f2dc 100644 --- a/src/mc/remote/RemoteClient.cpp +++ b/src/mc/remote/RemoteClient.cpp @@ -425,8 +425,7 @@ std::string RemoteClient::read_string(RemotePtr address) const } } -const void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr address, - ReadOptions /*options*/) const +void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr address, ReadOptions /*options*/) const { 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_); diff --git a/src/mc/remote/RemoteClient.hpp b/src/mc/remote/RemoteClient.hpp index b786aeabe2..174517df1f 100644 --- a/src/mc/remote/RemoteClient.hpp +++ b/src/mc/remote/RemoteClient.hpp @@ -80,8 +80,8 @@ public: RemoteClient& operator=(RemoteClient&&) = delete; // Read memory: - const void* read_bytes(void* buffer, std::size_t size, RemotePtr address, - ReadOptions options = ReadOptions::none()) const override; + void* read_bytes(void* buffer, std::size_t size, RemotePtr address, + 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 diff --git a/src/mc/sosp/Region.cpp b/src/mc/sosp/Region.cpp index 4eb5d6ffb0..8c27e7ce6c 100644 --- a/src/mc/sosp/Region.cpp +++ b/src/mc/sosp/Region.cpp @@ -55,7 +55,7 @@ static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, simgr return (char*)snapshot_page + offset; } -const void* Region::read(void* target, const void* addr, std::size_t size) +void* Region::read(void* target, const void* addr, std::size_t size) { xbt_assert(contain(simgrid::mc::remote(addr)), "Trying to read out of the region boundary."); diff --git a/src/mc/sosp/Region.hpp b/src/mc/sosp/Region.hpp index 2ee7e5272a..8293df6b5c 100644 --- a/src/mc/sosp/Region.hpp +++ b/src/mc/sosp/Region.hpp @@ -69,7 +69,7 @@ public: * @param size Size of the data to read in bytes * @return Pointer where the data is located (either target buffer or original location) */ - const void* read(void* target, const void* addr, std::size_t size); + void* read(void* target, const void* addr, std::size_t size); }; } // namespace mc diff --git a/src/mc/sosp/Snapshot.cpp b/src/mc/sosp/Snapshot.cpp index 141d14a9b1..bc32ba67a4 100644 --- a/src/mc/sosp/Snapshot.cpp +++ b/src/mc/sosp/Snapshot.cpp @@ -235,11 +235,11 @@ void Snapshot::add_region(RegionType type, ObjectInformation* object_info, void* snapshot_regions_.push_back(std::unique_ptr(std::move(region))); } -const void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr address, ReadOptions options) const +void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr address, ReadOptions options) const { Region* region = this->get_region((void*)address.address()); if (region) { - const void* res = region->read(buffer, (void*)address.address(), size); + void* res = region->read(buffer, (void*)address.address(), size); if (buffer == res || options & ReadOptions::lazy()) return res; else { diff --git a/src/mc/sosp/Snapshot.hpp b/src/mc/sosp/Snapshot.hpp index a81dfcb665..45b00dc172 100644 --- a/src/mc/sosp/Snapshot.hpp +++ b/src/mc/sosp/Snapshot.hpp @@ -63,8 +63,8 @@ public: /* Initialization */ /* Regular use */ - const void* read_bytes(void* buffer, std::size_t size, RemotePtr address, - ReadOptions options = ReadOptions::none()) const override; + void* read_bytes(void* buffer, std::size_t size, RemotePtr address, + ReadOptions options = ReadOptions::none()) const override; Region* get_region(const void* addr) const; Region* get_region(const void* addr, Region* hinted_region) const; void restore(RemoteClient* process);