move modelhistory code back
[c11tester.git] / history.cc
index 782da5a3b01690b59081f194ff15f74dade1868f..0a25caf530828ad7955cadfcc574d4443ee0a675 100644 (file)
@@ -99,6 +99,8 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
        /* return if thread i has not entered any function or has exited
           from all functions */
        SnapVector<func_id_list_t> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+       SnapVector< SnapList<action_list_t *> *> *
+               thrd_func_act_lists = model->get_execution()->get_thrd_func_act_lists();
 
        uint32_t id = id_to_int(tid);
        if ( thrd_func_list->size() <= id )
@@ -106,6 +108,7 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
 
        /* get the function id that thread i is currently in */
        uint32_t func_id = (*thrd_func_list)[id].back();
+       SnapList<action_list_t *> * func_act_lists = (*thrd_func_act_lists)[id];
 
        if (func_id == 0)
                return;
@@ -113,9 +116,8 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
                resize_func_nodes( func_id + 1 );
 
        FuncNode * func_node = func_nodes[func_id];
-       ASSERT (func_node != NULL);
 
-       /* do not care actions without a position */
+       /* do not care about actions without a position */
        if (act->get_position() == NULL)
                return;
 
@@ -124,12 +126,26 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
 
        if (act->is_write())
                add_to_write_history(act->get_location(), act->get_write_value());
+
+       /* add to curr_inst_list */
+       action_list_t * curr_act_list = func_act_lists->back();
+       ASSERT(curr_act_list != NULL);
+
+       ModelAction * last_act;
+       if (curr_act_list->size() != 0)
+               last_act = curr_act_list->back();
+
+       /* do not add actions with the same sequence number twice */
+       if (last_act != NULL && last_act->get_seq_number() == act->get_seq_number())
+               return;
+
+       curr_act_list->push_back(act);
 }
 
 /* return the FuncNode given its func_id  */
 FuncNode * ModelHistory::get_func_node(uint32_t func_id)
 {
-       if (func_nodes.size() <= func_id)       // this node has not been added
+       if (func_nodes.size() <= func_id)       // this node has not been added to func_nodes
                return NULL;
 
        return func_nodes[func_id];