+/** @brief Find the snapshoted region from a pointer
+ *
+ * @param addr Pointer
+ * @param process_index rank requesting the region
+ * */
+RegionSnapshot* Snapshot::get_region(const void* addr, int process_index) const
+{
+ size_t n = snapshot_regions_.size();
+ for (size_t i = 0; i != n; ++i) {
+ RegionSnapshot* region = snapshot_regions_[i].get();
+ if (not(region && region->contain(simgrid::mc::remote(addr))))
+ continue;
+
+ if (region->storage_type() == simgrid::mc::StorageType::Privatized) {
+#if HAVE_SMPI
+ // Use the current process index of the snapshot:
+ if (process_index == simgrid::mc::ProcessIndexDisabled)
+ process_index = privatization_index_;
+ xbt_assert(process_index >= 0, "Missing process index");
+ xbt_assert(process_index < (int)region->privatized_data().size(), "Invalid process index");
+
+ RegionSnapshot& priv_region = region->privatized_data()[process_index];
+ xbt_assert(priv_region.contain(simgrid::mc::remote(addr)));
+ return &priv_region;
+#else
+ xbt_die("Privatized region in a non SMPI build (this should not happen)");
+#endif
+ }
+
+ return region;
+ }
+
+ return nullptr;
+}
+
+/** @brief Find the snapshoted region from a pointer, with a hinted_region */
+RegionSnapshot* Snapshot::get_region(const void* addr, int process_index, RegionSnapshot* hinted_region) const
+{
+ if (hinted_region->contain(simgrid::mc::remote(addr)))
+ return hinted_region;
+ else
+ return get_region(addr, process_index);
+}