2 * @brief Core model checker.
12 #include "hashtable.h"
14 #include "modeltypes.h"
15 #include "stl-model.h"
18 #include "classlist.h"
19 #include "snapshot-interface.h"
21 /** @brief Model checker execution stats */
22 struct execution_stats {
23 int num_total; /**< @brief Total number of executions */
24 int num_buggy_executions; /** @brief Number of buggy executions */
25 int num_complete; /**< @brief Number of feasible, non-buggy, complete executions */
28 /** @brief The central structure for model-checking */
33 model_params * getParams();
35 /** Exit the model checker, intended for pluggins. */
36 void exit_model_checker();
38 ModelExecution * get_execution() const { return execution; }
39 ModelHistory * get_history() const { return history; }
41 int get_execution_number() const { return execution_number; }
43 Thread * get_thread(thread_id_t tid) const;
44 Thread * get_thread(const ModelAction *act) const;
46 Thread * get_current_thread() const;
48 uint64_t switch_thread(ModelAction *act);
50 void assert_bug(const char *msg, ...);
52 void assert_user_bug(const char *msg);
55 void add_trace_analysis(TraceAnalysis *a) { trace_analyses.push_back(a); }
56 void set_inspect_plugin(TraceAnalysis *a) { inspect_plugin=a; }
58 Thread * getInitThread() {return init_thread;}
59 Scheduler * getScheduler() {return scheduler;}
62 /** Snapshot id we return to restart. */
65 /** The scheduler to use: tracks the running/ready Threads */
66 Scheduler * const scheduler;
67 ModelHistory * history;
68 ModelExecution *execution;
73 unsigned int curr_thread_num;
74 Thread * chosen_thread;
78 void startRunExecution(Thread *old);
79 void finishRunExecution(Thread *old);
81 void chooseThread(ModelAction *act, Thread *thr);
82 Thread * getNextThread(Thread *old);
83 void handleChosenThread(Thread *old);
85 modelclock_t checkfree;
87 unsigned int get_num_threads() const;
89 void finish_execution(bool moreexecutions);
90 bool should_terminate_execution();
92 Thread * get_next_thread();
93 void reset_to_initial_state();
95 ModelVector<TraceAnalysis *> trace_analyses;
96 char random_state[256];
98 /** @bref Plugin that can inspect new actions. */
99 TraceAnalysis *inspect_plugin;
100 /** @brief The cumulative execution stats */
101 struct execution_stats stats;
103 void run_trace_analyses();
104 void print_bugs() const;
105 void print_execution(bool printbugs) const;
106 void print_stats() const;
109 extern ModelChecker *model;
110 void parse_options(struct model_params *params);
111 void install_trace_analyses(ModelExecution *execution);
113 #endif /* __MODEL_H__ */