X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/330c412486ad86896ffff897a620c2d253f32386..7bf4da31d5d3b1940d0166da655136ccf6af8148:/src/mc/sosp/Snapshot.cpp diff --git a/src/mc/sosp/Snapshot.cpp b/src/mc/sosp/Snapshot.cpp index fb8e06f1a1..5393c8fcdf 100644 --- a/src/mc/sosp/Snapshot.cpp +++ b/src/mc/sosp/Snapshot.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2014-2020. 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. */ @@ -16,7 +16,7 @@ namespace mc { /************************************* Take Snapshot ************************************/ /****************************************************************************************/ -void Snapshot::snapshot_regions(RemoteClient* process) +void Snapshot::snapshot_regions(RemoteSimulation* process) { snapshot_regions_.clear(); @@ -40,7 +40,7 @@ void Snapshot::snapshot_regions(RemoteClient* process) * @param ip Instruction pointer * @return true if the variable is valid * */ -static bool valid_variable(simgrid::mc::Variable* var, simgrid::mc::Frame* scope, const void* ip) +static bool valid_variable(const simgrid::mc::Variable* var, simgrid::mc::Frame* scope, const void* ip) { // The variable is not yet valid: if (scope->range.begin() + var->start_scope > (std::uint64_t)ip) @@ -55,7 +55,7 @@ static void fill_local_variables_values(mc_stack_frame_t stack_frame, Frame* sco if (not scope || not scope->range.contain(stack_frame->ip)) return; - for (Variable& current_variable : scope->variables) { + for (const Variable& current_variable : scope->variables) { if (not valid_variable(¤t_variable, scope, (void*)stack_frame->ip)) continue; @@ -71,7 +71,7 @@ static void fill_local_variables_values(mc_stack_frame_t stack_frame, Frame* sco else if (not current_variable.location_list.empty()) { dwarf::Location location = simgrid::dwarf::resolve(current_variable.location_list, current_variable.object_info, &(stack_frame->unw_cursor), (void*)stack_frame->frame_base, - &mc_model_checker->process()); + &mc_model_checker->get_remote_simulation()); if (not location.in_memory()) xbt_die("Cannot handle non-address variable"); @@ -97,14 +97,14 @@ static std::vector get_local_variables_values(std::vector unwind_stack_frames(UnwindContext* stack_context) { - const RemoteClient* process = &mc_model_checker->process(); + const RemoteSimulation* process = &mc_model_checker->get_remote_simulation(); std::vector result; unw_cursor_t c = stack_context->cursor(); // TODO, check condition check (unw_init_local==0 means end of frame) - while (1) { + while (true) { s_mc_stack_frame_t stack_frame; stack_frame.unw_cursor = c; @@ -149,7 +149,7 @@ static std::vector unwind_stack_frames(UnwindContext* stack_ return result; } -void Snapshot::snapshot_stacks(RemoteClient* process) +void Snapshot::snapshot_stacks(RemoteSimulation* process) { for (auto const& stack : process->stack_areas()) { s_mc_snapshot_stack_t st; @@ -174,30 +174,31 @@ void Snapshot::snapshot_stacks(RemoteClient* process) static void snapshot_handle_ignore(Snapshot* snapshot) { - xbt_assert(snapshot->process()); + xbt_assert(snapshot->get_remote_simulation()); // Copy the memory: - for (auto const& region : snapshot->process()->ignored_regions()) { + for (auto const& region : snapshot->get_remote_simulation()->ignored_regions()) { s_mc_snapshot_ignored_data_t ignored_data; ignored_data.start = (void*)region.addr; ignored_data.data.resize(region.size); // TODO, we should do this once per privatization segment: - snapshot->process()->read_bytes(ignored_data.data.data(), region.size, remote(region.addr)); + snapshot->get_remote_simulation()->read_bytes(ignored_data.data.data(), region.size, remote(region.addr)); snapshot->ignored_data_.push_back(std::move(ignored_data)); } // Zero the memory: - for (auto const& region : snapshot->process()->ignored_regions()) - snapshot->process()->clear_bytes(remote(region.addr), region.size); + for (auto const& region : snapshot->get_remote_simulation()->ignored_regions()) + snapshot->get_remote_simulation()->clear_bytes(remote(region.addr), region.size); } -static void snapshot_ignore_restore(simgrid::mc::Snapshot* snapshot) +static void snapshot_ignore_restore(const simgrid::mc::Snapshot* snapshot) { for (auto const& ignored_data : snapshot->ignored_data_) - snapshot->process()->write_bytes(ignored_data.data.data(), ignored_data.data.size(), remote(ignored_data.start)); + snapshot->get_remote_simulation()->write_bytes(ignored_data.data.data(), ignored_data.data.size(), + remote(ignored_data.start)); } -Snapshot::Snapshot(int num_state, RemoteClient* process) : AddressSpace(process), num_state_(num_state) +Snapshot::Snapshot(int num_state, RemoteSimulation* process) : AddressSpace(process), num_state_(num_state) { XBT_DEBUG("Taking snapshot %i", num_state); @@ -226,14 +227,14 @@ void Snapshot::add_region(RegionType type, ObjectInformation* object_info, void* else if (type == RegionType::Heap) xbt_assert(not object_info, "Unexpected object info for heap region."); - Region* region = new Region(type, start_addr, size); + auto* region = new Region(type, start_addr, size); region->object_info(object_info); snapshot_regions_.push_back(std::unique_ptr(std::move(region))); } void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr address, ReadOptions options) const { - Region* region = this->get_region((void*)address.address()); + const Region* region = this->get_region((void*)address.address()); if (region) { void* res = region->read(buffer, (void*)address.address(), size); if (buffer == res || options & ReadOptions::lazy()) @@ -243,7 +244,7 @@ void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr addre return buffer; } } else - return this->process()->read_bytes(buffer, size, address, options); + return this->get_remote_simulation()->read_bytes(buffer, size, address, options); } /** @brief Find the snapshotted region from a pointer * @@ -272,7 +273,7 @@ Region* Snapshot::get_region(const void* addr, Region* hinted_region) const return get_region(addr); } -void Snapshot::restore(RemoteClient* process) +void Snapshot::restore(RemoteSimulation* process) const { XBT_DEBUG("Restore snapshot %i", num_state_);