2 * @brief Core model checker.
12 #include "hashtable.h"
14 #include "modeltypes.h"
15 #include "stl-model.h"
19 /* Forward declaration */
31 typedef SnapList<ModelAction *> action_list_t;
33 /** @brief Model checker execution stats */
34 struct execution_stats {
35 int num_total; /**< @brief Total number of executions */
36 int num_infeasible; /**< @brief Number of infeasible executions */
37 int num_buggy_executions; /** @brief Number of buggy executions */
38 int num_complete; /**< @brief Number of feasible, non-buggy, complete executions */
39 int num_redundant; /**< @brief Number of redundant, aborted executions */
42 /** @brief The central structure for model-checking */
45 ModelChecker(struct model_params params);
50 /** @returns the context for the main model-checking system thread */
51 ucontext_t * get_system_context() { return &system_context; }
53 ModelExecution * get_execution() const { return execution; }
55 int get_execution_number() const { return execution_number; }
57 Thread * get_thread(thread_id_t tid) const;
58 Thread * get_thread(const ModelAction *act) const;
60 bool is_enabled(Thread *t) const;
61 bool is_enabled(thread_id_t tid) const;
63 Thread * get_current_thread() const;
65 void switch_from_master(Thread *thread);
66 uint64_t switch_to_master(ModelAction *act);
68 bool assert_bug(const char *msg, ...);
69 void assert_user_bug(const char *msg);
71 const model_params params;
72 void add_trace_analysis(TraceAnalysis *a) {
73 trace_analyses.push_back(a);
78 /** The scheduler to use: tracks the running/ready Threads */
79 Scheduler * const scheduler;
80 NodeStack * const node_stack;
81 ModelExecution *execution;
85 unsigned int get_num_threads() const;
87 void execute_sleep_set();
89 bool next_execution();
90 bool should_terminate_execution();
92 Thread * get_next_thread();
93 void reset_to_initial_state();
97 ModelAction *earliest_diverge;
99 ucontext_t system_context;
101 ModelVector<TraceAnalysis *> trace_analyses;
103 /** @brief The cumulative execution stats */
104 struct execution_stats stats;
106 void run_trace_analyses();
107 void print_bugs() const;
108 void print_execution(bool printbugs) const;
109 void print_stats() const;
111 friend void user_main_wrapper();
114 extern ModelChecker *model;
116 #endif /* __MODEL_H__ */