Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Implement remote support for MC_ignore
[simgrid.git] / src / mc / mc_protocol.h
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 MC_PROTOCOL_H
8 #define MC_PROTOCOL_H
9
10 #include <xbt/misc.h>
11
12 #include "mc/datatypes.h"
13
14 SG_BEGIN_DECL()
15
16 // ***** Environment variables for passing context to the model-checked process
17
18 /** Environment variable name set by `simgrid-mc` to enable MC support in the
19  *  children MC processes
20  */
21 #define MC_ENV_VARIABLE "SIMGRIC_MC"
22
23 /** Environment variable name used to pass the communication socket */
24 #define MC_ENV_SOCKET_FD "SIMGRID_MC_SOCKET_FD"
25
26 // ***** MC mode
27
28 typedef enum {
29   MC_MODE_NONE = 0,
30   MC_MODE_STANDALONE,
31   MC_MODE_CLIENT,
32   MC_MODE_SERVER
33 } e_mc_mode_t;
34
35 extern e_mc_mode_t mc_mode;
36
37 // ***** Messages
38
39 typedef enum {
40   MC_MESSAGE_NONE = 0,
41   MC_MESSAGE_HELLO = 1,
42   MC_MESSAGE_CONTINUE = 2,
43   MC_MESSAGE_IGNORE_REGION = 3,
44   MC_MESSAGE_IGNORE_MEMORY = 4,
45 } e_mc_message_type;
46
47 #define MC_MESSAGE_LENGTH 512
48
49 /** Basic structure for a MC message
50  *
51  *  The current version of the client/server protocol sends C structures over `AF_LOCAL`
52  *  `SOCK_DGRAM` sockets. This means that the protocol is ABI/architecture specific:
53  *  we currently can't model-check a x86 process from a x86_64 process.
54  *
55  *  Moreover the protocol is not stable. The same version of the library should be used
56  *  for the client and the server.
57  *
58  *  This is the basic structure shared by all messages: all message start with a message
59  *  type.
60  */
61 typedef struct s_mc_message {
62   e_mc_message_type type;
63 } s_mc_message_t, *mc_message_t;
64
65 typedef struct s_mc_ignore_region_message {
66   e_mc_message_type type;
67   s_mc_heap_ignore_region_t region;
68 } s_mc_ignore_region_message_t, *mc_ignore_region_message_t;
69
70 typedef struct s_mc_ignore_memory_message {
71   e_mc_message_type type;
72   void *addr;
73   size_t size;
74 } s_mc_ignore_memory_message_t, *mc_ignore_memory_message_t;
75
76 int MC_protocol_send(int socket, void* message, size_t size);
77 int MC_protocol_send_simple_message(int socket, int type);
78 int MC_protocol_hello(int socket);
79
80 SG_END_DECL()
81
82 #endif