This is a proxy to the Client (ie the MCed), as seen from the server
(ie, the MCer)
26 files changed:
*/
class AddressSpace {
private:
*/
class AddressSpace {
private:
+ RemoteClient* process_;
+
- explicit AddressSpace(Process* process) : process_(process) {}
+ explicit AddressSpace(RemoteClient* process) : process_(process) {}
virtual ~AddressSpace() = default;
virtual ~AddressSpace() = default;
- /** The process of this addres space
+ /** The process of this address space
*
* This is where we can get debug informations, memory layout, etc.
*/
*
* This is where we can get debug informations, memory layout, etc.
*/
- simgrid::mc::Process* process() const { return process_; }
+ simgrid::mc::RemoteClient* process() const { return process_; }
/** Read data from the address space
*
/** Read data from the address space
*
namespace simgrid {
namespace mc {
namespace simgrid {
namespace mc {
-ModelChecker::ModelChecker(std::unique_ptr<Process> process) :
- base_(nullptr),
- socket_event_(nullptr),
- signal_event_(nullptr),
- page_store_(500),
- process_(std::move(process)),
- parent_snapshot_(nullptr)
+ModelChecker::ModelChecker(std::unique_ptr<RemoteClient> process)
+ : base_(nullptr)
+ , socket_event_(nullptr)
+ , signal_event_(nullptr)
+ , page_store_(500)
+ , process_(std::move(process))
+ , parent_snapshot_(nullptr)
void ModelChecker::setup_ignore()
{
void ModelChecker::setup_ignore()
{
- Process& process = this->process();
+ RemoteClient& process = this->process();
for (std::pair<const char*, const char*> const& var :
ignored_local_variables)
process.ignore_local_variable(var.first, var.second);
for (std::pair<const char*, const char*> const& var :
ignored_local_variables)
process.ignore_local_variable(var.first, var.second);
{
XBT_DEBUG("Shuting down model-checker");
{
XBT_DEBUG("Shuting down model-checker");
- simgrid::mc::Process* process = &this->process();
+ simgrid::mc::RemoteClient* process = &this->process();
if (process->running()) {
XBT_DEBUG("Killing process");
kill(process->pid(), SIGTERM);
if (process->running()) {
XBT_DEBUG("Killing process");
kill(process->pid(), SIGTERM);
-void ModelChecker::resume(simgrid::mc::Process& process)
+void ModelChecker::resume(simgrid::mc::RemoteClient& process)
{
int res = process.getChannel().send(MC_MESSAGE_CONTINUE);
if (res)
{
int res = process.getChannel().send(MC_MESSAGE_CONTINUE);
if (res)
if (simgrid::mc::property_automaton == nullptr)
simgrid::mc::property_automaton = xbt_automaton_new();
if (simgrid::mc::property_automaton == nullptr)
simgrid::mc::property_automaton = xbt_automaton_new();
- simgrid::mc::Process* process = &this->process();
+ simgrid::mc::RemoteClient* process = &this->process();
simgrid::mc::RemotePtr<int> address
= simgrid::mc::remote((int*) message.data);
simgrid::xbt::add_proposition(simgrid::mc::property_automaton,
simgrid::mc::RemotePtr<int> address
= simgrid::mc::remote((int*) message.data);
simgrid::xbt::add_proposition(simgrid::mc::property_automaton,
-void ModelChecker::wait_client(simgrid::mc::Process& process)
+void ModelChecker::wait_client(simgrid::mc::RemoteClient& process)
{
this->resume(process);
if (this->process().running())
{
this->resume(process);
if (this->process().running())
#include <sys/types.h>
#include "src/mc/PageStore.hpp"
#include <sys/types.h>
#include "src/mc/PageStore.hpp"
-#include "src/mc/Process.hpp"
#include "src/mc/Transition.hpp"
#include "src/mc/mc_forward.hpp"
#include "src/mc/Transition.hpp"
#include "src/mc/mc_forward.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
#include "src/mc/remote/mc_protocol.h"
namespace simgrid {
#include "src/mc/remote/mc_protocol.h"
namespace simgrid {
std::set<std::string> hostnames_;
// This is the parent snapshot of the current state:
PageStore page_store_;
std::set<std::string> hostnames_;
// This is the parent snapshot of the current state:
PageStore page_store_;
- std::unique_ptr<Process> process_;
+ std::unique_ptr<RemoteClient> process_;
Checker* checker_ = nullptr;
public:
std::shared_ptr<simgrid::mc::Snapshot> parent_snapshot_;
Checker* checker_ = nullptr;
public:
std::shared_ptr<simgrid::mc::Snapshot> parent_snapshot_;
public:
ModelChecker(ModelChecker const&) = delete;
ModelChecker& operator=(ModelChecker const&) = delete;
public:
ModelChecker(ModelChecker const&) = delete;
ModelChecker& operator=(ModelChecker const&) = delete;
- explicit ModelChecker(std::unique_ptr<Process> process);
+ explicit ModelChecker(std::unique_ptr<RemoteClient> process);
- Process& process()
- {
- return *process_;
- }
+ RemoteClient& process() { return *process_; }
PageStore& page_store()
{
return page_store_;
PageStore& page_store()
{
return page_store_;
void start();
void shutdown();
void start();
void shutdown();
- void resume(simgrid::mc::Process& process);
+ void resume(simgrid::mc::RemoteClient& process);
void loop();
void handle_events(int fd, short events);
void loop();
void handle_events(int fd, short events);
- void wait_client(simgrid::mc::Process& process);
+ void wait_client(simgrid::mc::RemoteClient& process);
void handle_simcall(Transition const& transition);
void wait_for_requests()
{
void handle_simcall(Transition const& transition);
void wait_for_requests()
{
std::vector<simgrid::xbt::VmMap> const& maps, const char* name);
/** Augment the current module with informations about the other ones */
std::vector<simgrid::xbt::VmMap> const& maps, const char* name);
/** Augment the current module with informations about the other ones */
-XBT_PRIVATE void postProcessObjectInformation(
- simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info);
-
+XBT_PRIVATE void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info);
RegionSnapshot sparse_region(RegionType region_type,
void *start_addr, void* permanent_addr, size_t size)
{
RegionSnapshot sparse_region(RegionType region_type,
void *start_addr, void* permanent_addr, size_t size)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
assert(process != nullptr);
xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize-1)) == 0,
assert(process != nullptr);
xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize-1)) == 0,
Session::Session(pid_t pid, int socket)
{
Session::Session(pid_t pid, int socket)
{
- std::unique_ptr<simgrid::mc::Process> process(new simgrid::mc::Process(pid, socket));
+ std::unique_ptr<simgrid::mc::RemoteClient> process(new simgrid::mc::RemoteClient(pid, socket));
// TODO, automatic detection of the config from the process
process->privatized(smpi_privatize_global_variables != SMPI_PRIVATIZE_NONE);
modelChecker_ = std::unique_ptr<ModelChecker>(
// TODO, automatic detection of the config from the process
process->privatized(smpi_privatize_global_variables != SMPI_PRIVATIZE_NONE);
modelChecker_ = std::unique_ptr<ModelChecker>(
#include "xbt/log.h"
#include "xbt/sysdep.h"
#include "xbt/log.h"
#include "xbt/sysdep.h"
+#include "src/mc/VisitedState.hpp"
#include "src/mc/mc_comm_pattern.h"
#include "src/mc/mc_private.h"
#include "src/mc/mc_comm_pattern.h"
#include "src/mc/mc_private.h"
-#include "src/mc/Process.hpp"
#include "src/mc/mc_smx.h"
#include "src/mc/mc_smx.h"
-#include "src/mc/VisitedState.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_VisitedState, mc, "Logging specific to state equality detection mechanisms");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_VisitedState, mc, "Logging specific to state equality detection mechanisms");
/** @brief Save the current state */
VisitedState::VisitedState(unsigned long state_number)
{
/** @brief Save the current state */
VisitedState::VisitedState(unsigned long state_number)
{
- simgrid::mc::Process* process = &(mc_model_checker->process());
+ simgrid::mc::RemoteClient* process = &(mc_model_checker->process());
this->heap_bytes_used = mmalloc_get_bytes_used_remote(
process->get_heap()->heaplimit,
process->get_malloc_info());
this->heap_bytes_used = mmalloc_get_bytes_used_remote(
process->get_heap()->heaplimit,
process->get_malloc_info());
std::shared_ptr<const std::vector<int>> atomic_propositions,
std::shared_ptr<simgrid::mc::State> graph_state)
{
std::shared_ptr<const std::vector<int>> atomic_propositions,
std::shared_ptr<simgrid::mc::State> graph_state)
{
- simgrid::mc::Process* process = &(mc_model_checker->process());
+ simgrid::mc::RemoteClient* process = &(mc_model_checker->process());
this->graph_state = std::move(graph_state);
if(this->graph_state->system_state == nullptr)
this->graph_state = std::move(graph_state);
if(this->graph_state->system_state == nullptr)
int mmalloc_compare_heap(
simgrid::mc::StateComparator& state, simgrid::mc::Snapshot* snapshot1, simgrid::mc::Snapshot* snapshot2)
{
int mmalloc_compare_heap(
simgrid::mc::StateComparator& state, simgrid::mc::Snapshot* snapshot1, simgrid::mc::Snapshot* snapshot2)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
/* Start comparison */
size_t i1;
/* Start comparison */
size_t i1;
HeapLocationPairs* previous, int size,
int check_ignore)
{
HeapLocationPairs* previous, int size,
int check_ignore)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
mc_mem_region_t heap_region1 = MC_get_heap_region(snapshot1);
mc_mem_region_t heap_region2 = MC_get_heap_region(snapshot2);
mc_mem_region_t heap_region1 = MC_get_heap_region(snapshot1);
mc_mem_region_t heap_region2 = MC_get_heap_region(snapshot2);
HeapLocationPairs* previous,
simgrid::mc::Type* type, int pointer_level)
{
HeapLocationPairs* previous,
simgrid::mc::Type* type, int pointer_level)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
int res_compare;
ssize_t block1;
int res_compare;
ssize_t block1;
void* real_area2, simgrid::mc::Snapshot* snapshot2, mc_mem_region_t region2,
simgrid::mc::Type* type, int pointer_level)
{
void* real_area2, simgrid::mc::Snapshot* snapshot2, mc_mem_region_t region2,
simgrid::mc::Type* type, int pointer_level)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
simgrid::mc::Type* subtype;
simgrid::mc::Type* subsubtype;
simgrid::mc::Type* subtype;
simgrid::mc::Type* subsubtype;
else
state_comparator->clear();
else
state_comparator->clear();
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
return true;
#if SIMGRID_HAVE_MC
else if (mc_model_checker != nullptr) {
return true;
#if SIMGRID_HAVE_MC
else if (mc_model_checker != nullptr) {
- simgrid::mc::Process& modelchecked = mc_model_checker->process();
+ simgrid::mc::RemoteClient& modelchecked = mc_model_checker->process();
// TODO, *(mutex->owner) :/
return modelchecked.resolveActor(simgrid::mc::remote(mutex->owner))->pid ==
modelchecked.resolveActor(simgrid::mc::remote(req->issuer))->pid;
// TODO, *(mutex->owner) :/
return modelchecked.resolveActor(simgrid::mc::remote(mutex->owner))->pid ==
modelchecked.resolveActor(simgrid::mc::remote(req->issuer))->pid;
-static void get_memory_regions(simgrid::mc::Process* process, simgrid::mc::Snapshot* snapshot)
+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);
{
const size_t n = process->object_infos.size();
snapshot->snapshot_regions.resize(n + 1);
int process_index,
std::vector<s_local_variable>& result)
{
int process_index,
std::vector<s_local_variable>& result)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
if (not scope || not scope->range.contain(stack_frame->ip))
return;
if (not scope || not scope->range.contain(stack_frame->ip))
return;
static std::vector<s_mc_stack_frame_t> unwind_stack_frames(simgrid::mc::UnwindContext* stack_context)
{
static std::vector<s_mc_stack_frame_t> unwind_stack_frames(simgrid::mc::UnwindContext* stack_context)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
std::vector<s_mc_stack_frame_t> result;
unw_cursor_t c = stack_context->cursor();
std::vector<s_mc_stack_frame_t> result;
unw_cursor_t c = stack_context->cursor();
{
XBT_DEBUG("Taking snapshot %i", num_state);
{
XBT_DEBUG("Taking snapshot %i", num_state);
- simgrid::mc::Process* mc_process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* mc_process = &mc_model_checker->process();
std::shared_ptr<simgrid::mc::Snapshot> snapshot = std::make_shared<simgrid::mc::Snapshot>(mc_process, num_state);
std::shared_ptr<simgrid::mc::Snapshot> snapshot = std::make_shared<simgrid::mc::Snapshot>(mc_process, num_state);
#include "src/mc/mc_private.h"
#include "src/mc/mc_dwarf.hpp"
#include "src/mc/mc_private.h"
#include "src/mc/mc_dwarf.hpp"
-#include "src/mc/Process.hpp"
#include "src/mc/ObjectInformation.hpp"
#include "src/mc/Variable.hpp"
#include "src/mc/ObjectInformation.hpp"
#include "src/mc/Variable.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dwarf, mc, "DWARF processing");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dwarf, mc, "DWARF processing");
/*************************************************************************/
/*************************************************************************/
-void postProcessObjectInformation(simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info)
+void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info)
{
for (auto& i : info->types) {
{
for (auto& i : info->types) {
class ChunkedData;
class ModelChecker;
class AddressSpace;
class ChunkedData;
class ModelChecker;
class AddressSpace;
class Snapshot;
class ObjectInformation;
class Member;
class Snapshot;
class ObjectInformation;
class Member;
* @param page_count Number of pages of the region
* @param pagenos
*/
* @param page_count Number of pages of the region
* @param pagenos
*/
-void mc_restore_page_snapshot_region(simgrid::mc::Process* process,
- void* start_addr, simgrid::mc::ChunkedData const& pages_copy)
+void mc_restore_page_snapshot_region(simgrid::mc::RemoteClient* process, void* start_addr,
+ simgrid::mc::ChunkedData const& pages_copy)
{
for (size_t i = 0; i != pages_copy.page_count(); ++i) {
// Otherwise, copy the page:
{
for (size_t i = 0; i != pages_copy.page_count(); ++i) {
// Otherwise, copy the page:
-void mc_region_restore_sparse(simgrid::mc::Process* process, mc_mem_region_t reg)
+void mc_region_restore_sparse(simgrid::mc::RemoteClient* process, mc_mem_region_t reg)
{
xbt_assert(((reg->permanent_address().address()) & (xbt_pagesize-1)) == 0,
"Not at the beginning of a page");
{
xbt_assert(((reg->permanent_address().address()) & (xbt_pagesize-1)) == 0,
"Not at the beginning of a page");
* @param target Local vector (to be filled with copies of `s_smx_actor_t`)
* @param remote_swag Address of the process SWAG in the remote list
*/
* @param target Local vector (to be filled with copies of `s_smx_actor_t`)
* @param remote_swag Address of the process SWAG in the remote list
*/
-static void MC_process_refresh_simix_process_list(simgrid::mc::Process* process,
+static void MC_process_refresh_simix_process_list(simgrid::mc::RemoteClient* process,
std::vector<simgrid::mc::ActorInformation>& target,
simgrid::mc::RemotePtr<s_xbt_swag_t> remote_swag)
{
std::vector<simgrid::mc::ActorInformation>& target,
simgrid::mc::RemotePtr<s_xbt_swag_t> remote_swag)
{
assert(i == swag.count);
}
assert(i == swag.count);
}
-static void MC_process_refresh_simix_actor_dynar(simgrid::mc::Process* process,
+static void MC_process_refresh_simix_actor_dynar(simgrid::mc::RemoteClient* process,
std::vector<simgrid::mc::ActorInformation>& target,
simgrid::mc::RemotePtr<s_xbt_dynar_t> remote_dynar)
{
std::vector<simgrid::mc::ActorInformation>& target,
simgrid::mc::RemotePtr<s_xbt_dynar_t> remote_dynar)
{
namespace simgrid {
namespace mc {
namespace simgrid {
namespace mc {
-void Process::refresh_simix()
+void RemoteClient::refresh_simix()
- if (this->cache_flags_ & Process::cache_simix_processes)
+ if (this->cache_flags_ & RemoteClient::cache_simix_processes)
return;
// TODO, avoid to reload `&simix_global`, `simix_global`, `*simix_global`
return;
// TODO, avoid to reload `&simix_global`, `simix_global`, `*simix_global`
MC_process_refresh_simix_process_list(this, this->smx_dead_actors_infos,
remote(simix_global.getBuffer()->process_to_destroy));
MC_process_refresh_simix_process_list(this, this->smx_dead_actors_infos,
remote(simix_global.getBuffer()->process_to_destroy));
- this->cache_flags_ |= Process::cache_simix_processes;
+ this->cache_flags_ |= RemoteClient::cache_simix_processes;
if (mc_model_checker == nullptr)
return actor->host->getCname();
if (mc_model_checker == nullptr)
return actor->host->getCname();
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
/* HACK, Horrible hack to find the offset of the id in the simgrid::s4u::Host.
/* HACK, Horrible hack to find the offset of the id in the simgrid::s4u::Host.
const char* MC_smx_actor_get_name(smx_actor_t actor)
{
const char* MC_smx_actor_get_name(smx_actor_t actor)
{
- simgrid::mc::Process* process = &mc_model_checker->process();
+ simgrid::mc::RemoteClient* process = &mc_model_checker->process();
if (mc_model_checker == nullptr)
return actor->name.c_str();
if (mc_model_checker == nullptr)
return actor->name.c_str();
#ifndef SIMGRID_MC_SMX_H
#define SIMGRID_MC_SMX_H
#ifndef SIMGRID_MC_SMX_H
#define SIMGRID_MC_SMX_H
-#include "src/mc/Process.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
/** @file
* @brief (Cross-process, MCer/MCed) Access to SMX structures
/** @file
* @brief (Cross-process, MCer/MCed) Access to SMX structures
namespace simgrid {
namespace mc {
namespace simgrid {
namespace mc {
-Snapshot::Snapshot(Process* process, int _num_state)
+Snapshot::Snapshot(RemoteClient* process, int _num_state)
: AddressSpace(process)
, num_state(_num_state)
, heap_bytes_used(0)
: AddressSpace(process)
, num_state(_num_state)
, heap_bytes_used(0)
xbt_assert(xbt_pagesize == getpagesize());
xbt_assert(1 << xbt_pagebits == xbt_pagesize);
xbt_assert(xbt_pagesize == getpagesize());
xbt_assert(1 << xbt_pagebits == xbt_pagesize);
- std::unique_ptr<simgrid::mc::Process> process(new simgrid::mc::Process(getpid(), -1));
+ std::unique_ptr<simgrid::mc::RemoteClient> process(new simgrid::mc::RemoteClient(getpid(), -1));
process->init();
mc_model_checker = new ::simgrid::mc::ModelChecker(std::move(process));
process->init();
mc_model_checker = new ::simgrid::mc::ModelChecker(std::move(process));
-XBT_PRIVATE void mc_region_restore_sparse(simgrid::mc::Process* process, mc_mem_region_t reg);
+XBT_PRIVATE void mc_region_restore_sparse(simgrid::mc::RemoteClient* process, mc_mem_region_t reg);
static XBT_ALWAYS_INLINE void* mc_translate_address_region_chunked(uintptr_t addr, mc_mem_region_t region)
{
static XBT_ALWAYS_INLINE void* mc_translate_address_region_chunked(uintptr_t addr, mc_mem_region_t region)
{
class XBT_PRIVATE Snapshot final : public AddressSpace {
public:
class XBT_PRIVATE Snapshot final : public AddressSpace {
public:
- Snapshot(Process* process, int num_state);
+ Snapshot(RemoteClient* process, int num_state);
~Snapshot() = default;
const void* read_bytes(void* buffer, std::size_t size,
RemotePtr<void> address, int process_index = ProcessIndexAny,
~Snapshot() = default;
const void* read_bytes(void* buffer, std::size_t size,
RemotePtr<void> address, int process_index = ProcessIndexAny,
-XBT_PRIVATE void mc_restore_page_snapshot_region(
- simgrid::mc::Process* process,
- void* start_addr, simgrid::mc::ChunkedData const& pagenos);
+XBT_PRIVATE void mc_restore_page_snapshot_region(simgrid::mc::RemoteClient* process, void* start_addr,
+ simgrid::mc::ChunkedData const& pagenos);
const void* MC_region_read_fragmented(
mc_mem_region_t region, void* target, const void* addr, std::size_t size);
const void* MC_region_read_fragmented(
mc_mem_region_t region, void* target, const void* addr, std::size_t size);
-#include "src/mc/Process.hpp"
-#include "src/mc/mc_unw.h"
#include "src/mc/Frame.hpp"
#include "src/mc/Frame.hpp"
+#include "src/mc/mc_unw.h"
+#include "src/mc/remote/RemoteClient.hpp"
using simgrid::mc::remote;
using simgrid::mc::remote;
-void UnwindContext::initialize(simgrid::mc::Process* process, unw_context_t* c)
+void UnwindContext::initialize(simgrid::mc::RemoteClient* process, unw_context_t* c)
class UnwindContext {
simgrid::mc::AddressSpace* addressSpace_ = nullptr;
class UnwindContext {
simgrid::mc::AddressSpace* addressSpace_ = nullptr;
- simgrid::mc::Process* process_ = nullptr;
+ simgrid::mc::RemoteClient* process_ = nullptr;
unw_context_t unwindContext_;
public:
UnwindContext() = default;
~UnwindContext() { clear(); }
unw_context_t unwindContext_;
public:
UnwindContext() = default;
~UnwindContext() { clear(); }
- void initialize(simgrid::mc::Process* process, unw_context_t* c);
+ void initialize(simgrid::mc::RemoteClient* process, unw_context_t* c);
void clear();
unw_cursor_t cursor();
void clear();
unw_cursor_t cursor();
#include <libunwind.h>
#include <libunwind-ptrace.h>
#include <libunwind.h>
#include <libunwind-ptrace.h>
-#include "src/mc/Process.hpp"
#include "src/mc/mc_unw.h"
#include "src/mc/mc_unw.h"
+#include "src/mc/remote/RemoteClient.hpp"
/** \file
* Libunwind namespace implementation using process_vm_readv.
/** \file
* Libunwind namespace implementation using process_vm_readv.
#define _FILE_OFFSET_BITS 64 /* needed for pread_whole to work as expected on 32bits */
#include <assert.h>
#define _FILE_OFFSET_BITS 64 /* needed for pread_whole to work as expected on 32bits */
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/ptrace.h>
#include <cstdio>
#include <sys/ptrace.h>
#include <cstdio>
#include <regex.h>
#include <sys/mman.h> // PROT_*
#include <regex.h>
#include <sys/mman.h> // PROT_*
+#include <sys/types.h>
+#include <unistd.h>
#include <pthread.h>
#include <libgen.h>
#include <pthread.h>
#include <libgen.h>
#include <libunwind-ptrace.h>
#include <libunwind-ptrace.h>
#include "xbt/base.h"
#include "xbt/log.h"
#include <xbt/mmalloc.h>
#include "xbt/base.h"
#include "xbt/log.h"
#include <xbt/mmalloc.h>
-#include "src/mc/mc_unw.h"
-#include "src/mc/mc_snapshot.h"
#include "src/mc/mc_smx.h"
#include "src/mc/mc_smx.h"
+#include "src/mc/mc_snapshot.h"
+#include "src/mc/mc_unw.h"
-#include "src/mc/Process.hpp"
#include "src/mc/AddressSpace.hpp"
#include "src/mc/ObjectInformation.hpp"
#include "src/mc/Variable.hpp"
#include "src/mc/AddressSpace.hpp"
#include "src/mc/ObjectInformation.hpp"
#include "src/mc/Variable.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
using simgrid::mc::remote;
using simgrid::mc::remote;
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_process, mc,
- "MC process information");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_process, mc, "MC process information");
static bool is_filtered_lib(const char* libname)
{
for (const char* filtered_lib : filtered_libraries)
static bool is_filtered_lib(const char* libname)
{
for (const char* filtered_lib : filtered_libraries)
- if (strcmp(libname, filtered_lib)==0)
+ if (strcmp(libname, filtered_lib) == 0)
return true;
return false;
}
return true;
return false;
}
char* map_basename = xbt_basename(pathname);
regmatch_t match;
char* map_basename = xbt_basename(pathname);
regmatch_t match;
- if(regexec(&res->so_re, map_basename, 1, &match, 0)) {
+ if (regexec(&res->so_re, map_basename, 1, &match, 0)) {
free(map_basename);
return nullptr;
}
free(map_basename);
return nullptr;
}
// Strip the version suffix:
if (libname && not regexec(&res->version_re, libname, 1, &match, 0)) {
char* temp = libname;
// Strip the version suffix:
if (libname && not regexec(&res->version_re, libname, 1, &match, 0)) {
char* temp = libname;
- libname = strndup(temp, match.rm_so);
+ libname = strndup(temp, match.rm_so);
free(temp);
}
return libname;
}
free(temp);
}
return libname;
}
-static ssize_t pread_whole(int fd, void *buf, size_t count, off_t offset)
+static ssize_t pread_whole(int fd, void* buf, size_t count, off_t offset)
- char* buffer = (char*) buf;
+ char* buffer = (char*)buf;
ssize_t real_count = count;
while (count) {
ssize_t res = pread(fd, buffer, count, offset);
if (res > 0) {
ssize_t real_count = count;
while (count) {
ssize_t res = pread(fd, buffer, count, offset);
if (res > 0) {
buffer += res;
offset += res;
buffer += res;
offset += res;
return -1;
else if (errno != EINTR) {
perror("pread_whole");
return -1;
else if (errno != EINTR) {
perror("pread_whole");
-static ssize_t pwrite_whole(int fd, const void *buf, size_t count, off_t offset)
+static ssize_t pwrite_whole(int fd, const void* buf, size_t count, off_t offset)
- const char* buffer = (const char*) buf;
+ const char* buffer = (const char*)buf;
ssize_t real_count = count;
while (count) {
ssize_t res = pwrite(fd, buffer, count, offset);
if (res > 0) {
ssize_t real_count = count;
while (count) {
ssize_t res = pwrite(fd, buffer, count, offset);
if (res > 0) {
buffer += res;
offset += res;
buffer += res;
offset += res;
return -1;
else if (errno != EINTR)
return -1;
return -1;
else if (errno != EINTR)
return -1;
static void zero_buffer_init()
{
int fd = open("/dev/zero", O_RDONLY);
static void zero_buffer_init()
{
int fd = open("/dev/zero", O_RDONLY);
xbt_die("Could not open /dev/zero");
zero_buffer = mmap(nullptr, zero_buffer_size, PROT_READ, MAP_SHARED, fd, 0);
if (zero_buffer == MAP_FAILED)
xbt_die("Could not open /dev/zero");
zero_buffer = mmap(nullptr, zero_buffer_size, PROT_READ, MAP_SHARED, fd, 0);
if (zero_buffer == MAP_FAILED)
{
const size_t buffer_size = 30;
char buffer[buffer_size];
{
const size_t buffer_size = 30;
char buffer[buffer_size];
- int res = snprintf(buffer, buffer_size, "/proc/%lli/mem", (long long) pid);
- if (res < 0 || (size_t) res >= buffer_size) {
+ int res = snprintf(buffer, buffer_size, "/proc/%lli/mem", (long long)pid);
+ if (res < 0 || (size_t)res >= buffer_size) {
errno = ENAMETOOLONG;
return -1;
}
errno = ENAMETOOLONG;
return -1;
}
-Process::Process(pid_t pid, int sockfd) :
- AddressSpace(this), pid_(pid), channel_(sockfd), running_(true)
-{}
+RemoteClient::RemoteClient(pid_t pid, int sockfd) : AddressSpace(this), pid_(pid), channel_(sockfd), running_(true)
+{
+}
+void RemoteClient::init()
{
this->memory_map_ = simgrid::xbt::get_memory_map(this->pid_);
this->init_memory_map_info();
int fd = open_vm(this->pid_, O_RDWR);
{
this->memory_map_ = simgrid::xbt::get_memory_map(this->pid_);
this->init_memory_map_info();
int fd = open_vm(this->pid_, O_RDWR);
xbt_die("Could not open file for process virtual address space");
this->memory_file = fd;
xbt_die("Could not open file for process virtual address space");
this->memory_file = fd;
xbt_die("No heap information in the target process");
if (not std_heap_var->address)
xbt_die("No constant address for this variable");
xbt_die("No heap information in the target process");
if (not std_heap_var->address)
xbt_die("No constant address for this variable");
- this->read_bytes(&this->heap_address, sizeof(struct mdesc*),
- remote(std_heap_var->address),
- simgrid::mc::ProcessIndexDisabled);
+ this->read_bytes(&this->heap_address, sizeof(struct mdesc*), remote(std_heap_var->address),
+ simgrid::mc::ProcessIndexDisabled);
this->smx_actors_infos.clear();
this->smx_dead_actors_infos.clear();
this->smx_actors_infos.clear();
this->smx_dead_actors_infos.clear();
- this->unw_addr_space = simgrid::mc::UnwindContext::createUnwindAddressSpace();
+ this->unw_addr_space = simgrid::mc::UnwindContext::createUnwindAddressSpace();
this->unw_underlying_addr_space = simgrid::unw::create_addr_space();
this->unw_underlying_addr_space = simgrid::unw::create_addr_space();
- this->unw_underlying_context = simgrid::unw::create_context(
- this->unw_underlying_addr_space, this->pid_);
+ this->unw_underlying_context = simgrid::unw::create_context(this->unw_underlying_addr_space, this->pid_);
+RemoteClient::~RemoteClient()
{
if (this->memory_file >= 0)
close(this->memory_file);
{
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.
*/
* Do not use directly, this is used by the getters when appropriate
* in order to have fresh data.
*/
-void Process::refresh_heap()
+void RemoteClient::refresh_heap()
{
// Read/dereference/refresh the std_heap pointer:
if (not this->heap)
this->heap = std::unique_ptr<s_xbt_mheap_t>(new s_xbt_mheap_t());
{
// Read/dereference/refresh the std_heap pointer:
if (not this->heap)
this->heap = std::unique_ptr<s_xbt_mheap_t>(new s_xbt_mheap_t());
- this->read_bytes(this->heap.get(), sizeof(struct mdesc),
- remote(this->heap_address), simgrid::mc::ProcessIndexDisabled);
- this->cache_flags_ |= Process::cache_heap;
+ this->read_bytes(this->heap.get(), sizeof(struct mdesc), remote(this->heap_address),
+ simgrid::mc::ProcessIndexDisabled);
+ this->cache_flags_ |= RemoteClient::cache_heap;
}
/** Refresh the information about the process
}
/** Refresh the information about the process
* Do not use direclty, this is used by the getters when appropriate
* in order to have fresh data.
* */
* Do not use direclty, this is used by the getters when appropriate
* in order to have fresh data.
* */
-void Process::refresh_malloc_info()
+void RemoteClient::refresh_malloc_info()
{
// Refresh process->heapinfo:
{
// Refresh process->heapinfo:
- if (this->cache_flags_ & Process::cache_malloc)
+ if (this->cache_flags_ & RemoteClient::cache_malloc)
return;
size_t count = this->heap->heaplimit + 1;
if (this->heap_info.size() < count)
this->heap_info.resize(count);
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), simgrid::mc::ProcessIndexDisabled);
- this->cache_flags_ |= Process::cache_malloc;
+ this->read_bytes(this->heap_info.data(), count * sizeof(malloc_info), remote(this->heap->heapinfo),
+ simgrid::mc::ProcessIndexDisabled);
+ this->cache_flags_ |= RemoteClient::cache_malloc;
}
/** @brief Finds the range of the different memory segments and binary paths */
}
/** @brief Finds the range of the different memory segments and binary paths */
-void Process::init_memory_map_info()
+void RemoteClient::init_memory_map_info()
{
XBT_DEBUG("Get debug information ...");
this->maestro_stack_start_ = nullptr;
{
XBT_DEBUG("Get debug information ...");
this->maestro_stack_start_ = nullptr;
- this->maestro_stack_end_ = nullptr;
+ this->maestro_stack_end_ = nullptr;
this->object_infos.resize(0);
this->object_infos.resize(0);
- this->binary_info = nullptr;
+ this->binary_info = nullptr;
this->libsimgrid_info = nullptr;
struct s_mc_memory_map_re res;
this->libsimgrid_info = nullptr;
struct s_mc_memory_map_re res;
- if(regcomp(&res.so_re, SO_RE, 0) || regcomp(&res.version_re, VERSION_RE, 0))
+ if (regcomp(&res.so_re, SO_RE, 0) || regcomp(&res.version_re, VERSION_RE, 0))
xbt_die(".so regexp did not compile");
std::vector<simgrid::xbt::VmMap> const& maps = this->memory_map_;
xbt_die(".so regexp did not compile");
std::vector<simgrid::xbt::VmMap> const& maps = this->memory_map_;
this->object_infos.clear();
this->object_infos.clear();
- for (size_t i=0; i < maps.size(); i++) {
+ for (size_t i = 0; i < maps.size(); i++) {
simgrid::xbt::VmMap const& reg = maps[i];
simgrid::xbt::VmMap const& reg = maps[i];
- const char* pathname = maps[i].pathname.c_str();
+ const char* pathname = maps[i].pathname.c_str();
// Nothing to do
if (maps[i].pathname.empty()) {
// Nothing to do
if (maps[i].pathname.empty()) {
if (pathname[0] == '[') {
if ((reg.prot & PROT_WRITE) && not memcmp(pathname, "[stack]", 7)) {
this->maestro_stack_start_ = remote(reg.start_addr);
if (pathname[0] == '[') {
if ((reg.prot & PROT_WRITE) && not memcmp(pathname, "[stack]", 7)) {
this->maestro_stack_start_ = remote(reg.start_addr);
- this->maestro_stack_end_ = remote(reg.end_addr);
+ this->maestro_stack_end_ = remote(reg.end_addr);
}
current_name = nullptr;
continue;
}
}
current_name = nullptr;
continue;
}
- if (current_name && strcmp(current_name, pathname)==0)
+ if (current_name && strcmp(current_name, pathname) == 0)
continue;
current_name = pathname;
continue;
current_name = pathname;
continue;
const bool is_executable = not i;
continue;
const bool is_executable = not i;
- char* libname = nullptr;
+ char* libname = nullptr;
if (not is_executable) {
libname = get_lib_name(pathname, &res);
if (not libname)
if (not is_executable) {
libname = get_lib_name(pathname, &res);
if (not libname)
}
std::shared_ptr<simgrid::mc::ObjectInformation> info =
}
std::shared_ptr<simgrid::mc::ObjectInformation> info =
- simgrid::mc::createObjectInformation(this->memory_map_, pathname);
+ simgrid::mc::createObjectInformation(this->memory_map_, pathname);
this->object_infos.push_back(info);
if (is_executable)
this->binary_info = info;
this->object_infos.push_back(info);
if (is_executable)
this->binary_info = info;
XBT_DEBUG("Get debug information done !");
}
XBT_DEBUG("Get debug information done !");
}
-std::shared_ptr<simgrid::mc::ObjectInformation> Process::find_object_info(RemotePtr<void> addr) const
+std::shared_ptr<simgrid::mc::ObjectInformation> RemoteClient::find_object_info(RemotePtr<void> addr) const
{
for (auto const& object_info : this->object_infos)
{
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)
+ if (addr.address() >= (std::uint64_t)object_info->start && addr.address() <= (std::uint64_t)object_info->end)
return object_info;
return nullptr;
}
return object_info;
return nullptr;
}
-std::shared_ptr<ObjectInformation> Process::find_object_info_exec(RemotePtr<void> addr) const
+std::shared_ptr<ObjectInformation> RemoteClient::find_object_info_exec(RemotePtr<void> addr) const
{
for (std::shared_ptr<ObjectInformation> const& info : this->object_infos)
{
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)
+ if (addr.address() >= (std::uint64_t)info->start_exec && addr.address() <= (std::uint64_t)info->end_exec)
return info;
return nullptr;
}
return info;
return nullptr;
}
-std::shared_ptr<ObjectInformation> Process::find_object_info_rw(RemotePtr<void> addr) const
+std::shared_ptr<ObjectInformation> RemoteClient::find_object_info_rw(RemotePtr<void> addr) const
{
for (std::shared_ptr<ObjectInformation> const& info : this->object_infos)
{
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)
+ if (addr.address() >= (std::uint64_t)info->start_rw && addr.address() <= (std::uint64_t)info->end_rw)
return info;
return nullptr;
}
return info;
return nullptr;
}
-simgrid::mc::Frame* Process::find_function(RemotePtr<void> ip) const
+simgrid::mc::Frame* RemoteClient::find_function(RemotePtr<void> ip) const
{
std::shared_ptr<simgrid::mc::ObjectInformation> info = this->find_object_info_exec(ip);
{
std::shared_ptr<simgrid::mc::ObjectInformation> info = this->find_object_info_exec(ip);
- return info ? info->find_function((void*) ip.address()) : nullptr;
+ return info ? info->find_function((void*)ip.address()) : nullptr;
}
/** Find (one occurrence of) the named variable definition
*/
}
/** Find (one occurrence of) the named variable definition
*/
-simgrid::mc::Variable* Process::find_variable(const char* name) const
+simgrid::mc::Variable* RemoteClient::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
{
// First lookup the variable in the executable shared object.
// A global variable used directly by the executable code from a library
// We need to look up the variable in the executable first.
if (this->binary_info) {
std::shared_ptr<simgrid::mc::ObjectInformation> const& info = this->binary_info;
// We need to look up the variable in the executable first.
if (this->binary_info) {
std::shared_ptr<simgrid::mc::ObjectInformation> const& info = this->binary_info;
- simgrid::mc::Variable* var = info->find_variable(name);
+ simgrid::mc::Variable* var = info->find_variable(name);
-void Process::read_variable(const char* name, void* target, size_t size) const
+void RemoteClient::read_variable(const char* name, void* target, size_t size) const
{
simgrid::mc::Variable* var = this->find_variable(name);
xbt_assert(var->address, "No simple location for this variable");
{
simgrid::mc::Variable* var = this->find_variable(name);
xbt_assert(var->address, "No simple location for this variable");
this->read_bytes(target, size, remote(var->address));
}
this->read_bytes(target, size, remote(var->address));
}
-std::string Process::read_string(RemotePtr<char> address) const
+std::string RemoteClient::read_string(RemotePtr<char> address) const
{
if (not address)
return {};
{
if (not address)
return {};
off_t off = 0;
while (1) {
off_t off = 0;
while (1) {
- ssize_t c = pread(this->memory_file, res.data() + off, res.size() - off, (off_t) address.address() + off);
+ ssize_t c = pread(this->memory_file, res.data() + off, res.size() - off, (off_t)address.address() + off);
if (c == -1) {
if (errno == EINTR)
continue;
else
xbt_die("Could not read from from remote process");
}
if (c == -1) {
if (errno == EINTR)
continue;
else
xbt_die("Could not read from from remote process");
}
xbt_die("Could not read string from remote process");
void* p = memchr(res.data() + off, '\0', c);
xbt_die("Could not read string from remote process");
void* p = memchr(res.data() + off, '\0', c);
return std::string(res.data());
off += c;
return std::string(res.data());
off += c;
- if (off == (off_t) res.size())
+ if (off == (off_t)res.size())
res.resize(res.size() * 2);
}
}
res.resize(res.size() * 2);
}
}
-const void *Process::read_bytes(void* buffer, std::size_t size,
- RemotePtr<void> address, int process_index,
- ReadOptions options) const
+const void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, int process_index,
+ ReadOptions options) const
{
if (process_index != simgrid::mc::ProcessIndexDisabled) {
{
if (process_index != simgrid::mc::ProcessIndexDisabled) {
- std::shared_ptr<simgrid::mc::ObjectInformation> const& info =
- this->find_object_info_rw((void*)address.address());
- // Segment overlap is not handled.
+ std::shared_ptr<simgrid::mc::ObjectInformation> const& info = this->find_object_info_rw((void*)address.address());
+// Segment overlap is not handled.
#if HAVE_SMPI
if (info.get() && this->privatized(*info)) {
if (process_index < 0)
xbt_die("Missing process index");
#if HAVE_SMPI
if (info.get() && this->privatized(*info)) {
if (process_index < 0)
xbt_die("Missing process index");
- if (process_index >= (int) MC_smpi_process_count())
+ if (process_index >= (int)MC_smpi_process_count())
xbt_die("Invalid process index");
// Read smpi_privatization_regions from MCed:
smpi_privatization_region_t remote_smpi_privatization_regions =
xbt_die("Invalid process index");
// Read smpi_privatization_regions from MCed:
smpi_privatization_region_t remote_smpi_privatization_regions =
- mc_model_checker->process().read_variable<smpi_privatization_region_t>(
- "smpi_privatization_regions");
+ mc_model_checker->process().read_variable<smpi_privatization_region_t>("smpi_privatization_regions");
s_smpi_privatization_region_t privatization_region =
s_smpi_privatization_region_t privatization_region =
- mc_model_checker->process().read<s_smpi_privatization_region_t>(
- remote(remote_smpi_privatization_regions + process_index));
+ mc_model_checker->process().read<s_smpi_privatization_region_t>(
+ remote(remote_smpi_privatization_regions + process_index));
// Address translation in the privatization segment:
size_t offset = address.address() - (std::uint64_t)info->start_rw;
// Address translation in the privatization segment:
size_t offset = address.address() - (std::uint64_t)info->start_rw;
- address = remote((char*)privatization_region.address + offset);
+ address = remote((char*)privatization_region.address + offset);
- if (pread_whole(this->memory_file, buffer, size, (size_t) address.address()) < 0)
+ if (pread_whole(this->memory_file, buffer, size, (size_t)address.address()) < 0)
xbt_die("Read at %p from process %lli failed", (void*)address.address(), (long long)this->pid_);
return buffer;
}
xbt_die("Read at %p from process %lli failed", (void*)address.address(), (long long)this->pid_);
return buffer;
}
* @param len data size
* @param address target process memory address (target)
*/
* @param len data size
* @param address target process memory address (target)
*/
-void Process::write_bytes(const void* buffer, size_t len, RemotePtr<void> address)
+void RemoteClient::write_bytes(const void* buffer, size_t len, RemotePtr<void> address)
- if (pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) < 0)
- xbt_die("Write to process %lli failed", (long long) this->pid_);
+ if (pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) < 0)
+ xbt_die("Write to process %lli failed", (long long)this->pid_);
-void Process::clear_bytes(RemotePtr<void> address, size_t len)
+void RemoteClient::clear_bytes(RemotePtr<void> address, size_t len)
{
pthread_once(&zero_buffer_flag, zero_buffer_init);
while (len) {
size_t s = len > zero_buffer_size ? zero_buffer_size : len;
this->write_bytes(zero_buffer, s, address);
{
pthread_once(&zero_buffer_flag, zero_buffer_init);
while (len) {
size_t s = len > zero_buffer_size ? zero_buffer_size : len;
this->write_bytes(zero_buffer, s, address);
- address = remote((char*) address.address() + s);
+ address = remote((char*)address.address() + s);
-void Process::ignore_region(std::uint64_t addr, std::size_t size)
+void RemoteClient::ignore_region(std::uint64_t addr, std::size_t size)
{
IgnoredRegion region;
region.addr = addr;
{
IgnoredRegion region;
region.addr = addr;
- unsigned int cursor = 0;
+ unsigned int cursor = 0;
IgnoredRegion* current_region = nullptr;
int start = 0;
IgnoredRegion* current_region = nullptr;
int start = 0;
- int end = ignored_regions_.size() - 1;
+ int end = ignored_regions_.size() - 1;
- cursor = (start + end) / 2;
+ cursor = (start + end) / 2;
current_region = &ignored_regions_[cursor];
if (current_region->addr == addr) {
if (current_region->size == size)
current_region = &ignored_regions_[cursor];
if (current_region->addr == addr) {
if (current_region->size == size)
position = cursor + 1;
else
position = cursor;
position = cursor + 1;
else
position = cursor;
- ignored_regions_.insert(
- ignored_regions_.begin() + position, region);
+ ignored_regions_.insert(ignored_regions_.begin() + position, region);
-void Process::ignore_heap(IgnoredHeapRegion const& region)
+void RemoteClient::ignore_heap(IgnoredHeapRegion const& region)
{
if (ignored_heap_.empty()) {
ignored_heap_.push_back(std::move(region));
{
if (ignored_heap_.empty()) {
ignored_heap_.push_back(std::move(region));
typedef std::vector<IgnoredHeapRegion>::size_type size_type;
size_type start = 0;
typedef std::vector<IgnoredHeapRegion>::size_type size_type;
size_type start = 0;
- size_type end = ignored_heap_.size() - 1;
+ size_type end = ignored_heap_.size() - 1;
// Binary search the position of insertion:
size_type cursor;
while (start <= end) {
// Binary search the position of insertion:
size_type cursor;
while (start <= end) {
- cursor = start + (end - start) / 2;
+ cursor = start + (end - start) / 2;
auto& current_region = ignored_heap_[cursor];
if (current_region.address == region.address)
return;
auto& current_region = ignored_heap_[cursor];
if (current_region.address == region.address)
return;
// Insert it mc_heap_ignore_region_t:
if (ignored_heap_[cursor].address < region.address)
++cursor;
// Insert it mc_heap_ignore_region_t:
if (ignored_heap_[cursor].address < region.address)
++cursor;
- ignored_heap_.insert( ignored_heap_.begin() + cursor, region);
+ ignored_heap_.insert(ignored_heap_.begin() + cursor, region);
-void Process::unignore_heap(void *address, size_t size)
+void RemoteClient::unignore_heap(void* address, size_t size)
{
typedef std::vector<IgnoredHeapRegion>::size_type size_type;
size_type start = 0;
{
typedef std::vector<IgnoredHeapRegion>::size_type size_type;
size_type start = 0;
- size_type end = ignored_heap_.size() - 1;
+ size_type end = ignored_heap_.size() - 1;
// Binary search:
size_type cursor;
while (start <= end) {
// Binary search:
size_type cursor;
while (start <= end) {
- cursor = (start + end) / 2;
+ cursor = (start + end) / 2;
auto& region = ignored_heap_[cursor];
if (region.address == address) {
ignored_heap_.erase(ignored_heap_.begin() + cursor);
return;
} else if (region.address < address)
start = cursor + 1;
auto& region = ignored_heap_[cursor];
if (region.address == address) {
ignored_heap_.erase(ignored_heap_.begin() + cursor);
return;
} else if (region.address < address)
start = cursor + 1;
- else if ((char *) region.address <= ((char *) address + size)) {
+ else if ((char*)region.address <= ((char*)address + size)) {
ignored_heap_.erase(ignored_heap_.begin() + cursor);
return;
} else if (cursor != 0)
ignored_heap_.erase(ignored_heap_.begin() + cursor);
return;
} else if (cursor != 0)
-void Process::ignore_local_variable(const char *var_name, const char *frame_name)
+void RemoteClient::ignore_local_variable(const char* var_name, const char* frame_name)
{
if (frame_name != nullptr && strcmp(frame_name, "*") == 0)
frame_name = nullptr;
{
if (frame_name != nullptr && strcmp(frame_name, "*") == 0)
frame_name = nullptr;
- for (std::shared_ptr<simgrid::mc::ObjectInformation> const& info :
- this->object_infos)
+ for (std::shared_ptr<simgrid::mc::ObjectInformation> const& info : this->object_infos)
info->remove_local_variable(var_name, frame_name);
}
info->remove_local_variable(var_name, frame_name);
}
-std::vector<simgrid::mc::ActorInformation>& Process::actors()
+std::vector<simgrid::mc::ActorInformation>& RemoteClient::actors()
{
this->refresh_simix();
return smx_actors_infos;
}
{
this->refresh_simix();
return smx_actors_infos;
}
-std::vector<simgrid::mc::ActorInformation>& Process::dead_actors()
+std::vector<simgrid::mc::ActorInformation>& RemoteClient::dead_actors()
{
this->refresh_simix();
return smx_dead_actors_infos;
}
{
this->refresh_simix();
return smx_dead_actors_infos;
}
-void Process::dumpStack()
+void RemoteClient::dumpStack()
{
unw_addr_space_t as = unw_create_addr_space(&_UPT_accessors, BYTE_ORDER);
if (as == nullptr) {
{
unw_addr_space_t as = unw_create_addr_space(&_UPT_accessors, BYTE_ORDER);
if (as == nullptr) {
unw_destroy_addr_space(as);
return;
}
unw_destroy_addr_space(as);
return;
}
-/* Copyright (c) 2008-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2008-2017. 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. */
/* 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. */
#ifndef SIMGRID_MC_PROCESS_H
#define SIMGRID_MC_PROCESS_H
#ifndef SIMGRID_MC_PROCESS_H
#define SIMGRID_MC_PROCESS_H
-#include <type_traits>
-#include <vector>
#include <memory>
#include <string>
#include <memory>
#include <string>
+#include <type_traits>
+#include <vector>
#include "src/mc/remote/Channel.hpp"
#include "src/mc/remote/RemotePtr.hpp"
#include "src/mc/remote/Channel.hpp"
#include "src/mc/remote/RemotePtr.hpp"
-#include <simgrid/simix.h>
#include "src/simix/popping_private.h"
#include "src/simix/smx_private.h"
#include "src/simix/popping_private.h"
#include "src/simix/smx_private.h"
+#include <simgrid/simix.h>
#include "src/xbt/memory_map.hpp"
#include "src/xbt/memory_map.hpp"
void clear()
{
name.clear();
void clear()
{
name.clear();
struct IgnoredHeapRegion {
int block;
int fragment;
struct IgnoredHeapRegion {
int block;
int fragment;
-/** Representation of a process
+/** The Model-Checked process, seen from the MCer perspective
*
* This class is mixing a lot of different responsibilities and is tied
* to SIMIX. It should probably be split into different classes.
*
* This class is mixing a lot of different responsibilities and is tied
* to SIMIX. It should probably be split into different classes.
* - stack unwinding;
* - etc.
*/
* - stack unwinding;
* - etc.
*/
-class Process final : public AddressSpace {
+class RemoteClient 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.
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;
static constexpr int cache_simix_processes = 4;
static constexpr int cache_simix_processes = 4;
- Process(pid_t pid, int sockfd);
- ~Process();
+ RemoteClient(pid_t pid, int sockfd);
+ ~RemoteClient();
- Process(Process const&) = delete;
- Process(Process &&) = delete;
- Process& operator=(Process const&) = delete;
- Process& operator=(Process &&) = delete;
+ RemoteClient(RemoteClient const&) = delete;
+ RemoteClient(RemoteClient&&) = delete;
+ RemoteClient& operator=(RemoteClient const&) = delete;
+ RemoteClient& operator=(RemoteClient&&) = delete;
- const void* read_bytes(void* buffer, std::size_t size,
- RemotePtr<void> address, int process_index = ProcessIndexAny,
- ReadOptions options = ReadOptions::none()) const override;
+ const void* read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, int process_index = ProcessIndexAny,
+ ReadOptions options = ReadOptions::none()) const override;
void read_variable(const char* name, void* target, size_t size) const;
void read_variable(const char* name, void* target, size_t size) const;
- template<class T> void read_variable(const char* name, T* target) const
+ template <class T> void read_variable(const char* name, T* target) const
{
read_variable(name, target, sizeof(*target));
}
{
read_variable(name, target, sizeof(*target));
}
- template<class T>
- Remote<T> read_variable(const char *name) const
+ template <class T> Remote<T> read_variable(const char* name) const
{
Remote<T> res;
read_variable(name, res.getBuffer(), sizeof(T));
{
Remote<T> res;
read_variable(name, res.getBuffer(), sizeof(T));
// Heap access:
xbt_mheap_t get_heap()
{
// Heap access:
xbt_mheap_t get_heap()
{
- if (not(this->cache_flags_ & Process::cache_heap))
+ if (not(this->cache_flags_ & RemoteClient::cache_heap))
this->refresh_heap();
return this->heap.get();
}
const malloc_info* get_malloc_info()
{
this->refresh_heap();
return this->heap.get();
}
const malloc_info* get_malloc_info()
{
- if (not(this->cache_flags_ & Process::cache_malloc))
+ if (not(this->cache_flags_ & RemoteClient::cache_malloc))
this->refresh_malloc_info();
return this->heap_info.data();
}
this->refresh_malloc_info();
return this->heap_info.data();
}
- void clear_cache()
- {
- this->cache_flags_ = Process::cache_none;
- }
+ void clear_cache() { this->cache_flags_ = RemoteClient::cache_none; }
Channel const& getChannel() const { return channel_; }
Channel& getChannel() { return channel_; }
Channel const& getChannel() const { return channel_; }
Channel& getChannel() { return channel_; }
- std::vector<IgnoredRegion> const& ignored_regions() const
- {
- return ignored_regions_;
- }
+ std::vector<IgnoredRegion> const& ignored_regions() const { return ignored_regions_; }
void ignore_region(std::uint64_t address, std::size_t size);
pid_t pid() const { return pid_; }
void ignore_region(std::uint64_t address, std::size_t size);
pid_t pid() const { return pid_; }
return p >= this->maestro_stack_start_ && p < this->maestro_stack_end_;
}
return p >= this->maestro_stack_start_ && p < this->maestro_stack_end_;
}
- bool running() const
- {
- return running_;
- }
+ bool running() const { return running_; }
- void terminate()
- {
- running_ = false;
- }
+ void terminate() { running_ = false; }
- bool privatized(ObjectInformation const& info) const
- {
- return privatized_ && info.executable();
- }
- bool privatized() const
- {
- return privatized_;
- }
+ bool privatized(ObjectInformation const& info) const { return privatized_ && info.executable(); }
+ bool privatized() const { return privatized_; }
void privatized(bool privatized) { privatized_ = privatized; }
void ignore_global_variable(const char* name)
{
void privatized(bool privatized) { privatized_ = privatized; }
void ignore_global_variable(const char* name)
{
- for (std::shared_ptr<simgrid::mc::ObjectInformation> const& info :
- this->object_infos)
+ for (std::shared_ptr<simgrid::mc::ObjectInformation> const& info : this->object_infos)
info->remove_global_variable(name);
}
info->remove_global_variable(name);
}
- std::vector<s_stack_region_t>& stack_areas()
- {
- return stack_areas_;
- }
- std::vector<s_stack_region_t> const& stack_areas() const
- {
- return stack_areas_;
- }
+ std::vector<s_stack_region_t>& stack_areas() { return stack_areas_; }
+ std::vector<s_stack_region_t> const& stack_areas() const { return stack_areas_; }
- std::vector<IgnoredHeapRegion> const& ignored_heap() const
- {
- return ignored_heap_;
- }
+ std::vector<IgnoredHeapRegion> const& ignored_heap() const { return ignored_heap_; }
void ignore_heap(IgnoredHeapRegion const& region);
void ignore_heap(IgnoredHeapRegion const& region);
- void unignore_heap(void *address, size_t size);
+ void unignore_heap(void* address, size_t size);
- void ignore_local_variable(const char *var_name, const char *frame_name);
+ void ignore_local_variable(const char* var_name, const char* frame_name);
std::vector<simgrid::mc::ActorInformation>& actors();
std::vector<simgrid::mc::ActorInformation>& dead_actors();
std::vector<simgrid::mc::ActorInformation>& actors();
std::vector<simgrid::mc::ActorInformation>& dead_actors();
std::shared_ptr<simgrid::mc::ObjectInformation> binary_info;
public: // Copies of MCed SMX data structures
std::shared_ptr<simgrid::mc::ObjectInformation> binary_info;
public: // Copies of MCed SMX data structures
- /** Copy of `simix_global->process_list`
- *
- * See mc_smx.c.
- */
+ /** Copy of `simix_global->process_list`
+ *
+ * See mc_smx.c.
+ */
std::vector<ActorInformation> smx_actors_infos;
/** Copy of `simix_global->process_to_destroy`
std::vector<ActorInformation> smx_actors_infos;
/** Copy of `simix_global->process_to_destroy`
private:
/** State of the cache (which variables are up to date) */
private:
/** State of the cache (which variables are up to date) */
- int cache_flags_ = Process::cache_none;
+ int cache_flags_ = RemoteClient::cache_none;
public:
/** Address of the heap structure in the MCed process. */
public:
/** Address of the heap structure in the MCed process. */
* This is not used if the process is the current one:
* use `get_heap_info()` in order to use it.
*/
* This is not used if the process is the current one:
* use `get_heap_info()` in order to use it.
*/
- std::unique_ptr<s_xbt_mheap_t> heap;
+ std::unique_ptr<s_xbt_mheap_t> heap;
/** Copy of the allocation info structure
*
/** Copy of the allocation info structure
*
std::vector<malloc_info> heap_info;
public: // Libunwind-data
std::vector<malloc_info> heap_info;
public: // Libunwind-data
-
- /** Full-featured MC-aware libunwind address space for the process
- *
- * This address space is using a simgrid::mc::UnwindContext*
- * (with simgrid::mc::Process* / simgrid::mc::AddressSpace*
- * and unw_context_t).
- */
+ /** Full-featured MC-aware libunwind address space for the process
+ *
+ * This address space is using a simgrid::mc::UnwindContext*
+ * (with simgrid::mc::Process* / simgrid::mc::AddressSpace*
+ * and unw_context_t).
+ */
unw_addr_space_t unw_addr_space;
/** Underlying libunwind address-space
unw_addr_space_t unw_addr_space;
/** Underlying libunwind address-space
/** Open a FD to a remote process memory (`/dev/$pid/mem`)
*/
XBT_PRIVATE int open_vm(pid_t pid, int flags);
/** Open a FD to a remote process memory (`/dev/$pid/mem`)
*/
XBT_PRIVATE int open_vm(pid_t pid, int flags);
#include "src/mc/mc_private.h"
#include "src/mc/mc_private.h"
-#include "src/mc/Process.hpp"
-#include "src/mc/Type.hpp"
#include "src/mc/ObjectInformation.hpp"
#include "src/mc/ObjectInformation.hpp"
+#include "src/mc/Type.hpp"
#include "src/mc/Variable.hpp"
#include "src/mc/Variable.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
-static simgrid::mc::Process* process;
+static simgrid::mc::RemoteClient* process;
static
uintptr_t eval_binary_operation(
static
uintptr_t eval_binary_operation(
}
int main(int argc, char** argv) {
}
int main(int argc, char** argv) {
- process = new simgrid::mc::Process(getpid(), -1);
+ process = new simgrid::mc::RemoteClient(getpid(), -1);
process->init();
simgrid::dwarf::ExpressionContext state;
process->init();
simgrid::dwarf::ExpressionContext state;
#include "mc/datatypes.h"
#include "src/mc/mc_private.h"
#include "mc/datatypes.h"
#include "src/mc/mc_private.h"
-#include "src/mc/Process.hpp"
-#include "src/mc/Type.hpp"
#include "src/mc/ObjectInformation.hpp"
#include "src/mc/ObjectInformation.hpp"
+#include "src/mc/Type.hpp"
#include "src/mc/Variable.hpp"
#include "src/mc/Variable.hpp"
+#include "src/mc/remote/RemoteClient.hpp"
int test_some_array[4][5][6];
struct some_struct {
int test_some_array[4][5][6];
struct some_struct {
xbt_assert(location.address() == address, "Bad resolution of local variable %s of %s", variable, function);
}
xbt_assert(location.address() == address, "Bad resolution of local variable %s of %s", variable, function);
}
-static simgrid::mc::Variable* test_global_variable(
- simgrid::mc::Process& process, simgrid::mc::ObjectInformation* info,
- const char* name, void* address, long byte_size)
+static simgrid::mc::Variable* test_global_variable(simgrid::mc::RemoteClient& process,
+ simgrid::mc::ObjectInformation* info, const char* name,
+ void* address, long byte_size)
{
simgrid::mc::Variable* variable = info->find_variable(name);
xbt_assert(variable, "Global variable %s was not found", name);
{
simgrid::mc::Variable* variable = info->find_variable(name);
xbt_assert(variable, "Global variable %s was not found", name);
typedef struct foo {int i;} s_foo;
typedef struct foo {int i;} s_foo;
-static void test_type_by_name(simgrid::mc::Process& process, s_foo my_foo)
+static void test_type_by_name(simgrid::mc::RemoteClient& process, s_foo my_foo)
{
assert(process.binary_info->full_types_by_name.find("struct foo") != process.binary_info->full_types_by_name.end());
}
{
assert(process.binary_info->full_types_by_name.find("struct foo") != process.binary_info->full_types_by_name.end());
}
simgrid::mc::Variable* var;
simgrid::mc::Type* type;
simgrid::mc::Variable* var;
simgrid::mc::Type* type;
- simgrid::mc::Process process(getpid(), -1);
+ simgrid::mc::RemoteClient process(getpid(), -1);
process.init();
test_global_variable(process, process.binary_info.get(), "some_local_variable", &some_local_variable, sizeof(int));
process.init();
test_global_variable(process, process.binary_info.get(), "some_local_variable", &some_local_variable, sizeof(int));
src/mc/remote/Channel.hpp
src/mc/remote/Client.cpp
src/mc/remote/Client.hpp
src/mc/remote/Channel.hpp
src/mc/remote/Client.cpp
src/mc/remote/Client.hpp
+ src/mc/remote/RemoteClient.hpp
+ src/mc/remote/RemoteClient.cpp
src/mc/remote/RemotePtr.hpp
src/mc/remote/mc_protocol.h
src/mc/remote/mc_protocol.cpp
src/mc/remote/RemotePtr.hpp
src/mc/remote/mc_protocol.h
src/mc/remote/mc_protocol.cpp
src/mc/Type.hpp
src/mc/Variable.hpp
src/mc/mc_forward.hpp
src/mc/Type.hpp
src/mc/Variable.hpp
src/mc/mc_forward.hpp
- src/mc/Process.hpp
- src/mc/Process.cpp
src/mc/Session.cpp
src/mc/Session.hpp
src/mc/mc_unw.h
src/mc/Session.cpp
src/mc/Session.hpp
src/mc/mc_unw.h