1 /* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SIMGRID_MC_PROTOCOL_H
7 #define SIMGRID_MC_PROTOCOL_H
13 #include "mc/datatypes.h"
17 // ***** Environment variables for passing context to the model-checked process
19 /** Environment variable name set by `simgrid-mc` to enable MC support in the
20 * children MC processes
22 #define MC_ENV_VARIABLE "SIMGRID_MC"
24 /** Environment variable name used to pass the communication socket */
25 #define MC_ENV_SOCKET_FD "SIMGRID_MC_SOCKET_FD"
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,
40 MC_MESSAGE_SIMCALL_HANDLE,
41 MC_MESSAGE_ASSERTION_FAILED,
42 // MCer request to finish the restoration:
46 #define MC_MESSAGE_LENGTH 512
48 /** Basic structure for a MC message
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.
54 * Moreover the protocol is not stable. The same version of the library should be used
55 * for the client and the server.
57 * This is the basic structure shared by all messages: all message start with a message
61 e_mc_message_type type;
63 typedef struct s_mc_message s_mc_message_t;
64 typedef struct s_mc_message* mc_message_t;
66 struct s_mc_int_message {
67 e_mc_message_type type;
70 typedef struct s_mc_int_message s_mc_int_message_t;
71 typedef struct s_mc_int_message* mc_int_message_t;
73 struct s_mc_ignore_heap_message {
74 e_mc_message_type type;
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;
83 struct s_mc_ignore_memory_message {
84 e_mc_message_type type;
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;
91 struct s_mc_stack_region_message {
92 e_mc_message_type type;
93 s_stack_region_t stack_region;
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;
98 struct s_mc_simcall_handle_message {
99 e_mc_message_type type;
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;
106 struct s_mc_register_symbol_message {
107 e_mc_message_type type;
109 int (*callback)(void*);
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;
115 struct s_mc_restore_message {
116 e_mc_message_type type;
119 typedef struct s_mc_restore_message s_mc_restore_message_t;
120 typedef struct s_mc_restore_message* mc_restore_message_t;
122 XBT_PRIVATE const char* MC_message_type_name(e_mc_message_type type);