#include <vector>
#include "src/mc/mc_forward.hpp"
-#include "src/mc/RemotePtr.hpp"
+#include "src/mc/remote/RemotePtr.hpp"
namespace simgrid {
namespace mc {
#include "simgrid/sg_config.h"
#include "src/mc/ModelChecker.hpp"
-#include "src/mc/PageStore.hpp"
#include "src/mc/ModelChecker.hpp"
-#include "src/mc/mc_protocol.h"
-#include "src/mc/mc_private.h"
-#include "src/mc/mc_ignore.h"
-#include "src/mc/mc_exit.h"
-#include "src/mc/mc_record.h"
+#include "src/mc/PageStore.hpp"
#include "src/mc/Transition.hpp"
#include "src/mc/checker/Checker.hpp"
+#include "src/mc/mc_exit.h"
+#include "src/mc/mc_ignore.h"
+#include "src/mc/mc_private.h"
+#include "src/mc/mc_record.h"
+#include "src/mc/remote/mc_protocol.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_ModelChecker, mc, "ModelChecker");
#include <xbt/base.h>
#include <sys/types.h>
-#include "src/mc/mc_forward.hpp"
-#include "src/mc/Process.hpp"
#include "src/mc/PageStore.hpp"
-#include "src/mc/mc_protocol.h"
+#include "src/mc/Process.hpp"
#include "src/mc/Transition.hpp"
+#include "src/mc/mc_forward.hpp"
+#include "src/mc/remote/mc_protocol.h"
namespace simgrid {
namespace mc {
#include <xbt/mmalloc.h>
#include "src/xbt/mmalloc/mmprivate.h"
-#include "src/mc/Channel.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/xbt/memory_map.hpp"
-#include "src/mc/mc_forward.hpp"
-#include "src/mc/mc_base.h"
-#include "src/mc/RemotePtr.hpp"
#include "src/mc/AddressSpace.hpp"
-#include "src/mc/mc_protocol.h"
#include "src/mc/ObjectInformation.hpp"
-
+#include "src/mc/mc_base.h"
+#include "src/mc/mc_forward.hpp"
+#include "src/mc/remote/mc_protocol.h"
namespace simgrid {
namespace mc {
#include <xbt/base.h>
-#include "src/mc/RemotePtr.hpp"
-#include "src/mc/PageStore.hpp"
#include "src/mc/AddressSpace.hpp"
#include "src/mc/ChunkedData.hpp"
+#include "src/mc/PageStore.hpp"
+#include "src/mc/remote/RemotePtr.hpp"
namespace simgrid {
namespace mc {
#include <xbt/log.h>
#include <xbt/sysdep.h>
-#include "src/mc/mc_state.h"
+#include "src/mc/Transition.hpp"
+#include "src/mc/VisitedState.hpp"
+#include "src/mc/checker/CommunicationDeterminismChecker.hpp"
#include "src/mc/mc_comm_pattern.h"
-#include "src/mc/mc_request.h"
-#include "src/mc/mc_safety.h"
+#include "src/mc/mc_exit.h"
#include "src/mc/mc_private.h"
#include "src/mc/mc_record.h"
+#include "src/mc/mc_request.h"
+#include "src/mc/mc_safety.h"
#include "src/mc/mc_smx.h"
-#include "src/mc/Client.hpp"
-#include "src/mc/checker/CommunicationDeterminismChecker.hpp"
-#include "src/mc/mc_exit.h"
-#include "src/mc/VisitedState.hpp"
-#include "src/mc/Transition.hpp"
+#include "src/mc/mc_state.h"
+#include "src/mc/remote/Client.hpp"
using simgrid::mc::remote;
#include <xbt/log.h>
#include <xbt/sysdep.h>
-#include "src/mc/mc_request.h"
+#include "src/mc/Session.hpp"
+#include "src/mc/Transition.hpp"
#include "src/mc/checker/LivenessChecker.hpp"
+#include "src/mc/mc_exit.h"
#include "src/mc/mc_private.h"
-#include "src/mc/mc_record.h"
-#include "src/mc/mc_smx.h"
-#include "src/mc/Client.hpp"
#include "src/mc/mc_private.h"
+#include "src/mc/mc_record.h"
#include "src/mc/mc_replay.h"
+#include "src/mc/mc_request.h"
#include "src/mc/mc_safety.h"
-#include "src/mc/mc_exit.h"
-#include "src/mc/Transition.hpp"
-#include "src/mc/Session.hpp"
+#include "src/mc/mc_smx.h"
+#include "src/mc/remote/Client.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
"Logging specific to algorithms for liveness properties verification");
#include <xbt/log.h>
#include <xbt/sysdep.h>
-#include "src/mc/mc_state.h"
-#include "src/mc/mc_request.h"
-#include "src/mc/mc_safety.h"
+#include "src/mc/Session.hpp"
+#include "src/mc/Transition.hpp"
+#include "src/mc/VisitedState.hpp"
+#include "src/mc/checker/SafetyChecker.hpp"
+#include "src/mc/mc_exit.h"
#include "src/mc/mc_private.h"
#include "src/mc/mc_record.h"
+#include "src/mc/mc_request.h"
+#include "src/mc/mc_safety.h"
#include "src/mc/mc_smx.h"
-#include "src/mc/Client.hpp"
-#include "src/mc/mc_exit.h"
-#include "src/mc/checker/SafetyChecker.hpp"
-#include "src/mc/VisitedState.hpp"
-#include "src/mc/Transition.hpp"
-#include "src/mc/Session.hpp"
+#include "src/mc/mc_state.h"
+#include "src/mc/remote/Client.hpp"
#include "src/xbt/mmalloc/mmprivate.h"
#include "simgrid/sg_config.h"
#include "src/xbt_modinter.h"
+#include "src/mc/Session.hpp"
+#include "src/mc/checker/Checker.hpp"
#include "src/mc/mc_base.h"
-#include "src/mc/mc_private.h"
-#include "src/mc/mc_protocol.h"
-#include "src/mc/mc_safety.h"
#include "src/mc/mc_comm_pattern.h"
#include "src/mc/mc_exit.h"
-#include "src/mc/Session.hpp"
-#include "src/mc/checker/Checker.hpp"
+#include "src/mc/mc_private.h"
+#include "src/mc/mc_safety.h"
+#include "src/mc/remote/mc_protocol.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_main, mc, "Entry point for simgrid-mc");
#include <simgrid/simix.h>
+#include "mc/mc.h"
#include "src/mc/mc_base.h"
-#include "src/simix/smx_private.h"
#include "src/mc/mc_replay.h"
-#include "mc/mc.h"
-#include "src/mc/mc_protocol.h"
+#include "src/mc/remote/mc_protocol.h"
+#include "src/simix/smx_private.h"
#include "src/kernel/activity/ActivityImpl.hpp"
#include "src/kernel/activity/SynchroIo.hpp"
#include "src/mc/mc_private.h"
#include <mc/mc.h>
-#include "src/mc/mc_snapshot.h"
+#include "src/mc/mc_hash.hpp"
#include "src/mc/mc_mmu.h"
-#include "src/mc/mc_unw.h"
-#include "src/mc/mc_protocol.h"
#include "src/mc/mc_smx.h"
-#include "mc_hash.hpp"
+#include "src/mc/mc_snapshot.h"
+#include "src/mc/mc_unw.h"
+#include "src/mc/remote/mc_protocol.h"
#include "src/mc/RegionSnapshot.hpp"
#include "src/mc/ObjectInformation.hpp"
#include <xbt/sysdep.h>
#include <simgrid/modelchecker.h>
-#include "src/mc/mc_record.h"
-#include "src/mc/mc_private.h"
-#include "src/mc/mc_ignore.h"
-#include "src/mc/mc_protocol.h"
-#include "src/mc/Client.hpp"
#include "src/mc/ModelChecker.hpp"
+#include "src/mc/mc_ignore.h"
+#include "src/mc/mc_private.h"
+#include "src/mc/mc_record.h"
+#include "src/mc/remote/Client.hpp"
+#include "src/mc/remote/mc_protocol.h"
/** @file mc_client_api.cpp
*
#include "src/mc/checker/Checker.hpp"
#endif
-#include "src/mc/mc_record.h"
-#include "src/mc/mc_protocol.h"
-#include "src/mc/Client.hpp"
#include "src/mc/Transition.hpp"
+#include "src/mc/mc_record.h"
+#include "src/mc/remote/Client.hpp"
+#include "src/mc/remote/mc_protocol.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_global, mc, "Logging specific to MC (global)");
+++ /dev/null
-/* Copyright (c) 2015. 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. */
-
-#include <errno.h>
-#include <string.h>
-#include <stdio.h> // perror
-#include <cstddef> // std::size_t
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <xbt/log.h>
-
-#include "src/mc/mc_protocol.h"
-#include "src/mc/Client.hpp"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_protocol, mc, "Generic MC protocol logic");
-
-const char* MC_message_type_name(e_mc_message_type type)
-{
- switch(type) {
- case MC_MESSAGE_NONE:
- return "NONE";
- case MC_MESSAGE_CONTINUE:
- return "CONTINUE";
- case MC_MESSAGE_IGNORE_HEAP:
- return "IGNORE_HEAP";
- case MC_MESSAGE_UNIGNORE_HEAP:
- return "UNIGNORE_HEAP";
- case MC_MESSAGE_IGNORE_MEMORY:
- return "IGNORE_MEMORY";
- case MC_MESSAGE_STACK_REGION:
- return "STACK_REGION";
- case MC_MESSAGE_REGISTER_SYMBOL:
- return "REGISTER_SYMBOL";
- case MC_MESSAGE_DEADLOCK_CHECK:
- return "DEADLOCK_CHECK";
- case MC_MESSAGE_DEADLOCK_CHECK_REPLY:
- return "DEADLOCK_CHECK_REPLY";
- case MC_MESSAGE_WAITING:
- return "WAITING";
- case MC_MESSAGE_SIMCALL_HANDLE:
- return "SIMCALL_HANDLE";
- case MC_MESSAGE_ASSERTION_FAILED:
- return "ASSERTION_FAILED";
- default:
- return "?";
- }
-}
#include "src/smpi/private.h"
#include "src/mc/Process.hpp"
-#include "src/mc/mc_protocol.h"
+#include "src/mc/remote/mc_protocol.h"
/** @file
* @brief (Cross-process, MCer/MCed) Access to SMX structures
#include <cstddef>
-#include "src/mc/RemotePtr.hpp"
#include "src/mc/AddressSpace.hpp"
#include "src/mc/mc_xbt.hpp"
+#include "src/mc/remote/RemotePtr.hpp"
#include <xbt/dynar.h>
#include <xbt/sysdep.h>
#include <xbt/dynar.h>
-#include "src/mc/RemotePtr.hpp"
#include "src/mc/AddressSpace.hpp"
+#include "src/mc/remote/RemotePtr.hpp"
namespace simgrid {
namespace mc {
#include <errno.h>
#include <unistd.h>
-#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/types.h>
#include <xbt/log.h>
-#include "src/mc/Channel.hpp"
+#include "src/mc/remote/Channel.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_Channel, mc, "MC interprocess communication");
Channel::~Channel()
{
- if (this->socket_ >=0)
+ if (this->socket_ >= 0)
close(this->socket_);
}
int Channel::send(const void* message, size_t size) const
{
- XBT_DEBUG("Send %s",
- MC_message_type_name(*(e_mc_message_type*) message));
+ XBT_DEBUG("Send %s", MC_message_type_name(*(e_mc_message_type*)message));
while (::send(this->socket_, message, size, 0) == -1)
if (errno == EINTR)
continue;
{
int res = recv(this->socket_, message, size, block ? 0 : MSG_DONTWAIT);
if (res != -1)
- XBT_DEBUG("Receive %s",
- MC_message_type_name(*(e_mc_message_type*) message));
+ XBT_DEBUG("Receive %s", MC_message_type_name(*(e_mc_message_type*)message));
return res;
}
-
}
}
#include <type_traits>
-#include "src/mc/mc_protocol.h"
+#include "src/mc/remote/mc_protocol.h"
namespace simgrid {
namespace mc {
*/
class Channel {
int socket_ = -1;
- template<class M>
- static constexpr bool messageType()
+ template <class M> static constexpr bool messageType()
{
return std::is_class<M>::value && std::is_trivial<M>::value;
}
-public:
+public:
Channel() {}
explicit Channel(int sock) : socket_(sock) {}
~Channel();
Channel& operator=(Channel const&) = delete;
// Move:
- Channel(Channel&& that) : socket_(that.socket_)
- {
- that.socket_ = -1;
- }
+ Channel(Channel&& that) : socket_(that.socket_) { that.socket_ = -1; }
Channel& operator=(Channel&& that)
{
this->socket_ = that.socket_;
- that.socket_ = -1;
+ that.socket_ = -1;
return *this;
}
int send(const void* message, size_t size) const;
int send(e_mc_message_type type) const
{
- s_mc_message message = { type };
+ s_mc_message message = {type};
return this->send(&message, sizeof(message));
}
- template<class M>
- typename std::enable_if< messageType<M>(), int >::type
- send(M const& m) const
+ template <class M> typename std::enable_if<messageType<M>(), int>::type send(M const& m) const
{
return this->send(&m, sizeof(M));
}
// Receive
ssize_t receive(void* message, size_t size, bool block = true) const;
- template<class M>
- typename std::enable_if< messageType<M>(), ssize_t >::type
- receive(M& m) const
+ template <class M> typename std::enable_if<messageType<M>(), ssize_t>::type receive(M& m) const
{
return this->receive(&m, sizeof(M));
}
- int getSocket() const
- {
- return socket_;
- }
-
+ int getSocket() const { return socket_; }
};
-
}
}
/* 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. */
-#include <cstdlib>
#include <cerrno>
+#include <cstdlib>
-#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/socket.h>
+#include <sys/types.h>
#include <xbt/log.h>
-#include <xbt/sysdep.h>
#include <xbt/mmalloc.h>
#include <xbt/swag.h>
+#include <xbt/sysdep.h>
#include <simgrid/modelchecker.h>
#include "src/internal_config.h"
-#include "src/mc/mc_protocol.h"
-#include "src/mc/Client.hpp"
#include "src/mc/mc_request.h"
+#include "src/mc/remote/Client.hpp"
+#include "src/mc/remote/mc_protocol.h"
// We won't need those once the separation MCer/MCed is complete:
#include "src/mc/mc_ignore.h"
char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
if (!fd_env)
xbt_die("No MC socket passed in the environment");
- int fd = xbt_str_parse_int(fd_env, bprintf("Variable %s should contain a number but contains '%%s'", MC_ENV_SOCKET_FD));
+ int fd =
+ xbt_str_parse_int(fd_env, bprintf("Variable %s should contain a number but contains '%%s'", MC_ENV_SOCKET_FD));
XBT_DEBUG("Model-checked application found socket FD %i", fd);
// Check the socket type/validity:
#elif defined BSD
ptrace(PT_TRACE_ME, 0, nullptr, 0);
#else
-# error "no ptrace equivalent coded for this platform"
+#error "no ptrace equivalent coded for this platform"
#endif
- if(errno != 0 || raise(SIGSTOP) != 0)
+ if (errno != 0 || raise(SIGSTOP) != 0)
xbt_die("Could not wait for the model-checker");
client_->handleMessages();
xbt_die("Could not receive commands from the model-checker");
s_mc_message_t message;
- if ((size_t) s < sizeof(message))
+ if ((size_t)s < sizeof(message))
xbt_die("Received message is too small");
memcpy(&message, message_buffer, sizeof(message));
switch (message.type) {
- case MC_MESSAGE_DEADLOCK_CHECK:
- {
+ case MC_MESSAGE_DEADLOCK_CHECK: {
// Check deadlock:
bool deadlock = false;
smx_actor_t actor;
{
deadlock = false;
break;
- }
+ }
}
// Send result:
s_mc_int_message_t answer;
- answer.type = MC_MESSAGE_DEADLOCK_CHECK_REPLY;
+ answer.type = MC_MESSAGE_DEADLOCK_CHECK_REPLY;
answer.value = deadlock;
if (channel_.send(answer))
xbt_die("Could not send response");
- }
- break;
+ } break;
- case MC_MESSAGE_CONTINUE:
- return;
+ case MC_MESSAGE_CONTINUE:
+ return;
- case MC_MESSAGE_SIMCALL_HANDLE:
- {
+ case MC_MESSAGE_SIMCALL_HANDLE: {
s_mc_simcall_handle_message_t message;
if (s != sizeof(message))
xbt_die("Unexpected size for SIMCALL_HANDLE");
memcpy(&message, message_buffer, sizeof(message));
smx_actor_t process = SIMIX_process_from_PID(message.pid);
if (!process)
- xbt_die("Invalid pid %lu", (unsigned long) message.pid);
+ xbt_die("Invalid pid %lu", (unsigned long)message.pid);
SIMIX_simcall_handle(&process->simcall, message.value);
if (channel_.send(MC_MESSAGE_WAITING))
xbt_die("Could not send MESSAGE_WAITING to model-checker");
- }
- break;
+ } break;
- case MC_MESSAGE_RESTORE:
- {
+ case MC_MESSAGE_RESTORE: {
s_mc_restore_message_t message;
if (s != sizeof(message))
xbt_die("Unexpected size for SIMCALL_HANDLE");
#if HAVE_SMPI
smpi_really_switch_data_segment(message.index);
#endif
- }
- break;
-
- default:
- xbt_die("Received unexpected message %s (%i)",
- MC_message_type_name(message.type),
- message.type
- );
+ } break;
+
+ default:
+ xbt_die("Received unexpected message %s (%i)", MC_message_type_name(message.type), message.type);
}
}
}
{
s_mc_ignore_memory_message_t message;
message.type = MC_MESSAGE_IGNORE_MEMORY;
- message.addr = (std::uintptr_t) addr;
+ message.addr = (std::uintptr_t)addr;
message.size = size;
if (channel_.send(message))
xbt_die("Could not send IGNORE_MEMORY mesage to model-checker");
xbt_mheap_t heap = mmalloc_get_current_heap();
s_mc_ignore_heap_message_t message;
- message.type = MC_MESSAGE_IGNORE_HEAP;
+ message.type = MC_MESSAGE_IGNORE_HEAP;
message.address = address;
- message.size = size;
- message.block =
- ((char *) address -
- (char *) heap->heapbase) / BLOCKSIZE + 1;
+ message.size = size;
+ message.block = ((char*)address - (char*)heap->heapbase) / BLOCKSIZE + 1;
if (heap->heapinfo[message.block].type == 0) {
message.fragment = -1;
heap->heapinfo[message.block].busy_block.ignore++;
} else {
- message.fragment =
- ((uintptr_t) (ADDR2UINT(address) % (BLOCKSIZE))) >>
- heap->heapinfo[message.block].type;
+ message.fragment = ((uintptr_t)(ADDR2UINT(address) % (BLOCKSIZE))) >> heap->heapinfo[message.block].type;
heap->heapinfo[message.block].busy_frag.ignore[message.fragment]++;
}
{
s_mc_ignore_memory_message_t message;
message.type = MC_MESSAGE_UNIGNORE_HEAP;
- message.addr = (std::uintptr_t) address;
+ message.addr = (std::uintptr_t)address;
message.size = size;
if (channel_.send(message))
xbt_die("Could not send IGNORE_HEAP mesasge to model-checker");
}
-void Client::declareSymbol(const char *name, int* value)
+void Client::declareSymbol(const char* name, int* value)
{
s_mc_register_symbol_message_t message;
message.type = MC_MESSAGE_REGISTER_SYMBOL;
xbt_die("Symbol is too long");
strncpy(message.name, name, sizeof(message.name));
message.callback = nullptr;
- message.data = value;
+ message.data = value;
if (channel_.send(message))
xbt_die("Could send REGISTER_SYMBOL message to model-checker");
}
-void Client::declareStack(void *stack, size_t size, smx_actor_t process, ucontext_t* context)
+void Client::declareStack(void* stack, size_t size, smx_actor_t process, ucontext_t* context)
{
xbt_mheap_t heap = mmalloc_get_current_heap();
memset(®ion, 0, sizeof(region));
region.address = stack;
region.context = context;
- region.size = size;
- region.block =
- ((char *) stack -
- (char *) heap->heapbase) / BLOCKSIZE + 1;
+ region.size = size;
+ region.block = ((char*)stack - (char*)heap->heapbase) / BLOCKSIZE + 1;
#if HAVE_SMPI
if (smpi_privatize_global_variables && process)
region.process_index = smpi_process_index_of_smx_process(process);
else
#endif
- region.process_index = -1;
+ region.process_index = -1;
s_mc_stack_region_message_t message;
- message.type = MC_MESSAGE_STACK_REGION;
+ message.type = MC_MESSAGE_STACK_REGION;
message.stack_region = region;
if (channel_.send(message))
xbt_die("Coule not send STACK_REGION to model-checker");
}
-
}
}
#include <simgrid/simix.h>
-#include "src/mc/mc_protocol.h"
-#include "src/mc/Channel.hpp"
+#include "src/mc/remote/Channel.hpp"
+#include "src/mc/remote/mc_protocol.h"
namespace simgrid {
namespace mc {
bool active_ = false;
Channel channel_;
static std::unique_ptr<Client> client_;
+
public:
Client();
explicit Client(int fd) : active_(true), channel_(fd) {}
void ignoreMemory(void* addr, std::size_t size);
void ignoreHeap(void* addr, std::size_t size);
void unignoreHeap(void* addr, std::size_t size);
- void declareSymbol(const char *name, int* value);
+ void declareSymbol(const char* name, int* value);
#if HAVE_UCONTEXT_H
- void declareStack(void *stack, size_t size, smx_actor_t process, ucontext_t* context);
+ void declareStack(void* stack, size_t size, smx_actor_t process, ucontext_t* context);
#endif
// Singleton :/
// TODO, remove the singleton antipattern.
static Client* initialize();
- static Client* get()
- {
- return client_.get();
- }
+ static Client* get() { return client_.get(); }
};
-
}
}
* in the current process and in the target process: we don't handle
* cross-architecture (such as 32-bit/64-bit access).
*/
-template<class T>
-union Remote {
+template <class T> union Remote {
private:
T buffer;
+
public:
Remote() {}
~Remote() {}
- Remote(T& p)
- {
- std::memcpy(&buffer, &p, sizeof(buffer));
- }
- Remote(Remote const& that)
- {
- std::memcpy(&buffer, &that.buffer, sizeof(buffer));
- }
+ Remote(T& p) { std::memcpy(&buffer, &p, sizeof(buffer)); }
+ Remote(Remote const& that) { std::memcpy(&buffer, &that.buffer, sizeof(buffer)); }
Remote& operator=(Remote const& that)
{
std::memcpy(&buffer, &that.buffer, sizeof(buffer));
return *this;
}
- T* getBuffer() { return &buffer; }
+ T* getBuffer() { return &buffer; }
const T* getBuffer() const { return &buffer; }
std::size_t getBufferSize() const { return sizeof(T); }
- operator T() const {
+ operator T() const
+ {
static_assert(std::is_trivial<T>::value, "Cannot convert non trivial type");
return buffer;
}
- void clear()
- {
- std::memset(static_cast<void*>(&buffer), 0, sizeof(T));
- }
-
+ void clear() { std::memset(static_cast<void*>(&buffer), 0, sizeof(T)); }
};
/** Pointer to a remote address-space (process, snapshot)
* always detect it in context. This way `RemotePtr` is as efficient
* as a `uint64_t`.
*/
-template<class T> class RemotePtr {
+template <class T> class RemotePtr {
std::uint64_t address_;
+
public:
RemotePtr() : address_(0) {}
RemotePtr(std::uint64_t address) : address_(address) {}
/** Turn into a local pointer
*
(if the remote process is not, in fact, remote) */
- T* local() const { return (T*) address_; }
+ T* local() const { return (T*)address_; }
- operator bool() const
- {
- return address_;
- }
- bool operator!() const
- {
- return !address_;
- }
- operator RemotePtr<void>() const
- {
- return RemotePtr<void>(address_);
- }
- RemotePtr<T> operator+(std::uint64_t n) const
- {
- return RemotePtr<T>(address_ + n * sizeof(T));
- }
- RemotePtr<T> operator-(std::uint64_t n) const
- {
- return RemotePtr<T>(address_ - n * sizeof(T));
- }
+ operator bool() const { return address_; }
+ bool operator!() const { return !address_; }
+ operator RemotePtr<void>() const { return RemotePtr<void>(address_); }
+ RemotePtr<T> operator+(std::uint64_t n) const { return RemotePtr<T>(address_ + n * sizeof(T)); }
+ RemotePtr<T> operator-(std::uint64_t n) const { return RemotePtr<T>(address_ - n * sizeof(T)); }
RemotePtr<T>& operator+=(std::uint64_t n)
{
address_ += n * sizeof(T);
}
};
-template<class X, class Y>
-bool operator<(RemotePtr<X> const& x, RemotePtr<Y> const& y)
+template <class X, class Y> bool operator<(RemotePtr<X> const& x, RemotePtr<Y> const& y)
{
return x.address() < y.address();
}
-template<class X, class Y>
-bool operator>(RemotePtr<X> const& x, RemotePtr<Y> const& y)
+template <class X, class Y> bool operator>(RemotePtr<X> const& x, RemotePtr<Y> const& y)
{
return x.address() > y.address();
}
-template<class X, class Y>
-bool operator>=(RemotePtr<X> const& x, RemotePtr<Y> const& y)
+template <class X, class Y> bool operator>=(RemotePtr<X> const& x, RemotePtr<Y> const& y)
{
return x.address() >= y.address();
}
-template<class X, class Y>
-bool operator<=(RemotePtr<X> const& x, RemotePtr<Y> const& y)
+template <class X, class Y> bool operator<=(RemotePtr<X> const& x, RemotePtr<Y> const& y)
{
return x.address() <= y.address();
}
-template<class X, class Y>
-bool operator==(RemotePtr<X> const& x, RemotePtr<Y> const& y)
+template <class X, class Y> bool operator==(RemotePtr<X> const& x, RemotePtr<Y> const& y)
{
return x.address() == y.address();
}
-template<class X, class Y>
-bool operator!=(RemotePtr<X> const& x, RemotePtr<Y> const& y)
+template <class X, class Y> bool operator!=(RemotePtr<X> const& x, RemotePtr<Y> const& y)
{
return x.address() != y.address();
}
-template<class T> inline
-RemotePtr<T> remote(T *p)
+template <class T> inline RemotePtr<T> remote(T* p)
{
return RemotePtr<T>(p);
}
-template<class T=void> inline
-RemotePtr<T> remote(uint64_t p)
+template <class T = void> inline RemotePtr<T> remote(uint64_t p)
{
return RemotePtr<T>(p);
}
-
}
}
--- /dev/null
+/* Copyright (c) 2015. 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. */
+
+#include <cstddef> // std::size_t
+#include <errno.h>
+#include <stdio.h> // perror
+#include <string.h>
+
+#include <sys/socket.h>
+#include <sys/types.h>
+
+#include <xbt/log.h>
+
+#include "src/mc/remote/Client.hpp"
+#include "src/mc/remote/mc_protocol.h"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_protocol, mc, "Generic MC protocol logic");
+
+const char* MC_message_type_name(e_mc_message_type type)
+{
+ switch (type) {
+ case MC_MESSAGE_NONE:
+ return "NONE";
+ case MC_MESSAGE_CONTINUE:
+ return "CONTINUE";
+ case MC_MESSAGE_IGNORE_HEAP:
+ return "IGNORE_HEAP";
+ case MC_MESSAGE_UNIGNORE_HEAP:
+ return "UNIGNORE_HEAP";
+ case MC_MESSAGE_IGNORE_MEMORY:
+ return "IGNORE_MEMORY";
+ case MC_MESSAGE_STACK_REGION:
+ return "STACK_REGION";
+ case MC_MESSAGE_REGISTER_SYMBOL:
+ return "REGISTER_SYMBOL";
+ case MC_MESSAGE_DEADLOCK_CHECK:
+ return "DEADLOCK_CHECK";
+ case MC_MESSAGE_DEADLOCK_CHECK_REPLY:
+ return "DEADLOCK_CHECK_REPLY";
+ case MC_MESSAGE_WAITING:
+ return "WAITING";
+ case MC_MESSAGE_SIMCALL_HANDLE:
+ return "SIMCALL_HANDLE";
+ case MC_MESSAGE_ASSERTION_FAILED:
+ return "ASSERTION_FAILED";
+ default:
+ return "?";
+ }
+}
struct s_mc_message {
e_mc_message_type type;
};
-typedef struct s_mc_message s_mc_message_t;
+typedef struct s_mc_message s_mc_message_t;
typedef struct s_mc_message* mc_message_t;
struct s_mc_int_message {
e_mc_message_type type;
int block;
int fragment;
- void *address;
+ void* address;
size_t size;
};
-typedef struct s_mc_ignore_heap_message s_mc_ignore_heap_message_t;
+typedef struct s_mc_ignore_heap_message s_mc_ignore_heap_message_t;
typedef struct s_mc_ignore_heap_message* mc_ignore_heap_message_t;
struct s_mc_ignore_memory_message {
uint64_t addr;
size_t size;
};
-typedef struct s_mc_ignore_memory_message s_mc_ignore_memory_message_t;
+typedef struct s_mc_ignore_memory_message s_mc_ignore_memory_message_t;
typedef struct s_mc_ignore_memory_message* mc_ignore_memory_message_t;
struct s_mc_stack_region_message {
e_mc_message_type type;
s_stack_region_t stack_region;
};
-typedef struct s_mc_stack_region_message s_mc_stack_region_message_t;
+typedef struct s_mc_stack_region_message s_mc_stack_region_message_t;
typedef struct s_mc_stack_region_message* mc_stack_region_message_t;
struct s_mc_simcall_handle_message {
unsigned long pid;
int value;
};
-typedef struct s_mc_simcall_handle_message s_mc_simcall_handle_message_t;
+typedef struct s_mc_simcall_handle_message s_mc_simcall_handle_message_t;
typedef struct s_mc_simcall_handle_message* mc_simcall_handle_message;
struct s_mc_register_symbol_message {
int (*callback)(void*);
void* data;
};
-typedef struct s_mc_register_symbol_message s_mc_register_symbol_message_t;
+typedef struct s_mc_register_symbol_message s_mc_register_symbol_message_t;
typedef struct s_mc_register_symbol_message* mc_register_symbol_message_t;
struct s_mc_restore_message {
e_mc_message_type type;
int index;
};
-typedef struct s_mc_restore_message s_mc_restore_message_t;
+typedef struct s_mc_restore_message s_mc_restore_message_t;
typedef struct s_mc_restore_message* mc_restore_message_t;
XBT_PRIVATE const char* MC_message_type_name(e_mc_message_type type);
#include "src/kernel/activity/SynchroIo.hpp"
#include "src/kernel/activity/SynchroRaw.hpp"
#include "src/kernel/activity/SynchroSleep.hpp"
-#include "src/mc/Client.hpp"
#include "src/mc/mc_replay.h"
+#include "src/mc/remote/Client.hpp"
#include "src/msg/msg_private.h"
#include "src/surf/cpu_interface.hpp"
#include "src/surf/surf_interface.hpp"
#if HAVE_MC
#include "src/mc/mc_private.h"
-#include "src/mc/mc_protocol.h"
-#include "src/mc/Client.hpp"
-
+#include "src/mc/remote/Client.hpp"
+#include "src/mc/remote/mc_protocol.h"
#include <stdlib.h>
-#include "src/mc/mc_protocol.h"
#endif
#include "src/mc/mc_record.h"
#include <dlfcn.h>
-#include "src/mc/mc_base.h"
#include "mmprivate.h"
-#include "src/xbt_modinter.h"
#include "src/internal_config.h"
+#include "src/mc/mc_base.h"
+#include "src/mc/remote/mc_protocol.h"
+#include "src/xbt_modinter.h"
#include <math.h>
-#include "src/mc/mc_protocol.h"
/* ***** Whether to use `mmalloc` of the underlying malloc ***** */
src/mc/checker/SafetyChecker.hpp
src/mc/checker/LivenessChecker.cpp
src/mc/checker/LivenessChecker.hpp
- src/mc/RemotePtr.hpp
+ src/mc/remote/Channel.cpp
+ src/mc/remote/Channel.hpp
+ src/mc/remote/Client.cpp
+ src/mc/remote/Client.hpp
+ src/mc/remote/RemotePtr.hpp
+ src/mc/remote/mc_protocol.h
+ src/mc/remote/mc_protocol.cpp
+
src/mc/AddressSpace.hpp
src/mc/AddressSpace.cpp
- src/mc/Channel.cpp
- src/mc/Channel.hpp
- src/mc/Client.cpp
- src/mc/Client.hpp
src/mc/Frame.hpp
src/mc/Frame.cpp
src/mc/ModelChecker.hpp
src/mc/VisitedState.cpp
src/mc/VisitedState.hpp
src/mc/mc_client_api.cpp
- src/mc/mc_protocol.h
- src/mc/mc_protocol.cpp
src/mc/mc_smx.h
src/mc/mc_smx.cpp
src/mc/mc_xbt.hpp