Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mc: move some files related to ELF, DWARF or unwind reading into their own directory
[simgrid.git] / src / mc / remote / Client.hpp
1 /* Copyright (c) 2015-2019. 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 handleMessages();
29
30 private:
31   void handleDeadlockCheck(s_mc_message_t* msg);
32   void handleContinue(s_mc_message_t* msg);
33   void handleSimcall(s_mc_message_simcall_handle_t* message);
34   void handleRestore(s_mc_message_restore_t* msg);
35   void handleActorEnabled(s_mc_message_actor_enabled_t* msg);
36
37 public:
38   Channel const& getChannel() const { return channel_; }
39   Channel& getChannel() { return channel_; }
40   XBT_ATTRIB_NORETURN void mainLoop();
41   void reportAssertionFailure();
42   void ignoreMemory(void* addr, std::size_t size);
43   void ignoreHeap(void* addr, std::size_t size);
44   void unignoreHeap(void* addr, std::size_t size);
45   void declareSymbol(const char* name, int* value);
46 #if HAVE_UCONTEXT_H
47   void declareStack(void* stack, size_t size, smx_actor_t process, ucontext_t* context);
48 #endif
49
50   // Singleton :/
51   // TODO, remove the singleton antipattern.
52   static Client* initialize();
53   static Client* get() { return instance_.get(); }
54 };
55 }
56 }
57
58 #endif