planning to build a predicate generator based on values that have been written to...
[c11tester.git] / execution.cc
index 3f8a78cf0dbf6f1643e0f896852d668d992a1b07..01125bb2b0910b7e64fa3933afed1f1693e01c2a 100644 (file)
@@ -191,6 +191,16 @@ bool ModelExecution::have_bug_reports() const
        return priv->bugs.size() != 0;
 }
 
+/** @return True, if any fatal bugs have been reported for this execution.
+ *  Any bug other than a data race is considered a fatal bug. Data races
+ *  are not considered fatal unless the number of races is exceeds
+ *  a threshold (temporarily set as 15).
+ */
+bool ModelExecution::have_fatal_bug_reports() const
+{
+       return priv->bugs.size() != 0;
+}
+
 SnapVector<bug_message *> * ModelExecution::get_bugs() const
 {
        return &priv->bugs;
@@ -260,13 +270,13 @@ ModelAction * ModelExecution::convertNonAtomicStore(void * location) {
        getStoreThreadAndClock(location, &storethread, &storeclock);
        setAtomicStoreFlag(location);
        ModelAction * act = new ModelAction(NONATOMIC_WRITE, memory_order_relaxed, location, value, get_thread(storethread));
+       act->set_seq_number(storeclock);
        add_normal_write_to_lists(act);
        add_write_to_lists(act);
        w_modification_order(act);
        return act;
 }
 
-
 /**
  * Processes a read model action.
  * @param curr is the read model action to process.
@@ -276,13 +286,13 @@ ModelAction * ModelExecution::convertNonAtomicStore(void * location) {
 void ModelExecution::process_read(ModelAction *curr, SnapVector<ModelAction *> * rf_set)
 {
        SnapVector<const ModelAction *> * priorset = new SnapVector<const ModelAction *>();
-       while(true) {
-               bool hasnonatomicstore = hasNonAtomicStore(curr->get_location());
-               if (hasnonatomicstore) {
-                       ModelAction * nonatomicstore = convertNonAtomicStore(curr->get_location());
-                       rf_set->push_back(nonatomicstore);
-               }
+       bool hasnonatomicstore = hasNonAtomicStore(curr->get_location());
+       if (hasnonatomicstore) {
+               ModelAction * nonatomicstore = convertNonAtomicStore(curr->get_location());
+               rf_set->push_back(nonatomicstore);
+       }
 
+       while(true) {
                int index = fuzzer->selectWrite(curr, rf_set);
                ModelAction *rf = (*rf_set)[index];
 
@@ -1138,8 +1148,6 @@ void insertIntoActionList(action_list_t *list, ModelAction *act) {
                for(;rit != list->rend();rit++) {
                        if ((*rit)->get_seq_number() == next_seq) {
                                action_list_t::iterator it = rit.base();
-                               it++;   //get to right sequence number
-                               it++;   //get to item after it
                                list->insert(it, act);
                                break;
                        }
@@ -1160,8 +1168,6 @@ void insertIntoActionListAndSetCV(action_list_t *list, ModelAction *act) {
                        if ((*rit)->get_seq_number() == next_seq) {
                                act->create_cv((*rit));
                                action_list_t::iterator it = rit.base();
-                               it++;   //get to right sequence number
-                               it++;   //get to item after it
                                list->insert(it, act);
                                break;
                        }
@@ -1180,9 +1186,10 @@ void insertIntoActionListAndSetCV(action_list_t *list, ModelAction *act) {
 void ModelExecution::add_normal_write_to_lists(ModelAction *act)
 {
        int tid = id_to_int(act->get_tid());
+       insertIntoActionListAndSetCV(&action_trace, act);
+
        action_list_t *list = get_safe_ptr_action(&obj_map, act->get_location());
        insertIntoActionList(list, act);
-       insertIntoActionListAndSetCV(&action_trace, act);
 
        // Update obj_thrd_map, a per location, per thread, order of actions
        SnapVector<action_list_t> *vec = get_safe_ptr_vect_action(&obj_thrd_map, act->get_location());
@@ -1623,8 +1630,8 @@ Thread * ModelExecution::take_step(ModelAction *curr)
        curr = check_current_action(curr);
        ASSERT(curr);
 
-       // model_print("poitner loc: %p, thread: %d, type: %d, order: %d, position: %s\n", curr, curr->get_tid(), curr->get_type(), curr->get_mo(), curr->get_position() );
-       model->get_history()->add_func_atomic( curr, curr_thrd->get_id() );
+       /* Process this action in ModelHistory for records*/
+       model->get_history()->process_action( curr, curr->get_tid() );
 
        if (curr_thrd->is_blocked() || curr_thrd->is_complete())
                scheduler->remove_thread(curr_thrd);