include src/mc/remote/Channel.hpp
include src/mc/remote/CheckerSide.cpp
include src/mc/remote/CheckerSide.hpp
-include src/mc/remote/RemoteProcess.cpp
-include src/mc/remote/RemoteProcess.hpp
include src/mc/remote/RemotePtr.hpp
include src/mc/remote/mc_protocol.h
include src/mc/sosp/ChunkedData.cpp
include src/mc/sosp/PageStore_test.cpp
include src/mc/sosp/Region.cpp
include src/mc/sosp/Region.hpp
+include src/mc/sosp/RemoteProcessMemory.cpp
+include src/mc/sosp/RemoteProcessMemory.hpp
include src/mc/sosp/Snapshot.cpp
include src/mc/sosp/Snapshot.hpp
include src/mc/sosp/Snapshot_test.cpp
*/
class AddressSpace {
private:
- RemoteProcess* remote_process_;
+ RemoteProcessMemory* remote_process_memory_;
public:
- explicit AddressSpace(RemoteProcess* process) : remote_process_(process) {}
+ explicit AddressSpace(RemoteProcessMemory* process) : remote_process_memory_(process) {}
virtual ~AddressSpace() = default;
/** The process of this address space
*
* This is where we can get debug information, memory layout, etc.
*/
- simgrid::mc::RemoteProcess* get_remote_process() const { return remote_process_; }
+ simgrid::mc::RemoteProcessMemory* get_remote_process_memory() const { return remote_process_memory_; }
/** Read data from the address space
*
#include "src/mc/mc_config.hpp"
#include "src/mc/mc_exit.hpp"
#include "src/mc/mc_private.hpp"
-#include "src/mc/remote/RemoteProcess.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
#include "src/mc/transition/TransitionComm.hpp"
#include "xbt/automaton.hpp"
#include "xbt/system_error.hpp"
namespace simgrid::mc {
-ModelChecker::ModelChecker(std::unique_ptr<RemoteProcess> remote_simulation, int sockfd)
- : checker_side_(sockfd), remote_process_(std::move(remote_simulation))
+ModelChecker::ModelChecker(std::unique_ptr<RemoteProcessMemory> remote_memory, int sockfd)
+ : checker_side_(sockfd), remote_process_memory_(std::move(remote_memory))
{
}
int status;
// The model-checked process SIGSTOP itself to signal it's ready:
- const pid_t pid = remote_process_->pid();
+ const pid_t pid = remote_process_memory_->pid();
xbt_assert(waitpid(pid, &status, WAITPID_CHECKED_FLAGS) == pid && WIFSTOPPED(status) && WSTOPSIG(status) == SIGSTOP,
"Could not wait model-checked process");
void ModelChecker::setup_ignore()
{
- const RemoteProcess& process = this->get_remote_process();
+ const RemoteProcessMemory& process = this->get_remote_process_memory();
for (auto const& [var, frame] : ignored_local_variables)
process.ignore_local_variable(var, frame);
{
XBT_DEBUG("Shutting down model-checker");
- RemoteProcess& process = get_remote_process();
+ RemoteProcessMemory& process = get_remote_process_memory();
if (process.running()) {
XBT_DEBUG("Killing process");
finalize_app(true);
{
if (checker_side_.get_channel().send(MessageType::CONTINUE) != 0)
throw xbt::errno_error();
- remote_process_->clear_cache();
+ remote_process_memory_->clear_cache();
}
static void MC_report_crash(Exploration* explorer, int status)
XBT_INFO("Stack trace not displayed because you passed --log=no_loc");
} else {
XBT_INFO("Stack trace:");
- explorer->get_remote_app().get_remote_process().dump_stack();
+ explorer->get_remote_app().get_remote_process_memory().dump_stack();
}
}
}
xbt_assert(size == sizeof(message), "Broken message. Got %d bytes instead of %d.", (int)size, (int)sizeof(message));
memcpy(&message, buffer, sizeof(message));
- get_remote_process().init(message.mmalloc_default_mdp);
+ get_remote_process_memory().init(message.mmalloc_default_mdp);
break;
}
region.fragment = message.fragment;
region.address = message.address;
region.size = message.size;
- get_remote_process().ignore_heap(region);
+ get_remote_process_memory().ignore_heap(region);
break;
}
s_mc_message_ignore_memory_t message;
xbt_assert(size == sizeof(message), "Broken message");
memcpy(&message, buffer, sizeof(message));
- get_remote_process().unignore_heap((void*)(std::uintptr_t)message.addr, message.size);
+ get_remote_process_memory().unignore_heap((void*)(std::uintptr_t)message.addr, message.size);
break;
}
s_mc_message_ignore_memory_t message;
xbt_assert(size == sizeof(message), "Broken message");
memcpy(&message, buffer, sizeof(message));
- this->get_remote_process().ignore_region(message.addr, message.size);
+ this->get_remote_process_memory().ignore_region(message.addr, message.size);
break;
}
s_mc_message_stack_region_t message;
xbt_assert(size == sizeof(message), "Broken message");
memcpy(&message, buffer, sizeof(message));
- this->get_remote_process().stack_areas().push_back(message.stack_region);
+ this->get_remote_process_memory().stack_areas().push_back(message.stack_region);
} break;
case MessageType::REGISTER_SYMBOL: {
xbt_assert(not message.callback, "Support for client-side function proposition is not implemented.");
XBT_DEBUG("Received symbol: %s", message.name.data());
- LivenessChecker::automaton_register_symbol(get_remote_process(), message.name.data(), remote((int*)message.data));
+ LivenessChecker::automaton_register_symbol(get_remote_process_memory(), message.name.data(),
+ remote((int*)message.data));
break;
}
if (pid == -1) {
if (errno == ECHILD) {
// No more children:
- xbt_assert(not this->get_remote_process().running(), "Inconsistent state");
+ xbt_assert(not this->get_remote_process_memory().running(), "Inconsistent state");
break;
} else {
XBT_ERROR("Could not wait for pid");
}
}
- if (pid == this->get_remote_process().pid()) {
+ if (pid == this->get_remote_process_memory().pid()) {
// From PTRACE_O_TRACEEXIT:
#ifdef __linux__
if (status>>8 == (SIGTRAP | (PTRACE_EVENT_EXIT<<8))) {
unsigned long eventmsg;
- xbt_assert(ptrace(PTRACE_GETEVENTMSG, remote_process_->pid(), 0, &eventmsg) != -1, "Could not get exit status");
+ xbt_assert(ptrace(PTRACE_GETEVENTMSG, get_remote_process_memory().pid(), 0, &eventmsg) != -1,
+ "Could not get exit status");
status = static_cast<int>(eventmsg);
if (WIFSIGNALED(status)) {
MC_report_crash(exploration_, status);
- this->get_remote_process().terminate();
+ this->get_remote_process_memory().terminate();
this->exit(SIMGRID_MC_EXIT_PROGRAM_CRASH);
}
}
XBT_DEBUG("Stopped with signal %i", (int) WSTOPSIG(status));
errno = 0;
#ifdef __linux__
- ptrace(PTRACE_CONT, remote_process_->pid(), 0, WSTOPSIG(status));
+ ptrace(PTRACE_CONT, get_remote_process_memory().pid(), 0, WSTOPSIG(status));
#elif defined BSD
- ptrace(PT_CONTINUE, remote_process_->pid(), (caddr_t)1, WSTOPSIG(status));
+ ptrace(PT_CONTINUE, get_remote_process_memory().pid(), (caddr_t)1, WSTOPSIG(status));
#endif
xbt_assert(errno == 0, "Could not PTRACE_CONT");
}
else if (WIFSIGNALED(status)) {
MC_report_crash(exploration_, status);
- this->get_remote_process().terminate();
+ this->get_remote_process_memory().terminate();
this->exit(SIMGRID_MC_EXIT_PROGRAM_CRASH);
} else if (WIFEXITED(status)) {
XBT_DEBUG("Child process is over");
- this->get_remote_process().terminate();
+ this->get_remote_process_memory().terminate();
}
}
}
void ModelChecker::wait_for_requests()
{
this->resume();
- if (this->get_remote_process().running())
+ if (this->get_remote_process_memory().running())
checker_side_.dispatch();
}
m.times_considered_ = times_considered;
checker_side_.get_channel().send(m);
- this->remote_process_->clear_cache();
- if (this->remote_process_->running())
+ this->remote_process_memory_->clear_cache();
+ if (this->remote_process_memory_->running())
checker_side_.dispatch(); // The app may send messages while processing the transition
s_mc_message_simcall_execute_answer_t answer;
*/
class ModelChecker {
CheckerSide checker_side_;
- std::unique_ptr<RemoteProcess> remote_process_;
+ std::unique_ptr<RemoteProcessMemory> remote_process_memory_;
Exploration* exploration_ = nullptr;
public:
ModelChecker(ModelChecker const&) = delete;
ModelChecker& operator=(ModelChecker const&) = delete;
- explicit ModelChecker(std::unique_ptr<RemoteProcess> remote_simulation, int sockfd);
+ explicit ModelChecker(std::unique_ptr<RemoteProcessMemory> remote_simulation, int sockfd);
- RemoteProcess& get_remote_process() { return *remote_process_; }
+ RemoteProcessMemory& get_remote_process_memory() { return *remote_process_memory_; }
Channel& channel() { return checker_side_.get_channel(); }
void start();
/** @brief Save the current state */
VisitedState::VisitedState(unsigned long state_number, unsigned int actor_count, RemoteApp& remote_app)
- : heap_bytes_used_(remote_app.get_remote_process().get_remote_heap_bytes())
+ : heap_bytes_used_(remote_app.get_remote_process_memory().get_remote_heap_bytes())
, actor_count_(actor_count)
, num_(state_number)
{
xbt_assert(mc_model_checker == nullptr, "Did you manage to start the MC twice in this process?");
- auto process = std::make_unique<simgrid::mc::RemoteProcess>(pid);
+ auto process = std::make_unique<simgrid::mc::RemoteProcessMemory>(pid);
model_checker_ = std::make_unique<simgrid::mc::ModelChecker>(std::move(process), sockets[1]);
mc_model_checker = model_checker_.get();
void RemoteApp::restore_initial_state() const
{
- this->initial_snapshot_->restore(&model_checker_->get_remote_process());
+ this->initial_snapshot_->restore(&model_checker_->get_remote_process_memory());
}
unsigned long RemoteApp::get_maxpid() const
/* Get the list of actors that are ready to run at that step. Usually shorter than maxpid */
void get_actors_status(std::map<aid_t, simgrid::mc::ActorState>& whereto) const;
- /* Get the remote process */
- RemoteProcess& get_remote_process() { return model_checker_->get_remote_process(); }
+ /* Get the memory of the remote process */
+ RemoteProcessMemory& get_remote_process_memory() { return model_checker_->get_remote_process_memory(); }
PageStore& get_page_store() { return page_store_; }
};
return (pos != ignore_list->end() && pos->address == address) ? pos->size : -1;
}
-static bool is_stack(const simgrid::mc::RemoteProcess& process, const void* address)
+static bool is_stack(const simgrid::mc::RemoteProcessMemory& process, const void* address)
{
auto const& stack_areas = process.stack_areas();
return std::any_of(stack_areas.begin(), stack_areas.end(),
}
// TODO, this should depend on the snapshot?
-static bool is_block_stack(const simgrid::mc::RemoteProcess& process, int block)
+static bool is_block_stack(const simgrid::mc::RemoteProcessMemory& process, int block)
{
auto const& stack_areas = process.stack_areas();
return std::any_of(stack_areas.begin(), stack_areas.end(),
if ((heap1->heaplimit != heap2->heaplimit) || (heap1->heapsize != heap2->heapsize))
return -1;
this->heaplimit = heap1->heaplimit;
- this->std_heap_copy = *mc_model_checker->get_remote_process().get_heap();
+ this->std_heap_copy = *mc_model_checker->get_remote_process_memory().get_heap();
this->processStates[0].initHeapInformation(heap1, i1);
this->processStates[1].initHeapInformation(heap2, i2);
return 0;
xbt_die("No heap region");
}
-static bool heap_area_differ(const RemoteProcess& process, StateComparator& state, const void* area1, const void* area2,
- const Snapshot& snapshot1, const Snapshot& snapshot2, HeapLocationPairs* previous,
- Type* type, int pointer_level);
+static bool heap_area_differ(const RemoteProcessMemory& process, StateComparator& state, const void* area1,
+ const void* area2, const Snapshot& snapshot1, const Snapshot& snapshot2,
+ HeapLocationPairs* previous, Type* type, int pointer_level);
/* Compares the content of each heap fragment between the two states, at the bit level.
*
* of the liveness model-checker, as state-equality is used to detect the loops that constitute the accepting states of
* the verified property. So we could miss counter-examples to the verified property. Not good. Not good at all.
*/
-static bool mmalloc_heap_differ(const RemoteProcess& process, StateComparator& state, const Snapshot& snapshot1,
+static bool mmalloc_heap_differ(const RemoteProcessMemory& process, StateComparator& state, const Snapshot& snapshot1,
const Snapshot& snapshot2)
{
/* Check busy blocks */
* @param check_ignore
* @return true when different, false otherwise (same or unknown)
*/
-static bool heap_area_differ_without_type(const RemoteProcess& process, StateComparator& state, const void* real_area1,
- const void* real_area2, const Snapshot& snapshot1, const Snapshot& snapshot2,
- HeapLocationPairs* previous, int size, int check_ignore)
+static bool heap_area_differ_without_type(const RemoteProcessMemory& process, StateComparator& state,
+ const void* real_area1, const void* real_area2, const Snapshot& snapshot1,
+ const Snapshot& snapshot2, HeapLocationPairs* previous, int size,
+ int check_ignore)
{
const Region* heap_region1 = MC_get_heap_region(snapshot1);
const Region* heap_region2 = MC_get_heap_region(snapshot2);
* @param pointer_level
* @return true when different, false otherwise (same or unknown)
*/
-static bool heap_area_differ_with_type(const simgrid::mc::RemoteProcess& process, StateComparator& state,
+static bool heap_area_differ_with_type(const simgrid::mc::RemoteProcessMemory& process, StateComparator& state,
const void* real_area1, const void* real_area2, const Snapshot& snapshot1,
const Snapshot& snapshot2, HeapLocationPairs* previous, const Type* type,
int area_size, int check_ignore, int pointer_level)
* @param pointer_level
* @return true when different, false otherwise (same or unknown)
*/
-static bool heap_area_differ(const RemoteProcess& process, StateComparator& state, const void* area1, const void* area2,
- const Snapshot& snapshot1, const Snapshot& snapshot2, HeapLocationPairs* previous,
- Type* type, int pointer_level)
+static bool heap_area_differ(const RemoteProcessMemory& process, StateComparator& state, const void* area1,
+ const void* area2, const Snapshot& snapshot1, const Snapshot& snapshot2,
+ HeapLocationPairs* previous, Type* type, int pointer_level)
{
ssize_t block1;
ssize_t block2;
/************************** Snapshot comparison *******************************/
/******************************************************************************/
-static bool areas_differ_with_type(const simgrid::mc::RemoteProcess& process, simgrid::mc::StateComparator& state,
+static bool areas_differ_with_type(const simgrid::mc::RemoteProcessMemory& process, simgrid::mc::StateComparator& state,
const void* real_area1, const simgrid::mc::Snapshot& snapshot1,
simgrid::mc::Region* region1, const void* real_area2,
const simgrid::mc::Snapshot& snapshot2, simgrid::mc::Region* region2,
return false;
}
-static bool global_variables_differ(const simgrid::mc::RemoteProcess& process, simgrid::mc::StateComparator& state,
+static bool global_variables_differ(const simgrid::mc::RemoteProcessMemory& process,
+ simgrid::mc::StateComparator& state,
const simgrid::mc::ObjectInformation* object_info, simgrid::mc::Region* r1,
simgrid::mc::Region* r2, const simgrid::mc::Snapshot& snapshot1,
const simgrid::mc::Snapshot& snapshot2)
return false;
}
-static bool local_variables_differ(const simgrid::mc::RemoteProcess& process, simgrid::mc::StateComparator& state,
+static bool local_variables_differ(const simgrid::mc::RemoteProcessMemory& process, simgrid::mc::StateComparator& state,
const simgrid::mc::Snapshot& snapshot1, const simgrid::mc::Snapshot& snapshot2,
const_mc_snapshot_stack_t stack1, const_mc_snapshot_stack_t stack2)
{
// TODO, make this a field of ModelChecker or something similar
static StateComparator state_comparator;
- const RemoteProcess& process = mc_model_checker->get_remote_process();
+ const RemoteProcessMemory& process = mc_model_checker->get_remote_process_memory();
if (hash_ != other.hash_) {
XBT_VERB("(%ld - %ld) Different hash: 0x%" PRIx64 "--0x%" PRIx64, this->num_state_, other.num_state_, this->hash_,
/* If asked to rollback on a state that has a snapshot, restore it */
State* last_state = stack_.back().get();
if (const auto* system_state = last_state->get_system_state()) {
- system_state->restore(&get_remote_app().get_remote_process());
+ system_state->restore(&get_remote_app().get_remote_process_memory());
on_restore_system_state_signal(last_state, get_remote_app());
return;
}
this->app_state_ = std::move(app_state);
if (not this->app_state_->get_system_state())
this->app_state_->set_system_state(std::make_shared<Snapshot>(pair_num, remote_app.get_page_store()));
- this->heap_bytes_used = mc_model_checker->get_remote_process().get_remote_heap_bytes();
+ this->heap_bytes_used = mc_model_checker->get_remote_process_memory().get_remote_heap_bytes();
this->actor_count_ = app_state_->get_actor_count();
this->other_num = -1;
this->atomic_propositions = std::move(atomic_propositions);
if (_sg_mc_checkpoint > 0) {
const Pair* pair = exploration_stack_.back().get();
if (const auto* system_state = pair->app_state_->get_system_state()) {
- system_state->restore(&get_remote_app().get_remote_process());
+ system_state->restore(&get_remote_app().get_remote_process_memory());
return;
}
}
const xbt_automaton_transition* transition = xbt_dynar_get_as(dynar, index, xbt_automaton_transition_t);
return transition->dst;
}
-void LivenessChecker::automaton_register_symbol(RemoteProcess const& remote_process, const char* name,
+void LivenessChecker::automaton_register_symbol(RemoteProcessMemory const& remote_process, const char* name,
RemotePtr<int> address)
{
if (property_automaton_ == nullptr)
void set_property_automaton(xbt_automaton_state_t const& automaton_state) const;
xbt_automaton_exp_label_t get_automaton_transition_label(xbt_dynar_t const& dynar, int index) const;
xbt_automaton_state_t get_automaton_transition_dst(xbt_dynar_t const& dynar, int index) const;
- static void automaton_register_symbol(RemoteProcess const& remote_process, const char* name, RemotePtr<int> addr);
+ static void automaton_register_symbol(RemoteProcessMemory const& remote_process, const char* name,
+ RemotePtr<int> addr);
};
} // namespace simgrid::mc
const char* name);
/** Augment the current module with information about the other ones */
-XBT_PRIVATE void postProcessObjectInformation(const simgrid::mc::RemoteProcess* process,
+XBT_PRIVATE void postProcessObjectInformation(const simgrid::mc::RemoteProcessMemory* process,
simgrid::mc::ObjectInformation* info);
} // namespace simgrid::mc
#include "src/mc/inspect/Variable.hpp"
#include "src/mc/inspect/mc_dwarf.hpp"
#include "src/mc/mc_private.hpp"
-#include "src/mc/remote/RemoteProcess.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
#include <algorithm>
#include <array>
/*************************************************************************/
-void postProcessObjectInformation(const RemoteProcess* process, ObjectInformation* info)
+void postProcessObjectInformation(const RemoteProcessMemory* process, ObjectInformation* info)
{
for (auto& [_, t] : info->types) {
Type* type = &t;
/* 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. */
-/** \file
- * Libunwind support for mc_address_space objects.
- */
+/** \file Libunwind support for mc_address_space objects. */
// We need this for the register indices:
// #define _GNU_SOURCE
#include "src/mc/inspect/mc_unw.hpp"
#include "src/mc/inspect/Frame.hpp"
-#include "src/mc/remote/RemoteProcess.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
#include <cstring>
return unw_create_addr_space(&accessors, BYTE_ORDER);
}
-void UnwindContext::initialize(simgrid::mc::RemoteProcess* process, unw_context_t* c)
+void UnwindContext::initialize(simgrid::mc::RemoteProcessMemory* process, unw_context_t* c)
{
this->address_space_ = process;
this->process_ = process;
namespace simgrid::mc {
class UnwindContext {
- simgrid::mc::AddressSpace* address_space_ = nullptr;
- simgrid::mc::RemoteProcess* process_ = nullptr;
- unw_context_t unwind_context_ = {};
+ simgrid::mc::AddressSpace* address_space_ = nullptr;
+ simgrid::mc::RemoteProcessMemory* process_ = nullptr;
+ unw_context_t unwind_context_ = {};
public:
- void initialize(simgrid::mc::RemoteProcess* process, unw_context_t* c);
+ void initialize(simgrid::mc::RemoteProcessMemory* process, unw_context_t* c);
unw_cursor_t cursor();
private: // Methods and virtual table for libunwind
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/mc/inspect/mc_unw.hpp"
-#include "src/mc/remote/RemoteProcess.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
#include <sys/types.h>
#include <sys/uio.h>
#include "src/mc/ModelChecker.hpp"
#include "src/mc/api/RemoteApp.hpp"
#include "src/mc/remote/AppSide.hpp"
-#include "src/mc/remote/RemoteProcess.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
#endif
XBT_LOG_NEW_DEFAULT_CATEGORY(mc, "All MC categories");
class ChunkedData;
class ModelChecker;
class AddressSpace;
-class RemoteProcess;
+class RemoteProcessMemory;
class Snapshot;
class ObjectInformation;
class Member;
#include "src/kernel/actor/SimcallObserver.hpp"
#include "src/mc/mc_base.hpp"
#include "src/mc/mc_config.hpp"
-#include "src/mc/remote/RemoteProcess.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
#if HAVE_SMPI
#include "src/smpi/include/private.hpp"
#endif
#include "src/mc/ModelChecker.hpp"
#include "src/mc/mc_config.hpp"
#include "src/mc/mc_forward.hpp"
-#include "src/mc/remote/RemoteProcess.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
#include <cstdlib>
#include <sys/mman.h>
{
xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize - 1)) == 0, "Start address not at the beginning of a page");
- chunks_ =
- ChunkedData(store, mc_model_checker->get_remote_process(), RemotePtr<void>(start_addr), mmu::chunk_count(size));
+ chunks_ = ChunkedData(store, mc_model_checker->get_remote_process_memory(), RemotePtr<void>(start_addr),
+ mmu::chunk_count(size));
}
/** @brief Restore a region from a snapshot
for (size_t i = 0; i != get_chunks().page_count(); ++i) {
auto* target_page = (void*)simgrid::mc::mmu::join(i, (std::uintptr_t)(void*)start().address());
const void* source_page = get_chunks().page(i);
- mc_model_checker->get_remote_process().write_bytes(source_page, xbt_pagesize, remote(target_page));
+ mc_model_checker->get_remote_process_memory().write_bytes(source_page, xbt_pagesize, remote(target_page));
}
}
#define _FILE_OFFSET_BITS 64 /* needed for pread_whole to work as expected on 32bits */
-#include "src/mc/remote/RemoteProcess.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
#include "src/mc/sosp/Snapshot.hpp"
#include "xbt/file.hpp"
return open(buffer.c_str(), flags);
}
-// ***** RemoteProcess
+// ***** RemoteProcessMemory
-RemoteProcess::RemoteProcess(pid_t pid) : AddressSpace(this), pid_(pid), running_(true) {}
+RemoteProcessMemory::RemoteProcessMemory(pid_t pid) : AddressSpace(this), pid_(pid), running_(true) {}
-void RemoteProcess::init(xbt_mheap_t mmalloc_default_mdp)
+void RemoteProcessMemory::init(xbt_mheap_t mmalloc_default_mdp)
{
this->heap_address = remote(mmalloc_default_mdp);
this->unw_underlying_context = simgrid::unw::create_context(this->unw_underlying_addr_space, this->pid_);
}
-RemoteProcess::~RemoteProcess()
+RemoteProcessMemory::~RemoteProcessMemory()
{
if (this->memory_file >= 0)
close(this->memory_file);
* Do not use directly, this is used by the getters when appropriate
* in order to have fresh data.
*/
-void RemoteProcess::refresh_heap()
+void RemoteProcessMemory::refresh_heap()
{
// Read/dereference/refresh the std_heap pointer:
this->read(this->heap.get(), this->heap_address);
- this->cache_flags_ |= RemoteProcess::cache_heap;
+ this->cache_flags_ |= RemoteProcessMemory::cache_heap;
}
/** Refresh the information about the process
* Do not use directly, this is used by the getters when appropriate
* in order to have fresh data.
* */
-void RemoteProcess::refresh_malloc_info()
+void RemoteProcessMemory::refresh_malloc_info()
{
// Refresh process->heapinfo:
- if (this->cache_flags_ & RemoteProcess::cache_malloc)
+ if (this->cache_flags_ & RemoteProcessMemory::cache_malloc)
return;
size_t count = this->heap->heaplimit + 1;
if (this->heap_info.size() < count)
this->heap_info.resize(count);
this->read_bytes(this->heap_info.data(), count * sizeof(malloc_info), remote(this->heap->heapinfo));
- this->cache_flags_ |= RemoteProcess::cache_malloc;
+ this->cache_flags_ |= RemoteProcessMemory::cache_malloc;
}
-std::size_t RemoteProcess::get_remote_heap_bytes()
+std::size_t RemoteProcessMemory::get_remote_heap_bytes()
{
return mmalloc_get_bytes_used_remote(get_heap()->heaplimit, get_malloc_info());
}
/** @brief Finds the range of the different memory segments and binary paths */
-void RemoteProcess::init_memory_map_info()
+void RemoteProcessMemory::init_memory_map_info()
{
XBT_DEBUG("Get debug information ...");
this->maestro_stack_start_ = nullptr;
XBT_DEBUG("Get debug information done !");
}
-std::shared_ptr<simgrid::mc::ObjectInformation> RemoteProcess::find_object_info(RemotePtr<void> addr) const
+std::shared_ptr<simgrid::mc::ObjectInformation> RemoteProcessMemory::find_object_info(RemotePtr<void> addr) const
{
for (auto const& object_info : this->object_infos)
if (addr.address() >= (std::uint64_t)object_info->start && addr.address() <= (std::uint64_t)object_info->end)
return nullptr;
}
-std::shared_ptr<ObjectInformation> RemoteProcess::find_object_info_exec(RemotePtr<void> addr) const
+std::shared_ptr<ObjectInformation> RemoteProcessMemory::find_object_info_exec(RemotePtr<void> addr) const
{
for (std::shared_ptr<ObjectInformation> const& info : this->object_infos)
if (addr.address() >= (std::uint64_t)info->start_exec && addr.address() <= (std::uint64_t)info->end_exec)
return nullptr;
}
-std::shared_ptr<ObjectInformation> RemoteProcess::find_object_info_rw(RemotePtr<void> addr) const
+std::shared_ptr<ObjectInformation> RemoteProcessMemory::find_object_info_rw(RemotePtr<void> addr) const
{
for (std::shared_ptr<ObjectInformation> const& info : this->object_infos)
if (addr.address() >= (std::uint64_t)info->start_rw && addr.address() <= (std::uint64_t)info->end_rw)
return nullptr;
}
-simgrid::mc::Frame* RemoteProcess::find_function(RemotePtr<void> ip) const
+simgrid::mc::Frame* RemoteProcessMemory::find_function(RemotePtr<void> ip) const
{
std::shared_ptr<simgrid::mc::ObjectInformation> info = this->find_object_info_exec(ip);
return info ? info->find_function((void*)ip.address()) : nullptr;
/** Find (one occurrence of) the named variable definition
*/
-const simgrid::mc::Variable* RemoteProcess::find_variable(const char* name) const
+const simgrid::mc::Variable* RemoteProcessMemory::find_variable(const char* name) const
{
// First lookup the variable in the executable shared object.
// A global variable used directly by the executable code from a library
return nullptr;
}
-void RemoteProcess::read_variable(const char* name, void* target, size_t size) const
+void RemoteProcessMemory::read_variable(const char* name, void* target, size_t size) const
{
const simgrid::mc::Variable* var = this->find_variable(name);
xbt_assert(var, "Variable %s not found", name);
this->read_bytes(target, size, remote(var->address));
}
-std::string RemoteProcess::read_string(RemotePtr<char> address) const
+std::string RemoteProcessMemory::read_string(RemotePtr<char> address) const
{
if (not address)
return {};
}
}
-void* RemoteProcess::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, ReadOptions /*options*/) const
+void* RemoteProcessMemory::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address,
+ ReadOptions /*options*/) const
{
xbt_assert(pread_whole(this->memory_file, buffer, size, (size_t)address.address()) != -1,
"Read at %p from process %lli failed", (void*)address.address(), (long long)this->pid_);
* @param len data size
* @param address target process memory address (target)
*/
-void RemoteProcess::write_bytes(const void* buffer, size_t len, RemotePtr<void> address) const
+void RemoteProcessMemory::write_bytes(const void* buffer, size_t len, RemotePtr<void> address) const
{
xbt_assert(pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) != -1,
"Write to process %lli failed", (long long)this->pid_);
close(fd);
}
-void RemoteProcess::clear_bytes(RemotePtr<void> address, size_t len) const
+void RemoteProcessMemory::clear_bytes(RemotePtr<void> address, size_t len) const
{
static constexpr size_t zero_buffer_size = 10 * 4096;
static const void* zero_buffer;
}
}
-void RemoteProcess::ignore_region(std::uint64_t addr, std::size_t size)
+void RemoteProcessMemory::ignore_region(std::uint64_t addr, std::size_t size)
{
IgnoredRegion region;
region.addr = addr;
ignored_regions_.insert(pos, region);
}
-void RemoteProcess::ignore_heap(IgnoredHeapRegion const& region)
+void RemoteProcessMemory::ignore_heap(IgnoredHeapRegion const& region)
{
// Binary search the position of insertion:
auto pos = std::lower_bound(ignored_heap_.begin(), ignored_heap_.end(), region.address,
}
}
-void RemoteProcess::unignore_heap(void* address, size_t size)
+void RemoteProcessMemory::unignore_heap(void* address, size_t size)
{
// Binary search:
auto pos = std::lower_bound(ignored_heap_.begin(), ignored_heap_.end(), address,
ignored_heap_.erase(pos);
}
-void RemoteProcess::ignore_local_variable(const char* var_name, const char* frame_name) const
+void RemoteProcessMemory::ignore_local_variable(const char* var_name, const char* frame_name) const
{
if (frame_name != nullptr && strcmp(frame_name, "*") == 0)
frame_name = nullptr;
info->remove_local_variable(var_name, frame_name);
}
-void RemoteProcess::dump_stack() const
+void RemoteProcessMemory::dump_stack() const
{
unw_addr_space_t as = unw_create_addr_space(&_UPT_accessors, BYTE_ORDER);
if (as == nullptr) {
* - stack unwinding;
* - etc.
*/
-class RemoteProcess final : public AddressSpace {
+class RemoteProcessMemory final : public AddressSpace {
private:
// Those flags are used to track down which cached information
// is still up to date and which information needs to be updated.
- static constexpr int cache_none = 0;
- static constexpr int cache_heap = 1;
- static constexpr int cache_malloc = 2;
+ static constexpr int cache_none = 0;
+ static constexpr int cache_heap = 1;
+ static constexpr int cache_malloc = 2;
public:
- explicit RemoteProcess(pid_t pid);
- ~RemoteProcess() override;
+ explicit RemoteProcessMemory(pid_t pid);
+ ~RemoteProcessMemory() override;
void init(xbt_mheap_t mmalloc_default_mdp);
- RemoteProcess(RemoteProcess const&) = delete;
- RemoteProcess(RemoteProcess&&) = delete;
- RemoteProcess& operator=(RemoteProcess const&) = delete;
- RemoteProcess& operator=(RemoteProcess&&) = delete;
+ RemoteProcessMemory(RemoteProcessMemory const&) = delete;
+ RemoteProcessMemory(RemoteProcessMemory&&) = delete;
+ RemoteProcessMemory& operator=(RemoteProcessMemory const&) = delete;
+ RemoteProcessMemory& operator=(RemoteProcessMemory&&) = delete;
/* ************* */
/* Low-level API */
// Heap access:
xbt_mheap_t get_heap()
{
- if (not(this->cache_flags_ & RemoteProcess::cache_heap))
+ if (not(this->cache_flags_ & RemoteProcessMemory::cache_heap))
this->refresh_heap();
return this->heap.get();
}
const malloc_info* get_malloc_info()
{
- if (not(this->cache_flags_ & RemoteProcess::cache_malloc))
+ if (not(this->cache_flags_ & RemoteProcessMemory::cache_malloc))
this->refresh_malloc_info();
return this->heap_info.data();
}
/* Get the amount of memory mallocated in the remote process (requires mmalloc) */
std::size_t get_remote_heap_bytes();
- void clear_cache() { this->cache_flags_ = RemoteProcess::cache_none; }
+ void clear_cache() { this->cache_flags_ = RemoteProcessMemory::cache_none; }
std::vector<IgnoredRegion> const& ignored_regions() const { return ignored_regions_; }
void ignore_region(std::uint64_t address, std::size_t size);
std::vector<IgnoredHeapRegion> ignored_heap_;
/** State of the cache (which variables are up to date) */
- int cache_flags_ = RemoteProcess::cache_none;
+ int cache_flags_ = RemoteProcessMemory::cache_none;
public:
// object info
/************************************* Take Snapshot ************************************/
/****************************************************************************************/
-void Snapshot::snapshot_regions(RemoteProcess* process)
+void Snapshot::snapshot_regions(RemoteProcessMemory* process)
{
snapshot_regions_.clear();
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->get_remote_process());
+ &mc_model_checker->get_remote_process_memory());
xbt_assert(location.in_memory(), "Cannot handle non-address variable");
new_var.address = location.address();
static std::vector<s_mc_stack_frame_t> unwind_stack_frames(UnwindContext* stack_context)
{
- const RemoteProcess* process = &mc_model_checker->get_remote_process();
+ const RemoteProcessMemory* process = &mc_model_checker->get_remote_process_memory();
std::vector<s_mc_stack_frame_t> result;
unw_cursor_t c = stack_context->cursor();
return result;
}
-void Snapshot::snapshot_stacks(RemoteProcess* process)
+void Snapshot::snapshot_stacks(RemoteProcessMemory* process)
{
for (auto const& stack : process->stack_areas()) {
s_mc_snapshot_stack_t st;
void Snapshot::handle_ignore()
{
- xbt_assert(get_remote_process());
+ xbt_assert(get_remote_process_memory());
// Copy the memory:
- for (auto const& region : get_remote_process()->ignored_regions()) {
+ for (auto const& region : get_remote_process_memory()->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:
- get_remote_process()->read_bytes(ignored_data.data.data(), region.size, remote(region.addr));
+ get_remote_process_memory()->read_bytes(ignored_data.data.data(), region.size, remote(region.addr));
ignored_data_.push_back(std::move(ignored_data));
}
// Zero the memory:
- for (auto const& region : get_remote_process()->ignored_regions())
- get_remote_process()->clear_bytes(remote(region.addr), region.size);
+ for (auto const& region : get_remote_process_memory()->ignored_regions())
+ get_remote_process_memory()->clear_bytes(remote(region.addr), region.size);
}
void Snapshot::ignore_restore() const
{
for (auto const& ignored_data : ignored_data_)
- get_remote_process()->write_bytes(ignored_data.data.data(), ignored_data.data.size(), remote(ignored_data.start));
+ get_remote_process_memory()->write_bytes(ignored_data.data.data(), ignored_data.data.size(),
+ remote(ignored_data.start));
}
-Snapshot::Snapshot(long num_state, PageStore& store, RemoteProcess* process)
+Snapshot::Snapshot(long num_state, PageStore& store, RemoteProcessMemory* process)
: AddressSpace(process), page_store_(store), num_state_(num_state)
{
XBT_DEBUG("Taking snapshot %ld", num_state);
return buffer;
}
} else
- return this->get_remote_process()->read_bytes(buffer, size, address, options);
+ return this->get_remote_process_memory()->read_bytes(buffer, size, address, options);
}
/** @brief Find the snapshotted region from a pointer
*
return get_region(addr);
}
-void Snapshot::restore(RemoteProcess* process) const
+void Snapshot::restore(RemoteProcessMemory* process) const
{
XBT_DEBUG("Restore snapshot %ld", num_state_);
#include "src/mc/ModelChecker.hpp"
#include "src/mc/inspect/mc_unw.hpp"
-#include "src/mc/remote/RemoteProcess.hpp"
#include "src/mc/sosp/Region.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
// ***** MC Snapshot
public:
/* Initialization */
- Snapshot(long num_state, PageStore& store, RemoteProcess* process = &mc_model_checker->get_remote_process());
+ Snapshot(long num_state, PageStore& store,
+ RemoteProcessMemory* process = &mc_model_checker->get_remote_process_memory());
/* Regular use */
bool on_heap(const void* address) const
{
- const s_xbt_mheap_t* heap = get_remote_process()->get_heap();
+ const s_xbt_mheap_t* heap = get_remote_process_memory()->get_heap();
return address >= heap->heapbase && address < heap->breakval;
}
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(RemoteProcess* process) const;
+ void restore(RemoteProcessMemory* process) const;
bool operator==(const Snapshot& other);
bool operator!=(const Snapshot& other) { return not(*this == other); }
private:
void add_region(RegionType type, ObjectInformation* object_info, void* start_addr, std::size_t size);
- void snapshot_regions(RemoteProcess* process);
- void snapshot_stacks(RemoteProcess* process);
+ void snapshot_regions(RemoteProcessMemory* process);
+ void snapshot_stacks(RemoteProcessMemory* process);
void handle_ignore();
void ignore_restore() const;
hash_type do_hash() const;
mc_model_checker = nullptr;
}
- static std::unique_ptr<simgrid::mc::RemoteProcess> process;
+ static std::unique_ptr<simgrid::mc::RemoteProcessMemory> process;
};
// static member variables init.
-std::unique_ptr<simgrid::mc::RemoteProcess> snap_test_helper::process = nullptr;
+std::unique_ptr<simgrid::mc::RemoteProcessMemory> snap_test_helper::process = nullptr;
simgrid::mc::PageStore snap_test_helper::page_store_(500);
void snap_test_helper::init_memory(void* mem, size_t size)
REQUIRE(xbt_pagesize == getpagesize());
REQUIRE(1 << xbt_pagebits == xbt_pagesize);
- process = std::make_unique<simgrid::mc::RemoteProcess>(getpid());
+ process = std::make_unique<simgrid::mc::RemoteProcessMemory>(getpid());
process->init(nullptr);
mc_model_checker = new ::simgrid::mc::ModelChecker(std::move(process), -1);
}
#include "src/mc/inspect/ObjectInformation.hpp"
#include "src/mc/inspect/Type.hpp"
#include "src/mc/inspect/Variable.hpp"
-#include "src/mc/remote/RemoteProcess.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
#include <array>
#include <cassert>
int main()
{
- auto* process = new simgrid::mc::RemoteProcess(getpid());
+ auto* process = new simgrid::mc::RemoteProcessMemory(getpid());
process->init(nullptr);
simgrid::dwarf::ExpressionContext state;
#include "src/mc/inspect/ObjectInformation.hpp"
#include "src/mc/inspect/Type.hpp"
#include "src/mc/inspect/Variable.hpp"
-#include "src/mc/remote/RemoteProcess.hpp"
+#include "src/mc/sosp/RemoteProcessMemory.hpp"
#include <cassert>
#include <cstring>
xbt_assert(location.address() == address, "Bad resolution of local variable %s of %s", variable, function);
}
-static const simgrid::mc::Variable* test_global_variable(const simgrid::mc::RemoteProcess& process,
+static const simgrid::mc::Variable* test_global_variable(const simgrid::mc::RemoteProcessMemory& process,
simgrid::mc::ObjectInformation* info, const char* name,
void* address, long byte_size)
{
int i;
};
-static void test_type_by_name(const simgrid::mc::RemoteProcess& process, s_foo /*my_foo*/)
+static void test_type_by_name(const simgrid::mc::RemoteProcessMemory& process, s_foo /*my_foo*/)
{
assert(process.binary_info->full_types_by_name.find("struct s_foo") != process.binary_info->full_types_by_name.end());
}
const simgrid::mc::Variable* var;
simgrid::mc::Type* type;
- simgrid::mc::RemoteProcess process(getpid());
+ simgrid::mc::RemoteProcessMemory process(getpid());
process.init(nullptr);
test_global_variable(process, process.binary_info.get(), "some_local_variable", &some_local_variable, sizeof(int));
src/mc/remote/Channel.hpp
src/mc/remote/CheckerSide.cpp
src/mc/remote/CheckerSide.hpp
- src/mc/remote/RemoteProcess.cpp
- src/mc/remote/RemoteProcess.hpp
src/mc/remote/RemotePtr.hpp
src/mc/remote/mc_protocol.h
-
+
src/mc/sosp/ChunkedData.cpp
src/mc/sosp/ChunkedData.hpp
src/mc/sosp/PageStore.cpp
src/mc/sosp/PageStore.hpp
src/mc/sosp/Region.cpp
src/mc/sosp/Region.hpp
+ src/mc/sosp/RemoteProcessMemory.cpp
+ src/mc/sosp/RemoteProcessMemory.hpp
src/mc/sosp/Snapshot.cpp
src/mc/sosp/Snapshot.hpp