Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
do not load internal_config.h from mc.h
[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  *  This is the basic structure shared by all messages: all message start with a message
58  *  type.
59  */
60 struct s_mc_message {
61   e_mc_message_type type;
62 };
63 typedef struct s_mc_message s_mc_message_t;
64 typedef struct s_mc_message* mc_message_t;
65
66 struct s_mc_int_message {
67   e_mc_message_type type;
68   uint64_t value;
69 };
70 typedef struct s_mc_int_message s_mc_int_message_t;
71 typedef struct s_mc_int_message* mc_int_message_t;
72
73 struct s_mc_ignore_heap_message {
74   e_mc_message_type type;
75   int block;
76   int fragment;
77   void* address;
78   size_t size;
79 };
80 typedef struct s_mc_ignore_heap_message s_mc_ignore_heap_message_t;
81 typedef struct s_mc_ignore_heap_message* mc_ignore_heap_message_t;
82
83 struct s_mc_ignore_memory_message {
84   e_mc_message_type type;
85   uint64_t addr;
86   size_t size;
87 };
88 typedef struct s_mc_ignore_memory_message s_mc_ignore_memory_message_t;
89 typedef struct s_mc_ignore_memory_message* mc_ignore_memory_message_t;
90
91 struct s_mc_stack_region_message {
92   e_mc_message_type type;
93   s_stack_region_t stack_region;
94 };
95 typedef struct s_mc_stack_region_message s_mc_stack_region_message_t;
96 typedef struct s_mc_stack_region_message* mc_stack_region_message_t;
97
98 struct s_mc_simcall_handle_message {
99   e_mc_message_type type;
100   unsigned long pid;
101   int value;
102 };
103 typedef struct s_mc_simcall_handle_message s_mc_simcall_handle_message_t;
104 typedef struct s_mc_simcall_handle_message* mc_simcall_handle_message;
105
106 struct s_mc_register_symbol_message {
107   e_mc_message_type type;
108   char name[128];
109   int (*callback)(void*);
110   void* data;
111 };
112 typedef struct s_mc_register_symbol_message s_mc_register_symbol_message_t;
113 typedef struct s_mc_register_symbol_message* mc_register_symbol_message_t;
114
115 struct s_mc_restore_message {
116   e_mc_message_type type;
117   int index;
118 };
119 typedef struct s_mc_restore_message s_mc_restore_message_t;
120 typedef struct s_mc_restore_message* mc_restore_message_t;
121
122 XBT_PRIVATE const char* MC_message_type_name(e_mc_message_type type);
123
124 SG_END_DECL()
125
126 #endif