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 typedef SnapList<ModelAction *> action_list_t;
23 /** @brief Model checker execution stats */
24 struct execution_stats {
25 int num_total; /**< @brief Total number of executions */
26 int num_buggy_executions; /** @brief Number of buggy executions */
27 int num_complete; /**< @brief Number of feasible, non-buggy, complete executions */
30 /** @brief The central structure for model-checking */
35 model_params * getParams();
38 /** Restart the model checker, intended for pluggins. */
41 /** Exit the model checker, intended for pluggins. */
42 void exit_model_checker();
44 /** @returns the context for the main model-checking system thread */
45 ucontext_t * get_system_context() { return &system_context; }
47 ModelExecution * get_execution() const { return execution; }
48 ModelHistory * get_history() const { return history; }
50 int get_execution_number() const { return execution_number; }
52 Thread * get_thread(thread_id_t tid) const;
53 Thread * get_thread(const ModelAction *act) const;
55 Thread * get_current_thread() const;
57 void switch_from_master(Thread *thread);
58 uint64_t switch_to_master(ModelAction *act);
60 void assert_bug(const char *msg, ...);
62 void assert_user_bug(const char *msg);
65 void add_trace_analysis(TraceAnalysis *a) { trace_analyses.push_back(a); }
66 void set_inspect_plugin(TraceAnalysis *a) { inspect_plugin=a; }
68 Thread * getInitThread() {return init_thread;}
69 Scheduler * getScheduler() {return scheduler;}
72 /** Flag indicates whether to restart the model checker. */
75 /** Snapshot id we return to restart. */
78 /** The scheduler to use: tracks the running/ready Threads */
79 Scheduler * const scheduler;
80 ModelHistory * history;
81 ModelExecution *execution;
86 unsigned int get_num_threads() const;
88 bool next_execution();
89 bool should_terminate_execution();
91 Thread * get_next_thread();
92 void reset_to_initial_state();
94 ucontext_t system_context;
96 ModelVector<TraceAnalysis *> trace_analyses;
98 /** @bref Implement restart. */
100 /** @bref Plugin that can inspect new actions. */
101 TraceAnalysis *inspect_plugin;
102 /** @brief The cumulative execution stats */
103 struct execution_stats stats;
105 void run_trace_analyses();
106 void print_bugs() const;
107 void print_execution(bool printbugs) const;
108 void print_stats() const;
111 extern ModelChecker *model;
112 void parse_options(struct model_params *params);
113 void install_trace_analyses(ModelExecution *execution);
115 #endif /* __MODEL_H__ */