1 /* Copyright (c) 2007-2014. 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. */
10 #include "simgrid_config.h"
17 #include <elfutils/libdw.h>
21 #include "mc/datatypes.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"
31 #include "msg/datatypes.h"
32 #include "xbt/strbuff.h"
33 #include "xbt/parmap.h"
35 #include "mc_forward.h"
39 typedef struct s_mc_function_index_item s_mc_function_index_item_t, *mc_function_index_item_t;
41 /****************************** Snapshots ***********************************/
43 extern xbt_dynar_t mc_checkpoint_ignore;
45 /********************************* MC Global **********************************/
47 extern FILE *dot_output;
48 extern const char* colors[13];
49 extern xbt_parmap_t parmap;
51 extern int user_max_depth_reached;
53 int MC_deadlock_check(void);
54 void MC_replay(xbt_fifo_t stack);
55 void MC_replay_liveness(xbt_fifo_t 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 void MC_show_non_termination(void);
61 /** Stack (of `mc_state_t`) representing the current position of the
62 * the MC in the exploration graph
64 * It is managed by its head (`xbt_fifo_shift` and `xbt_fifo_unshift`).
66 extern xbt_fifo_t mc_stack;
68 int get_search_interval(xbt_dynar_t list, void *ref, int *min, int *max);
71 /****************************** Statistics ************************************/
73 typedef struct mc_stats {
74 unsigned long state_size;
75 unsigned long visited_states;
76 unsigned long visited_pairs;
77 unsigned long expanded_states;
78 unsigned long expanded_pairs;
79 unsigned long executed_transitions;
80 } s_mc_stats_t, *mc_stats_t;
82 extern mc_stats_t mc_stats;
84 void MC_print_statistics(mc_stats_t stats);
86 extern char *libsimgrid_path;
88 /********************************** Snapshot comparison **********************************/
90 typedef struct s_mc_comparison_times{
91 double nb_processes_comparison_time;
92 double bytes_used_comparison_time;
93 double stacks_sizes_comparison_time;
94 double binary_global_variables_comparison_time;
95 double libsimgrid_global_variables_comparison_time;
96 double heap_comparison_time;
97 double stacks_comparison_time;
98 }s_mc_comparison_times_t, *mc_comparison_times_t;
100 extern __thread mc_comparison_times_t mc_comp_times;
101 extern __thread double mc_snapshot_comparison_time;
103 int snapshot_compare(void *state1, void *state2);
104 void print_comparison_times(void);
109 /********************************** Variables with DWARF **********************************/
111 dw_frame_t MC_find_function_by_ip(void* ip);
112 mc_object_info_t MC_ip_find_object_info(void* ip);
114 void MC_find_object_address(memory_map_t maps, mc_object_info_t result);
116 /********************************** Miscellaneous **********************************/
118 typedef struct s_local_variable{
119 dw_frame_t subprogram;
125 }s_local_variable_t, *local_variable_t;
127 /* *********** Sets *********** */
129 typedef struct s_mc_address_set *mc_address_set_t;
131 mc_address_set_t mc_address_set_new(void);
132 void mc_address_set_free(mc_address_set_t* p);
133 void mc_address_add(mc_address_set_t p, const void* value);
134 bool mc_address_test(mc_address_set_t p, const void* value);
136 /* *********** Hash *********** */
138 /** \brief Hash the current state
139 * \param num_state number of states
140 * \param stacks stacks (mc_snapshot_stak_t) used fot the stack unwinding informations
141 * \result resulting hash
143 uint64_t mc_hash_processes_state(int num_state, xbt_dynar_t stacks);
145 /** @brief Dump the stacks of the application processes
147 * This functions is currently not used but it is quite convenient
148 * to call from the debugger.
150 * Does not work when an application thread is running.
152 void MC_dump_stacks(FILE* file);