1 /* Copyright (c) 2007-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_PRIVATE_H
8 #define SIMGRID_MC_PRIVATE_H
10 #include <sys/types.h>
12 #include "simgrid_config.h"
22 #include "mc/datatypes.h"
24 #include "xbt/config.h"
26 #include "xbt/function_types.h"
27 #include "xbt/mmalloc.h"
28 #include "../simix/smx_private.h"
29 #include "../xbt/mmalloc/mmprivate.h"
30 #include "xbt/automaton.h"
32 #include <simgrid/msg.h>
33 #include "xbt/strbuff.h"
34 #include "xbt/parmap.h"
36 #include "mc_forward.h"
37 #include "mc_protocol.h"
41 typedef struct s_mc_function_index_item s_mc_function_index_item_t, *mc_function_index_item_t;
43 /********************************* MC Global **********************************/
45 /** Initialisation of the model-checker
47 * @param pid PID of the target process
48 * @param socket FD for the communication socket **in server mode** (or -1 otherwise)
50 void MC_init_model_checker(pid_t pid, int socket);
52 XBT_INTERNAL extern FILE *dot_output;
53 XBT_INTERNAL extern const char* colors[13];
54 XBT_INTERNAL extern xbt_parmap_t parmap;
56 XBT_INTERNAL extern int user_max_depth_reached;
58 XBT_INTERNAL int MC_deadlock_check(void);
59 XBT_INTERNAL void MC_replay(xbt_fifo_t stack);
60 XBT_INTERNAL void MC_replay_liveness(xbt_fifo_t stack);
61 XBT_INTERNAL void MC_show_deadlock(smx_simcall_t req);
62 XBT_INTERNAL void MC_show_stack_safety(xbt_fifo_t stack);
63 XBT_INTERNAL void MC_dump_stack_safety(xbt_fifo_t stack);
64 XBT_INTERNAL void MC_show_non_termination(void);
66 /** Stack (of `mc_state_t`) representing the current position of the
67 * the MC in the exploration graph
69 * It is managed by its head (`xbt_fifo_shift` and `xbt_fifo_unshift`).
71 XBT_INTERNAL extern xbt_fifo_t mc_stack;
73 XBT_INTERNAL int get_search_interval(xbt_dynar_t list, void *ref, int *min, int *max);
76 /****************************** Statistics ************************************/
78 typedef struct mc_stats {
79 unsigned long state_size;
80 unsigned long visited_states;
81 unsigned long visited_pairs;
82 unsigned long expanded_states;
83 unsigned long expanded_pairs;
84 unsigned long executed_transitions;
85 } s_mc_stats_t, *mc_stats_t;
87 XBT_INTERNAL extern mc_stats_t mc_stats;
89 XBT_INTERNAL void MC_print_statistics(mc_stats_t stats);
91 /********************************** Snapshot comparison **********************************/
93 typedef struct s_mc_comparison_times{
94 double nb_processes_comparison_time;
95 double bytes_used_comparison_time;
96 double stacks_sizes_comparison_time;
97 double global_variables_comparison_time;
98 double heap_comparison_time;
99 double stacks_comparison_time;
100 }s_mc_comparison_times_t, *mc_comparison_times_t;
102 extern XBT_INTERNAL __thread mc_comparison_times_t mc_comp_times;
103 extern XBT_INTERNAL __thread double mc_snapshot_comparison_time;
105 XBT_INTERNAL int snapshot_compare(void *state1, void *state2);
106 XBT_INTERNAL void print_comparison_times(void);
111 /********************************** Miscellaneous **********************************/
113 XBT_INTERNAL void MC_dump_stacks(FILE* file);
115 XBT_INTERNAL void MC_report_assertion_error(void);
117 XBT_INTERNAL void MC_invalidate_cache(void);