Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / src / mc / mc_private.h
1 /* Copyright (c) 2007-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_PRIVATE_H
8 #define SIMGRID_MC_PRIVATE_H
9
10 #include <sys/types.h>
11
12 #include "simgrid_config.h"
13 #include <stdio.h>
14 #include <stdint.h>
15 #include <stdbool.h>
16 #ifndef WIN32
17 #include <sys/mman.h>
18 #endif
19 #include <elfutils/libdw.h>
20
21 #include "mc/mc.h"
22 #include "mc_base.h"
23 #include "mc/datatypes.h"
24 #include "xbt/fifo.h"
25 #include "xbt/config.h"
26
27 #ifdef __cplusplus
28 #include "../xbt/memory_map.hpp"
29 #endif
30
31 #include "xbt/function_types.h"
32 #include "xbt/mmalloc.h"
33 #include "../simix/smx_private.h"
34 #include "../xbt/mmalloc/mmprivate.h"
35 #include "xbt/automaton.h"
36 #include "xbt/hash.h"
37 #include <simgrid/msg.h>
38 #include "xbt/strbuff.h"
39 #include "xbt/parmap.h"
40 #include <xbt/base.h>
41
42 #include "mc_forward.h"
43 #include "mc_protocol.h"
44
45 SG_BEGIN_DECL()
46
47 typedef struct s_mc_function_index_item s_mc_function_index_item_t, *mc_function_index_item_t;
48
49 /********************************* MC Global **********************************/
50
51 /** Initialisation of the model-checker
52  *
53  * @param pid     PID of the target process
54  * @param socket  FD for the communication socket **in server mode** (or -1 otherwise)
55  */
56 void MC_init_model_checker(pid_t pid, int socket);
57
58 XBT_PRIVATE extern FILE *dot_output;
59 XBT_PRIVATE extern const char* colors[13];
60 XBT_PRIVATE extern xbt_parmap_t parmap;
61
62 XBT_PRIVATE extern int user_max_depth_reached;
63
64 XBT_PRIVATE int MC_deadlock_check(void);
65 XBT_PRIVATE void MC_replay(xbt_fifo_t stack);
66 XBT_PRIVATE void MC_replay_liveness(xbt_fifo_t stack);
67 XBT_PRIVATE void MC_show_deadlock(smx_simcall_t req);
68 XBT_PRIVATE void MC_show_stack_safety(xbt_fifo_t stack);
69 XBT_PRIVATE void MC_dump_stack_safety(xbt_fifo_t stack);
70 XBT_PRIVATE void MC_show_non_termination(void);
71
72 /** Stack (of `mc_state_t`) representing the current position of the
73  *  the MC in the exploration graph
74  *
75  *  It is managed by its head (`xbt_fifo_shift` and `xbt_fifo_unshift`).
76  */
77 XBT_PRIVATE extern xbt_fifo_t mc_stack;
78
79 XBT_PRIVATE int get_search_interval(xbt_dynar_t list, void *ref, int *min, int *max);
80
81
82 /****************************** Statistics ************************************/
83
84 typedef struct mc_stats {
85   unsigned long state_size;
86   unsigned long visited_states;
87   unsigned long visited_pairs;
88   unsigned long expanded_states;
89   unsigned long expanded_pairs;
90   unsigned long executed_transitions;
91 } s_mc_stats_t, *mc_stats_t;
92
93 XBT_PRIVATE extern mc_stats_t mc_stats;
94
95 XBT_PRIVATE void MC_print_statistics(mc_stats_t stats);
96
97 /********************************** Snapshot comparison **********************************/
98
99 typedef struct s_mc_comparison_times{
100   double nb_processes_comparison_time;
101   double bytes_used_comparison_time;
102   double stacks_sizes_comparison_time;
103   double global_variables_comparison_time;
104   double heap_comparison_time;
105   double stacks_comparison_time;
106 }s_mc_comparison_times_t, *mc_comparison_times_t;
107
108 extern XBT_PRIVATE __thread mc_comparison_times_t mc_comp_times;
109 extern XBT_PRIVATE __thread double mc_snapshot_comparison_time;
110
111 XBT_PRIVATE int snapshot_compare(void *state1, void *state2);
112 XBT_PRIVATE void print_comparison_times(void);
113
114 //#define MC_DEBUG 1
115 #define MC_VERBOSE 1
116
117 /********************************** Miscellaneous **********************************/
118
119 XBT_PRIVATE void MC_dump_stacks(FILE* file);
120
121 XBT_PRIVATE void MC_report_assertion_error(void);
122
123 XBT_PRIVATE void MC_invalidate_cache(void);
124
125 #ifdef __cplusplus
126
127 XBT_PRIVATE void MC_find_object_address(
128   std::vector<simgrid::xbt::VmMap> const& maps, simgrid::mc::ObjectInformation* result);
129
130 #endif
131
132 SG_END_DECL()
133
134 #endif