Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / mc / remote / Client.hpp
1 /* Copyright (c) 2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SIMGRID_MC_CLIENT_H
8 #define SIMGRID_MC_CLIENT_H
9
10 #include "src/internal_config.h"
11
12 #include <cstddef>
13 #include <memory>
14
15 #include <xbt/base.h>
16
17 #include <simgrid/simix.h>
18
19 #include "src/mc/remote/Channel.hpp"
20 #include "src/mc/remote/mc_protocol.h"
21
22 namespace simgrid {
23 namespace mc {
24
25 /** Model-checked-side of the communication protocol
26  *
27  *  Send messages to the model-checker and handles message from it.
28  */
29 class XBT_PUBLIC() Client {
30 private:
31   bool active_ = false;
32   Channel channel_;
33   static std::unique_ptr<Client> client_;
34
35 public:
36   Client();
37   explicit Client(int fd) : active_(true), channel_(fd) {}
38   void handleMessages();
39   Channel const& getChannel() const { return channel_; }
40   Channel& getChannel() { return channel_; }
41   void mainLoop();
42   void reportAssertionFailure(const char* description = nullptr);
43   void ignoreMemory(void* addr, std::size_t size);
44   void ignoreHeap(void* addr, std::size_t size);
45   void unignoreHeap(void* addr, std::size_t size);
46   void declareSymbol(const char* name, int* value);
47 #if HAVE_UCONTEXT_H
48   void declareStack(void* stack, size_t size, smx_actor_t process, ucontext_t* context);
49 #endif
50
51   // Singleton :/
52   // TODO, remove the singleton antipattern.
53   static Client* initialize();
54   static Client* get() { return client_.get(); }
55 };
56 }
57 }
58
59 SG_BEGIN_DECL()
60
61 #if SIMGRID_HAVE_MC
62 void MC_ignore(void* addr, std::size_t size);
63 #endif
64
65 SG_END_DECL()
66
67 #endif