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.
58 /* Basic structure: all message start with a message type */
60 e_mc_message_type type;
62 typedef struct s_mc_message mc_message_t;
64 struct s_mc_message_int {
65 e_mc_message_type type;
68 typedef struct s_mc_message_int mc_message_int_t;
71 struct s_mc_message_ignore_heap {
72 e_mc_message_type type;
78 typedef struct s_mc_message_ignore_heap s_mc_message_ignore_heap_t;
80 struct s_mc_message_ignore_memory {
81 e_mc_message_type type;
85 typedef struct s_mc_message_ignore_memory s_mc_message_ignore_memory_t;
87 struct s_mc_message_stack_region {
88 e_mc_message_type type;
89 s_stack_region_t stack_region;
91 typedef struct s_mc_message_stack_region s_mc_message_stack_region_t;
93 struct s_mc_message_register_symbol {
94 e_mc_message_type type;
96 int (*callback)(void*);
99 typedef struct s_mc_message_register_symbol s_mc_message_register_symbol_t;
101 /* Server -> client */
102 struct s_mc_message_simcall_handle {
103 e_mc_message_type type;
107 typedef struct s_mc_message_simcall_handle s_mc_message_simcall_handle_t;
109 struct s_mc_message_restore {
110 e_mc_message_type type;
113 typedef struct s_mc_message_restore s_mc_message_restore_t;
115 XBT_PRIVATE const char* MC_message_type_name(e_mc_message_type type);