Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
192a78c48c366c22df07762d3a0ad9254eada75f
[simgrid.git] / src / mc / remote / mc_protocol.h
1 /* Copyright (c) 2015-2017. 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 #include <stdint.h>
10
11 #include <xbt/base.h>
12
13 #include "mc/datatypes.h"
14
15 SG_BEGIN_DECL()
16
17 // ***** Environment variables for passing context to the model-checked process
18
19 /** Environment variable name set by `simgrid-mc` to enable MC support in the
20  *  children MC processes
21  */
22 #define MC_ENV_VARIABLE "SIMGRID_MC"
23
24 /** Environment variable name used to pass the communication socket */
25 #define MC_ENV_SOCKET_FD "SIMGRID_MC_SOCKET_FD"
26
27 // ***** Messages
28
29 typedef enum {
30   MC_MESSAGE_NONE,
31   MC_MESSAGE_CONTINUE,
32   MC_MESSAGE_IGNORE_HEAP,
33   MC_MESSAGE_UNIGNORE_HEAP,
34   MC_MESSAGE_IGNORE_MEMORY,
35   MC_MESSAGE_STACK_REGION,
36   MC_MESSAGE_REGISTER_SYMBOL,
37   MC_MESSAGE_DEADLOCK_CHECK,
38   MC_MESSAGE_DEADLOCK_CHECK_REPLY,
39   MC_MESSAGE_WAITING,
40   MC_MESSAGE_SIMCALL_HANDLE,
41   MC_MESSAGE_ASSERTION_FAILED,
42   // MCer request to finish the restoration:
43   MC_MESSAGE_RESTORE,
44 } e_mc_message_type;
45
46 #define MC_MESSAGE_LENGTH 512
47
48 /** Basic structure for a MC message
49  *
50  *  The current version of the client/server protocol sends C structures over `AF_LOCAL`
51  *  `SOCK_DGRAM` sockets. This means that the protocol is ABI/architecture specific:
52  *  we currently can't model-check a x86 process from a x86_64 process.
53  *
54  *  Moreover the protocol is not stable. The same version of the library should be used
55  *  for the client and the server.
56  */
57
58 /* Basic structure: all message start with a message type */
59 struct s_mc_message {
60   e_mc_message_type type;
61 };
62 typedef struct s_mc_message mc_message_t;
63
64 struct s_mc_message_int {
65   e_mc_message_type type;
66   uint64_t value;
67 };
68 typedef struct s_mc_message_int mc_message_int_t;
69
70 struct s_mc_message_ignore_heap {
71   e_mc_message_type type;
72   int block;
73   int fragment;
74   void* address;
75   size_t size;
76 };
77 typedef struct s_mc_message_ignore_heap s_mc_message_ignore_heap_t;
78
79 struct s_mc_message_ignore_memory {
80   e_mc_message_type type;
81   uint64_t addr;
82   size_t size;
83 };
84 typedef struct s_mc_message_ignore_memory s_mc_message_ignore_memory_t;
85
86 struct s_mc_message_stack_region {
87   e_mc_message_type type;
88   s_stack_region_t stack_region;
89 };
90 typedef struct s_mc_message_stack_region s_mc_message_stack_region_t;
91
92 struct s_mc_message_simcall_handle {
93   e_mc_message_type type;
94   unsigned long pid;
95   int value;
96 };
97 typedef struct s_mc_message_simcall_handle s_mc_message_simcall_handle_t;
98
99 struct s_mc_register_symbol_message {
100   e_mc_message_type type;
101   char name[128];
102   int (*callback)(void*);
103   void* data;
104 };
105 typedef struct s_mc_register_symbol_message s_mc_register_symbol_message_t;
106
107 struct s_mc_message_restore {
108   e_mc_message_type type;
109   int index;
110 };
111 typedef struct s_mc_message_restore s_mc_message_restore_t;
112
113 XBT_PRIVATE const char* MC_message_type_name(e_mc_message_type type);
114
115 SG_END_DECL()
116
117 #endif