1 /* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_MC_REMOTE_EVENTLOOP_HPP
7 #define SIMGRID_MC_REMOTE_EVENTLOOP_HPP
9 #include "src/mc/mc_forward.hpp"
10 #include "src/mc/remote/Channel.hpp"
12 #include <event2/event.h>
16 namespace simgrid::mc {
18 /* CheckerSide: All what the checker needs to interact with a given application process */
23 std::unique_ptr<event_base, decltype(&event_base_free)> base_{nullptr, &event_base_free};
24 std::unique_ptr<RemoteProcessMemory> remote_memory_;
27 bool running_ = false;
30 void setup_events(); // Part of the initialization
31 void clear_memory_cache();
32 void handle_waitpid();
35 explicit CheckerSide(const std::vector<char*>& args, bool need_memory_introspection);
39 CheckerSide(CheckerSide const&) = delete;
40 CheckerSide& operator=(CheckerSide const&) = delete;
41 CheckerSide& operator=(CheckerSide&&) = delete;
43 /* Communicating with the application */
44 Channel const& get_channel() const { return channel_; }
45 Channel& get_channel() { return channel_; }
47 bool handle_message(const char* buffer, ssize_t size);
48 void dispatch_events() const;
49 void break_loop() const;
50 void wait_for_requests();
52 /* Interacting with the application process */
53 pid_t get_pid() const { return pid_; }
54 bool running() const { return running_; }
55 void terminate() { running_ = false; }
56 RemoteProcessMemory* get_remote_memory() { return remote_memory_.get(); }
59 } // namespace simgrid::mc