Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
57189e65f039ad4af8e8c44597b783c44cded526
[simgrid.git] / src / mc / remote / AppSide.hpp
1 /* mc::remote::AppSide: the Application-side of the channel                 */
2
3 /* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved.          */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #ifndef SIMGRID_MC_CLIENT_H
9 #define SIMGRID_MC_CLIENT_H
10
11 #include "src/mc/remote/Channel.hpp"
12
13 #include <memory>
14
15 namespace simgrid::mc {
16
17 /** Model-checked-side of the communication protocol
18  *
19  *  Send messages to the model-checker and handles message from it.
20  */
21 class XBT_PUBLIC AppSide {
22 private:
23   Channel channel_;
24   static std::unique_ptr<AppSide> instance_;
25   bool need_memory_info_ = false; /* by default we don't send memory info, unless we got a NEED_MEMINFO */
26   std::unordered_map<int, int> child_statuses_;
27
28 public:
29   AppSide();
30   explicit AppSide(int fd) : channel_(fd) {}
31   void handle_messages();
32
33 private:
34   void handle_deadlock_check(const s_mc_message_t* msg) const;
35   void handle_simcall_execute(const s_mc_message_simcall_execute_t* message) const;
36   void handle_finalize(const s_mc_message_int_t* msg) const;
37   void handle_fork(const s_mc_message_fork_t* msg);
38   void handle_wait_child(const s_mc_message_int_t* msg);
39   void handle_need_meminfo();
40   void handle_actors_status() const;
41   void handle_actors_maxpid() const;
42
43 public:
44   Channel const& get_channel() const { return channel_; }
45   Channel& get_channel() { return channel_; }
46   XBT_ATTRIB_NORETURN void main_loop();
47   void report_assertion_failure();
48   void ignore_memory(void* addr, std::size_t size) const;
49   void unignore_memory(void* addr, std::size_t size) const;
50   void ignore_heap(void* addr, std::size_t size) const;
51   void unignore_heap(void* addr, std::size_t size) const;
52   void declare_symbol(const char* name, int* value) const;
53 #if HAVE_UCONTEXT_H
54   void declare_stack(void* stack, size_t size, ucontext_t* context) const;
55 #endif
56
57   // TODO, remove the singleton antipattern.
58   static AppSide* get();
59 };
60 } // namespace simgrid::mc
61
62 #endif