#define XBT_ALWAYS_INLINE inline __attribute__((always_inline))
#endif
-/** Cache the size of a memory page for the current system. */
+/** Size of a memory page for the current system. */
extern "C" int xbt_pagesize;
-/** Cache the number of bits of addresses inside a given page, log2(xbt_pagesize). */
+/** Number of bits of addresses inside a given page, log2(xbt_pagesize). */
extern "C" int xbt_pagebits;
namespace simgrid {
// TODO, do not depend on xbt_pagesize/xbt_pagebits but our own chunk size
namespace mmu {
-static int chunkSize()
+static int chunk_size()
{
return xbt_pagesize;
}
* @param size Byte size
* @return Number of memory pages
*/
-static XBT_ALWAYS_INLINE std::size_t chunkCount(std::size_t size)
+static XBT_ALWAYS_INLINE std::size_t chunk_count(std::size_t size)
{
size_t page_count = size >> xbt_pagebits;
if (size & (xbt_pagesize - 1))
return {offset >> xbt_pagebits, offset & (xbt_pagesize - 1)};
}
-/** Merge chunk number and remaining offset info a global offset */
+/** Merge chunk number and remaining offset into a global offset */
static XBT_ALWAYS_INLINE std::uintptr_t join(std::size_t page, std::uintptr_t offset)
{
return ((std::uintptr_t)page << xbt_pagebits) + offset;
return join(value.first, value.second);
}
-static XBT_ALWAYS_INLINE bool sameChunk(std::uintptr_t a, std::uintptr_t b)
+static XBT_ALWAYS_INLINE bool same_chunk(std::uintptr_t a, std::uintptr_t b)
{
return (a >> xbt_pagebits) == (b >> xbt_pagebits);
}
case simgrid::mc::StorageType::Chunked:
xbt_assert(((region->permanent_address().address()) & (xbt_pagesize - 1)) == 0, "Not at the beginning of a page");
- xbt_assert(simgrid::mc::mmu::chunkCount(region->size()) == region->page_data().page_count());
+ xbt_assert(simgrid::mc::mmu::chunk_count(region->size()) == region->page_data().page_count());
for (size_t i = 0; i != region->page_data().page_count(); ++i) {
void* target_page =
}
#endif
-static void add_region(int index, simgrid::mc::Snapshot* snapshot, simgrid::mc::RegionType type,
+static void add_region(simgrid::mc::Snapshot* snapshot, simgrid::mc::RegionType type,
simgrid::mc::ObjectInformation* object_info, void* start_addr, void* permanent_addr,
std::size_t size)
{
region = simgrid::mc::region(type, start_addr, permanent_addr, size);
region.object_info(object_info);
- snapshot->snapshot_regions[index] =
- std::unique_ptr<simgrid::mc::RegionSnapshot>(new simgrid::mc::RegionSnapshot(std::move(region)));
+ snapshot->snapshot_regions.push_back(
+ std::unique_ptr<simgrid::mc::RegionSnapshot>(new simgrid::mc::RegionSnapshot(std::move(region))));
}
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);
- int i = 0;
- for (auto const& object_info : process->object_infos) {
- add_region(i, snapshot, simgrid::mc::RegionType::Data, object_info.get(), object_info->start_rw,
- object_info->start_rw, object_info->end_rw - object_info->start_rw);
- ++i;
- }
+ snapshot->snapshot_regions.clear();
+
+ for (auto const& object_info : process->object_infos)
+ add_region(snapshot, simgrid::mc::RegionType::Data, object_info.get(), object_info->start_rw, object_info->start_rw,
+ object_info->end_rw - object_info->start_rw);
xbt_mheap_t heap = process->get_heap();
void* start_heap = heap->base;
void* end_heap = heap->breakval;
- add_region(n, snapshot, simgrid::mc::RegionType::Heap, nullptr, start_heap, start_heap,
+ add_region(snapshot, simgrid::mc::RegionType::Heap, nullptr, start_heap, start_heap,
(char*)end_heap - (char*)start_heap);
snapshot->heap_bytes_used = mmalloc_get_bytes_used_remote(heap->heaplimit, process->get_malloc_info());
snapshot->stacks = take_snapshot_stacks(snapshot.get());
if (_sg_mc_hash)
snapshot->hash = simgrid::mc::hash(*snapshot);
- else
- snapshot->hash = 0;
- } else
- snapshot->hash = 0;
+ }
snapshot_ignore_restore(snapshot.get());
return snapshot;
std::vector<std::size_t> stack_sizes;
std::vector<s_mc_snapshot_stack_t> stacks;
std::vector<simgrid::mc::IgnoredHeapRegion> to_ignore;
- std::uint64_t hash;
+ std::uint64_t hash = 0;
std::vector<s_mc_snapshot_ignored_data_t> ignored_data;
};
} // namespace mc
case simgrid::mc::StorageType::Chunked: {
// Last byte of the region:
void* end = (char*)addr + size - 1;
- if (simgrid::mc::mmu::sameChunk((std::uintptr_t)addr, (std::uintptr_t)end)) {
+ if (simgrid::mc::mmu::same_chunk((std::uintptr_t)addr, (std::uintptr_t)end)) {
// The memory is contained in a single page:
return mc_translate_address_region_chunked((uintptr_t)addr, region);
}