int main_argc;
char **main_argv;
-/** Wrapper to run the user's main function, with appropriate arguments */
-void wrapper_user_main(void *)
-{
- user_main(main_argc, main_argv);
-}
-
/** The model_main function contains the main model checking loop. */
static void model_main() {
- thrd_t user_thread;
struct model_params params;
param_defaults(¶ms);
snapshotObject = new SnapshotStack();
model = new ModelChecker(params);
-
snapshotObject->snapshotStep(0);
- do {
- /* Start user program */
- model->add_thread(new Thread(&user_thread, &wrapper_user_main, NULL));
-
- /* Wait for all threads to complete */
- model->finish_execution();
- } while (model->next_execution());
-
- model->print_stats();
-
+ model->run();
delete model;
DEBUG("Exiting\n");
while (take_step());
}
+
+/** Wrapper to run the user's main function, with appropriate arguments */
+void user_main_wrapper(void *)
+{
+ user_main(model->params.argc, model->params.argv);
+}
+
+/** @brief Run ModelChecker for the user program */
+void ModelChecker::run()
+{
+ do {
+ thrd_t user_thread;
+
+ /* Start user program */
+ add_thread(new Thread(&user_thread, &user_main_wrapper, NULL));
+
+ /* Wait for all threads to complete */
+ finish_execution();
+ } while (next_execution());
+
+ print_stats();
+}
ModelChecker(struct model_params params);
~ModelChecker();
+ void run();
+
/** @returns the context for the main model-checking system thread */
ucontext_t * get_system_context() { return &system_context; }
bool have_bug_reports() const;
void print_bugs() const;
void print_execution(bool printbugs) const;
+
+ friend void user_main_wrapper();
};
extern ModelChecker *model;