Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Separate mmalloc from xbt
[simgrid.git] / src / mc / remote / mc_protocol.h
1 /* Copyright (c) 2015-2022. 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_PROTOCOL_H
7 #define SIMGRID_MC_PROTOCOL_H
8
9 // ***** Environment variables for passing context to the model-checked process
10
11 #ifdef __cplusplus
12
13 #include "src/kernel/actor/SimcallObserver.hpp"
14
15 #include "mc/datatypes.h"
16 #include "simgrid/forward.h" // aid_t
17 #include <array>
18 #include <cstdint>
19 #include <xbt/dynar.h>
20 #include <xbt/mmalloc.h>
21 #include <xbt/utility.hpp>
22
23 // ***** Messages
24 namespace simgrid::mc {
25
26 XBT_DECLARE_ENUM_CLASS(MessageType, NONE, INITIAL_ADDRESSES, CONTINUE, IGNORE_HEAP, UNIGNORE_HEAP, IGNORE_MEMORY,
27                        STACK_REGION, REGISTER_SYMBOL, DEADLOCK_CHECK, DEADLOCK_CHECK_REPLY, WAITING, SIMCALL_EXECUTE,
28                        SIMCALL_EXECUTE_ANSWER, ASSERTION_FAILED, ACTOR_ENABLED, ACTOR_ENABLED_REPLY, FINALIZE);
29
30 } // namespace simgrid::mc
31
32 constexpr unsigned MC_MESSAGE_LENGTH = 512;
33 constexpr unsigned SIMCALL_SERIALIZATION_BUFFER_SIZE = 2048;
34
35 /** Basic structure for a MC message
36  *
37  *  The current version of the client/server protocol sends C structures over `AF_LOCAL`
38  *  `SOCK_SEQPACKET` sockets. This means that the protocol is ABI/architecture specific:
39  *  we currently can't model-check a x86 process from a x86_64 process.
40  *
41  *  Moreover the protocol is not stable. The same version of the library should be used
42  *  for the client and the server.
43  */
44
45 /* Basic structure: all message start with a message type */
46 struct s_mc_message_t {
47   simgrid::mc::MessageType type;
48 };
49
50 struct s_mc_message_int_t {
51   simgrid::mc::MessageType type;
52   uint64_t value;
53 };
54
55 /* Client->Server */
56 struct s_mc_message_initial_addresses_t {
57   simgrid::mc::MessageType type;
58   xbt_mheap_t mmalloc_default_mdp;
59   unsigned long* maxpid;
60   xbt_dynar_t actors;
61 };
62
63 struct s_mc_message_ignore_heap_t {
64   simgrid::mc::MessageType type;
65   int block;
66   int fragment;
67   void* address;
68   size_t size;
69 };
70
71 struct s_mc_message_ignore_memory_t {
72   simgrid::mc::MessageType type;
73   uint64_t addr;
74   size_t size;
75 };
76
77 struct s_mc_message_stack_region_t {
78   simgrid::mc::MessageType type;
79   s_stack_region_t stack_region;
80 };
81
82 struct s_mc_message_register_symbol_t {
83   simgrid::mc::MessageType type;
84   std::array<char, 128> name;
85   int (*callback)(void*);
86   void* data;
87 };
88
89 /* Server -> client */
90 struct s_mc_message_simcall_execute_t {
91   simgrid::mc::MessageType type;
92   aid_t aid_;
93   int times_considered_;
94 };
95 struct s_mc_message_simcall_execute_answer_t {
96   simgrid::mc::MessageType type;
97   std::array<char, SIMCALL_SERIALIZATION_BUFFER_SIZE> buffer;
98 };
99
100 struct s_mc_message_restore_t {
101   simgrid::mc::MessageType type;
102   int index;
103 };
104
105 struct s_mc_message_actor_enabled_t {
106   simgrid::mc::MessageType type;
107   aid_t aid; // actor ID
108 };
109
110 #endif // __cplusplus
111 #endif