Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Move process info in a new s_mc_process_t structure
[simgrid.git] / src / mc / mc_private.h
1 /* Copyright (c) 2007-2014. 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 MC_PRIVATE_H
8 #define MC_PRIVATE_H
9
10 #include "simgrid_config.h"
11 #include <stdio.h>
12 #include <stdint.h>
13 #include <stdbool.h>
14 #ifndef WIN32
15 #include <sys/mman.h>
16 #endif
17 #include <elfutils/libdw.h>
18
19 #include "mc/mc.h"
20 #include "mc_base.h"
21 #include "mc/datatypes.h"
22 #include "xbt/fifo.h"
23 #include "xbt/config.h"
24 #include "xbt/function_types.h"
25 #include "xbt/mmalloc.h"
26 #include "../simix/smx_private.h"
27 #include "../xbt/mmalloc/mmprivate.h"
28 #include "xbt/automaton.h"
29 #include "xbt/hash.h"
30 #include "msg/msg.h"
31 #include "msg/datatypes.h"
32 #include "xbt/strbuff.h"
33 #include "xbt/parmap.h"
34
35 #include "mc_forward.h"
36
37 SG_BEGIN_DECL()
38
39 typedef struct s_mc_function_index_item s_mc_function_index_item_t, *mc_function_index_item_t;
40
41 /****************************** Snapshots ***********************************/
42
43 extern xbt_dynar_t mc_checkpoint_ignore;
44
45 /********************************* MC Global **********************************/
46
47 extern FILE *dot_output;
48 extern const char* colors[13];
49 extern xbt_parmap_t parmap;
50
51 extern int user_max_depth_reached;
52
53 int MC_deadlock_check(void);
54 void MC_replay(xbt_fifo_t stack, int start);
55 void MC_replay_liveness(xbt_fifo_t stack, int all_stack);
56 void MC_show_deadlock(smx_simcall_t req);
57 void MC_show_stack_safety(xbt_fifo_t stack);
58 void MC_dump_stack_safety(xbt_fifo_t stack);
59
60 /** Stack (of `mc_state_t`) representing the current position of the
61  *  the MC in the exploration graph
62  *
63  *  It is managed by its head (`xbt_fifo_shift` and `xbt_fifo_unshift`).
64  */
65 extern xbt_fifo_t mc_stack;
66
67 int get_search_interval(xbt_dynar_t list, void *ref, int *min, int *max);
68
69
70 /****************************** Statistics ************************************/
71
72 typedef struct mc_stats {
73   unsigned long state_size;
74   unsigned long visited_states;
75   unsigned long visited_pairs;
76   unsigned long expanded_states;
77   unsigned long expanded_pairs;
78   unsigned long executed_transitions;
79 } s_mc_stats_t, *mc_stats_t;
80
81 extern mc_stats_t mc_stats;
82
83 void MC_print_statistics(mc_stats_t stats);
84
85 /********************************** Snapshot comparison **********************************/
86
87 typedef struct s_mc_comparison_times{
88   double nb_processes_comparison_time;
89   double bytes_used_comparison_time;
90   double stacks_sizes_comparison_time;
91   double binary_global_variables_comparison_time;
92   double libsimgrid_global_variables_comparison_time;
93   double heap_comparison_time;
94   double stacks_comparison_time;
95 }s_mc_comparison_times_t, *mc_comparison_times_t;
96
97 extern __thread mc_comparison_times_t mc_comp_times;
98 extern __thread double mc_snapshot_comparison_time;
99
100 int snapshot_compare(void *state1, void *state2);
101 void print_comparison_times(void);
102
103 //#define MC_DEBUG 1
104 #define MC_VERBOSE 1
105
106 /********************************** Variables with DWARF **********************************/
107
108 void MC_find_object_address(memory_map_t maps, mc_object_info_t result);
109
110 /********************************** Miscellaneous **********************************/
111
112 typedef struct s_local_variable{
113   dw_frame_t subprogram;
114   unsigned long ip;
115   char *name;
116   dw_type_t type;
117   void *address;
118   int region;
119 }s_local_variable_t, *local_variable_t;
120
121 /* *********** Sets *********** */
122
123 typedef struct s_mc_address_set *mc_address_set_t;
124
125 mc_address_set_t mc_address_set_new(void);
126 void mc_address_set_free(mc_address_set_t* p);
127 void mc_address_add(mc_address_set_t p, const void* value);
128 bool mc_address_test(mc_address_set_t p, const void* value);
129
130 /* *********** Hash *********** */
131
132 /** \brief Hash the current state
133  *  \param num_state number of states
134  *  \param stacks stacks (mc_snapshot_stak_t) used fot the stack unwinding informations
135  *  \result resulting hash
136  * */
137 uint64_t mc_hash_processes_state(int num_state, xbt_dynar_t stacks);
138
139 /* *********** Snapshot *********** */
140
141 #define MC_LOG_REQUEST(log, req, value) \
142   if (XBT_LOG_ISENABLED(log, xbt_log_priority_debug)) { \
143     char* req_str = MC_request_to_string(req, value); \
144     XBT_DEBUG("Execute: %s", req_str); \
145     xbt_free(req_str); \
146   }
147
148 /** @brief Dump the stacks of the application processes
149  *
150  *   This functions is currently not used but it is quite convenient
151  *   to call from the debugger.
152  *
153  *   Does not work when an application thread is running.
154  */
155 void MC_dump_stacks(FILE* file);
156
157 SG_END_DECL()
158
159 #endif