1 /* Copyright (c) 2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #ifndef SIMGRID_MC_PROTOCOL_H
8 #define SIMGRID_MC_PROTOCOL_H
12 #include "mc/datatypes.h"
16 // ***** Environment variables for passing context to the model-checked process
18 /** Environment variable name set by `simgrid-mc` to enable MC support in the
19 * children MC processes
21 #define MC_ENV_VARIABLE "SIMGRIC_MC"
23 /** Environment variable name used to pass the communication socket */
24 #define MC_ENV_SOCKET_FD "SIMGRID_MC_SOCKET_FD"
34 extern e_mc_mode_t mc_mode;
42 MC_MESSAGE_IGNORE_HEAP,
43 MC_MESSAGE_UNIGNORE_HEAP,
44 MC_MESSAGE_IGNORE_MEMORY,
45 MC_MESSAGE_STACK_REGION,
46 MC_MESSAGE_REGISTER_SYMBOL,
47 MC_MESSAGE_DEADLOCK_CHECK,
48 MC_MESSAGE_DEADLOCK_CHECK_REPLY,
50 MC_MESSAGE_SIMCALL_HANDLE,
51 MC_MESSAGE_ASSERTION_FAILED,
54 #define MC_MESSAGE_LENGTH 512
56 /** Basic structure for a MC message
58 * The current version of the client/server protocol sends C structures over `AF_LOCAL`
59 * `SOCK_DGRAM` sockets. This means that the protocol is ABI/architecture specific:
60 * we currently can't model-check a x86 process from a x86_64 process.
62 * Moreover the protocol is not stable. The same version of the library should be used
63 * for the client and the server.
65 * This is the basic structure shared by all messages: all message start with a message
68 typedef struct s_mc_message {
69 e_mc_message_type type;
70 } s_mc_message_t, *mc_message_t;
72 typedef struct s_mc_int_message {
73 e_mc_message_type type;
75 } s_mc_int_message_t, *mc_int_message_t;
77 typedef struct s_mc_ignore_heap_message {
78 e_mc_message_type type;
79 s_mc_heap_ignore_region_t region;
80 } s_mc_ignore_heap_message_t, *mc_ignore_heap_message_t;
82 typedef struct s_mc_ignore_memory_message {
83 e_mc_message_type type;
86 } s_mc_ignore_memory_message_t, *mc_ignore_memory_message_t;
88 typedef struct s_mc_stack_region_message {
89 e_mc_message_type type;
90 s_stack_region_t stack_region;
91 } s_mc_stack_region_message_t, *mc_stack_region_message_t;
93 typedef struct s_mc_simcall_handle_message {
94 e_mc_message_type type;
97 } s_mc_simcall_handle_message_t, *mc_simcall_handle_message;
99 typedef struct s_mc_register_symbol_message {
100 e_mc_message_type type;
102 int (*callback)(void*);
104 } s_mc_register_symbol_message_t, * mc_register_symbol_message_t;
106 XBT_INTERNAL int MC_protocol_send(int socket, const void* message, size_t size);
107 XBT_INTERNAL int MC_protocol_send_simple_message(int socket, e_mc_message_type type);
108 XBT_INTERNAL int MC_protocol_hello(int socket);
109 XBT_INTERNAL ssize_t MC_receive_message(int socket, void* message, size_t size, int options);
111 XBT_INTERNAL const char* MC_message_type_name(e_mc_message_type type);
112 XBT_INTERNAL const char* MC_mode_name(e_mc_mode_t mode);