Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use std::equal_range in get_search_range()
[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 SIMGRID_MC_PROTOCOL_H
8 #define SIMGRID_MC_PROTOCOL_H
9
10 #include <stdint.h>
11
12 #include <xbt/base.h>
13
14 #include "mc/datatypes.h"
15
16 SG_BEGIN_DECL()
17
18 // ***** Environment variables for passing context to the model-checked process
19
20 /** Environment variable name set by `simgrid-mc` to enable MC support in the
21  *  children MC processes
22  */
23 #define MC_ENV_VARIABLE "SIMGRID_MC"
24
25 /** Environment variable name used to pass the communication socket */
26 #define MC_ENV_SOCKET_FD "SIMGRID_MC_SOCKET_FD"
27
28 // ***** MC mode
29
30 typedef enum {
31   MC_MODE_NONE = 0,
32   MC_MODE_CLIENT,
33   MC_MODE_SERVER
34 } e_mc_mode_t;
35
36 extern e_mc_mode_t mc_mode;
37
38 // ***** Messages
39
40 typedef enum {
41   MC_MESSAGE_NONE,
42   MC_MESSAGE_CONTINUE,
43   MC_MESSAGE_IGNORE_HEAP,
44   MC_MESSAGE_UNIGNORE_HEAP,
45   MC_MESSAGE_IGNORE_MEMORY,
46   MC_MESSAGE_STACK_REGION,
47   MC_MESSAGE_REGISTER_SYMBOL,
48   MC_MESSAGE_DEADLOCK_CHECK,
49   MC_MESSAGE_DEADLOCK_CHECK_REPLY,
50   MC_MESSAGE_WAITING,
51   MC_MESSAGE_SIMCALL_HANDLE,
52   MC_MESSAGE_ASSERTION_FAILED,
53   // MCer request to finish the restoration:
54   MC_MESSAGE_RESTORE,
55 } e_mc_message_type;
56
57 #define MC_MESSAGE_LENGTH 512
58
59 /** Basic structure for a MC message
60  *
61  *  The current version of the client/server protocol sends C structures over `AF_LOCAL`
62  *  `SOCK_DGRAM` sockets. This means that the protocol is ABI/architecture specific:
63  *  we currently can't model-check a x86 process from a x86_64 process.
64  *
65  *  Moreover the protocol is not stable. The same version of the library should be used
66  *  for the client and the server.
67  *
68  *  This is the basic structure shared by all messages: all message start with a message
69  *  type.
70  */
71 typedef struct s_mc_message {
72   e_mc_message_type type;
73 } s_mc_message_t, *mc_message_t;
74
75 typedef struct s_mc_int_message {
76   e_mc_message_type type;
77   uint64_t value;
78 } s_mc_int_message_t, *mc_int_message_t;
79
80 typedef struct s_mc_ignore_heap_message {
81   e_mc_message_type type;
82   int block;
83   int fragment;
84   void *address;
85   size_t size;
86 } s_mc_ignore_heap_message_t, *mc_ignore_heap_message_t;
87
88 typedef struct s_mc_ignore_memory_message {
89   e_mc_message_type type;
90   uint64_t addr;
91   size_t size;
92 } s_mc_ignore_memory_message_t, *mc_ignore_memory_message_t;
93
94 typedef struct s_mc_stack_region_message {
95   e_mc_message_type type;
96   s_stack_region_t stack_region;
97 } s_mc_stack_region_message_t, *mc_stack_region_message_t;
98
99 typedef struct s_mc_simcall_handle_message {
100   e_mc_message_type type;
101   unsigned long pid;
102   int value;
103 } s_mc_simcall_handle_message_t, *mc_simcall_handle_message;
104
105 typedef struct s_mc_register_symbol_message {
106   e_mc_message_type type;
107   char name[128];
108   int (*callback)(void*);
109   void* data;
110 } s_mc_register_symbol_message_t, * mc_register_symbol_message_t;
111
112 typedef struct s_mc_restore_message {
113   e_mc_message_type type;
114   int index;
115 } s_mc_restore_message_t, *mc_restore_message_t;
116
117 XBT_PRIVATE const char* MC_message_type_name(e_mc_message_type type);
118 XBT_PRIVATE const char* MC_mode_name(e_mc_mode_t mode);
119
120 SG_END_DECL()
121
122 #endif