/* Resume the application */
if (checker_side_->get_channel().send(MessageType::CONTINUE) != 0)
throw xbt::errno_error();
- get_remote_process_memory().clear_cache();
+ checker_side_->clear_memory_cache();
if (checker_side_->running())
checker_side_->dispatch_events();
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkerside, mc, "MC communication with the application");
namespace simgrid::mc {
-CheckerSide::CheckerSide(int sockfd, pid_t pid)
- : remote_memory_(std::make_unique<simgrid::mc::RemoteProcessMemory>(pid))
- , channel_(sockfd)
- , running_(true)
- , pid_(pid)
+CheckerSide::CheckerSide(int sockfd, pid_t pid) : channel_(sockfd), running_(true), pid_(pid)
{
auto* base = event_base_new();
base_.reset(base);
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_memory().init(message.mmalloc_default_mdp);
+ /* Create the memory address space, now that we have the mandatory information */
+ remote_memory_ = std::make_unique<simgrid::mc::RemoteProcessMemory>(pid_, message.mmalloc_default_mdp);
break;
}
return true;
}
+void CheckerSide::clear_memory_cache()
+{
+ if (remote_memory_)
+ remote_memory_->clear_cache();
+}
+
void CheckerSide::handle_waitpid()
{
XBT_DEBUG("Check for wait event");
pid_t get_pid() const { return pid_; }
bool running() const { return running_; }
void terminate() { running_ = false; }
- RemoteProcessMemory& get_remote_memory() { return *remote_memory_.get(); }
void handle_waitpid();
+ RemoteProcessMemory& get_remote_memory() { return *remote_memory_.get(); }
+ void clear_memory_cache();
};
} // namespace simgrid::mc
// ***** RemoteProcessMemory
-RemoteProcessMemory::RemoteProcessMemory(pid_t pid) : AddressSpace(this), pid_(pid) {}
-
-void RemoteProcessMemory::init(xbt_mheap_t mmalloc_default_mdp)
+RemoteProcessMemory::RemoteProcessMemory(pid_t pid, xbt_mheap_t mmalloc_default_mdp) : AddressSpace(this), pid_(pid)
{
this->heap_address = remote(mmalloc_default_mdp);
static constexpr int cache_malloc = 2;
public:
- explicit RemoteProcessMemory(pid_t pid);
+ explicit RemoteProcessMemory(pid_t pid, xbt_mheap_t mmalloc_default_mdp);
~RemoteProcessMemory() override;
- void init(xbt_mheap_t mmalloc_default_mdp);
RemoteProcessMemory(RemoteProcessMemory const&) = delete;
RemoteProcessMemory(RemoteProcessMemory&&) = delete;
REQUIRE(xbt_pagesize == getpagesize());
REQUIRE(1 << xbt_pagebits == xbt_pagesize);
- memory_ = std::make_unique<simgrid::mc::RemoteProcessMemory>(getpid());
- memory_->init(nullptr);
+ memory_ = std::make_unique<simgrid::mc::RemoteProcessMemory>(getpid(), nullptr);
}
snap_test_helper::prologue_return snap_test_helper::prologue(int n)
int main()
{
- auto* process = new simgrid::mc::RemoteProcessMemory(getpid());
- process->init(nullptr);
+ auto* process = new simgrid::mc::RemoteProcessMemory(getpid(), nullptr);
simgrid::dwarf::ExpressionContext state;
state.address_space = (simgrid::mc::AddressSpace*) process;
const simgrid::mc::Variable* var;
simgrid::mc::Type* type;
- simgrid::mc::RemoteProcessMemory process(getpid());
- process.init(nullptr);
+ simgrid::mc::RemoteProcessMemory process(getpid(), nullptr);
test_global_variable(process, process.binary_info.get(), "some_local_variable", &some_local_variable, sizeof(int));