// Read each page:
while (simgrid::mc::mmu::split((std::uintptr_t)addr).first != page_end) {
- void* snapshot_addr = mc_translate_address_region_chunked((uintptr_t)addr, region);
+ void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, region);
void* next_page = (void*)simgrid::mc::mmu::join(simgrid::mc::mmu::split((std::uintptr_t)addr).first + 1, 0);
size_t readable = (char*)next_page - (char*)addr;
memcpy(dest, snapshot_addr, readable);
}
// Read the end:
- void* snapshot_addr = mc_translate_address_region_chunked((uintptr_t)addr, region);
+ void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, region);
memcpy(dest, snapshot_addr, size);
return target;
// Using alloca() for large allocations may trigger stack overflow:
// use malloc if the buffer is too big.
bool stack_alloc = size < 64;
- void* buffer1a = nullptr;
- void* buffer2a = nullptr;
- if (region1 != nullptr && region1->storage_type() != simgrid::mc::StorageType::Flat)
- buffer1a = stack_alloc ? alloca(size) : ::operator new(size);
- if (region2 != nullptr && region2->storage_type() != simgrid::mc::StorageType::Flat)
- buffer2a = stack_alloc ? alloca(size) : ::operator new(size);
+ void* buffer1a = stack_alloc ? alloca(size) : ::operator new(size);
+ void* buffer2a = stack_alloc ? alloca(size) : ::operator new(size);
const void* buffer1 = MC_region_read(region1, buffer1a, addr1, size);
const void* buffer2 = MC_region_read(region2, buffer2a, addr2, size);
int res;
add_region(simgrid::mc::RegionType::Heap, nullptr, start_heap, start_heap, (char*)end_heap - (char*)start_heap);
heap_bytes_used_ = mmalloc_get_bytes_used_remote(heap->heaplimit, process->get_malloc_info());
- privatization_index_ = simgrid::mc::ProcessIndexMissing;
-
-#if HAVE_SMPI
- if (mc_model_checker->process().privatized() && MC_smpi_process_count())
- // snapshot->privatization_index = smpi_loaded_page
- mc_model_checker->process().read_variable("smpi_loaded_page", &privatization_index_, sizeof(privatization_index_));
-#endif
}
/** @brief Checks whether the variable is in scope for a given IP.
return true;
}
-static void fill_local_variables_values(mc_stack_frame_t stack_frame, simgrid::mc::Frame* scope, int process_index,
+static void fill_local_variables_values(mc_stack_frame_t stack_frame, simgrid::mc::Frame* scope,
std::vector<s_local_variable_t>& result)
{
if (not scope || not scope->range.contain(stack_frame->ip))
else if (not current_variable.location_list.empty()) {
simgrid::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(), process_index);
+ (void*)stack_frame->frame_base, &mc_model_checker->process());
if (not location.in_memory())
xbt_die("Cannot handle non-address variable");
// Recursive processing of nested scopes:
for (simgrid::mc::Frame& nested_scope : scope->scopes)
- fill_local_variables_values(stack_frame, &nested_scope, process_index, result);
+ fill_local_variables_values(stack_frame, &nested_scope, result);
}
-static std::vector<s_local_variable_t> get_local_variables_values(std::vector<s_mc_stack_frame_t>& stack_frames,
- int process_index)
+static std::vector<s_local_variable_t> get_local_variables_values(std::vector<s_mc_stack_frame_t>& stack_frames)
{
std::vector<s_local_variable_t> variables;
for (s_mc_stack_frame_t& stack_frame : stack_frames)
- fill_local_variables_values(&stack_frame, stack_frame.frame, process_index, variables);
+ fill_local_variables_values(&stack_frame, stack_frame.frame, variables);
return variables;
}
// Read the context from remote process:
unw_context_t context;
- mc_model_checker->process().read_bytes(&context, sizeof(context), remote(stack.context));
+ process->read_bytes(&context, sizeof(context), remote(stack.context));
- st.context.initialize(&mc_model_checker->process(), &context);
+ st.context.initialize(process, &context);
st.stack_frames = unwind_stack_frames(&st.context);
- st.local_variables = get_local_variables_values(st.stack_frames, stack.process_index);
- st.process_index = stack.process_index;
+ st.local_variables = get_local_variables_values(st.stack_frames);
unw_word_t sp = st.stack_frames[0].sp;
xbt_assert(snapshot->process());
// Copy the memory:
- for (auto const& region : mc_model_checker->process().ignored_regions()) {
+ for (auto const& region : snapshot->process()->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),
- simgrid::mc::ProcessIndexDisabled);
+ snapshot->process()->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 : mc_model_checker->process().ignored_regions())
+ for (auto const& region : snapshot->process()->ignored_regions())
snapshot->process()->clear_bytes(remote(region.addr), region.size);
}
static void snapshot_ignore_restore(simgrid::mc::Snapshot* snapshot)
, num_state_(_num_state)
, heap_bytes_used_(0)
, enabled_processes_()
- , privatization_index_(0)
, hash_(0)
{
for (auto const& p : process->actors())
- enabled_processes_.insert(p.copy.getBuffer()->get_pid());
+ enabled_processes_.insert(p.copy.get_buffer()->get_pid());
snapshot_handle_ignore(this);
else if (type == simgrid::mc::RegionType::Heap)
xbt_assert(not object_info, "Unexpected object info for heap region.");
- simgrid::mc::RegionSnapshot* region;
-#if HAVE_SMPI
- const bool privatization_aware = object_info && mc_model_checker->process().privatized(*object_info);
- if (privatization_aware && MC_smpi_process_count())
- region = new RegionPrivatized(type, start_addr, permanent_addr, size);
- else
-#endif
- region = simgrid::mc::region(type, start_addr, permanent_addr, size);
-
+ simgrid::mc::RegionSnapshot* region = simgrid::mc::region(type, start_addr, permanent_addr, size);
region->object_info(object_info);
snapshot_regions_.push_back(std::unique_ptr<simgrid::mc::RegionSnapshot>(std::move(region)));
}
-const void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, int process_index,
- ReadOptions options) const
+const void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, ReadOptions options) const
{
- RegionSnapshot* region = this->get_region((void*)address.address(), process_index);
+ RegionSnapshot* region = this->get_region((void*)address.address());
if (region) {
const void* res = MC_region_read(region, buffer, (void*)address.address(), size);
if (buffer == res || options & ReadOptions::lazy())
return buffer;
}
} else
- return this->process()->read_bytes(buffer, size, address, process_index, options);
+ return this->process()->read_bytes(buffer, size, address, options);
}
/** @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
+RegionSnapshot* Snapshot::get_region(const void* addr) const
{
size_t n = snapshot_regions_.size();
for (size_t i = 0; i != n; ++i) {
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].get();
- 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;
}
}
/** @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
+RegionSnapshot* Snapshot::get_region(const void* addr, RegionSnapshot* hinted_region) const
{
if (hinted_region->contain(simgrid::mc::remote(addr)))
return hinted_region;
else
- return get_region(addr, process_index);
+ return get_region(addr);
}
void Snapshot::restore(RemoteClient* process)
region.get()->restore();
}
- // Fix the privatization mmap if needed
- if (privatization_index_ >= 0) {
- s_mc_message_restore_t message{MC_MESSAGE_RESTORE, privatization_index_};
- process->getChannel().send(message);
- }
-
snapshot_ignore_restore(this);
process->clear_cache();
}