Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The return type of the sg_actor_on_exit() callbacks is now 'void'
[simgrid.git] / src / mc / remote / Client.hpp
1 /* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef SIMGRID_MC_CLIENT_H
7 #define SIMGRID_MC_CLIENT_H
8
9 #include "src/mc/remote/Channel.hpp"
10
11 #include <memory>
12
13 namespace simgrid {
14 namespace mc {
15
16 /** Model-checked-side of the communication protocol
17  *
18  *  Send messages to the model-checker and handles message from it.
19  */
20 class XBT_PUBLIC Client {
21 private:
22   Channel channel_;
23   static std::unique_ptr<Client> instance_;
24
25 public:
26   Client();
27   explicit Client(int fd) : channel_(fd) {}
28   void handle_messages();
29
30 private:
31   void handle_deadlock_check(const s_mc_message_t* msg);
32   void handle_continue(const s_mc_message_t* msg);
33   void handle_simcall(const s_mc_message_simcall_handle_t* message);
34   void handle_actor_enabled(const s_mc_message_actor_enabled_t* msg);
35
36 public:
37   Channel const& get_channel() const { return channel_; }
38   Channel& get_channel() { return channel_; }
39   XBT_ATTRIB_NORETURN void main_loop();
40   void report_assertion_failure();
41   void ignore_memory(void* addr, std::size_t size);
42   void ignore_heap(void* addr, std::size_t size);
43   void unignore_heap(void* addr, std::size_t size);
44   void declare_symbol(const char* name, int* value);
45 #if HAVE_UCONTEXT_H
46   void declare_stack(void* stack, size_t size, ucontext_t* context);
47 #endif
48
49   // Singleton :/
50   // TODO, remove the singleton antipattern.
51   static Client* initialize();
52   static Client* get() { return instance_.get(); }
53 };
54 } // namespace mc
55 } // namespace simgrid
56
57 #endif