model: add promise printing to execution summaries
[model-checker.git] / model.cc
index 7a5edc7a1b8666ff8be384edd4e06f0e3ccc3f5e..62550da7f4bd30398650b188ddc13dc1b82d1986 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -401,14 +401,14 @@ bool ModelChecker::is_deadlocked() const
 }
 
 /**
- * Check if a Thread has entered a deadlock situation. This will not check
- * other threads for potential deadlock situations, and may miss deadlocks
- * involving WAIT.
+ * Check if a Thread has entered a circular wait deadlock situation. This will
+ * not check other threads for potential deadlock situations, and may miss
+ * deadlocks involving WAIT.
  *
  * @param t The thread which may have entered a deadlock
  * @return True if this Thread entered a deadlock; false otherwise
  */
-bool ModelChecker::check_deadlock(const Thread *t) const
+bool ModelChecker::is_circular_wait(const Thread *t) const
 {
        for (Thread *waiting = t->waiting_on() ; waiting != NULL; waiting = waiting->waiting_on())
                if (waiting == t)
@@ -2872,6 +2872,14 @@ void ModelChecker::print_summary() const
                print_infeasibility(" INFEASIBLE");
        print_list(action_trace);
        model_print("\n");
+       if (!promises->empty()) {
+               model_print("Pending promises:\n");
+               for (unsigned int i = 0; i < promises->size(); i++) {
+                       model_print(" [P%u] ", i);
+                       (*promises)[i]->print();
+               }
+               model_print("\n");
+       }
 }
 
 /**
@@ -3052,7 +3060,7 @@ void ModelChecker::run()
                                Thread *thr = get_thread(tid);
                                if (!thr->is_model_thread() && !thr->is_complete() && !thr->get_pending()) {
                                        switch_from_master(thr);
-                                       if (check_deadlock(thr))
+                                       if (is_circular_wait(thr))
                                                assert_bug("Deadlock detected");
                                }
                        }