small changes
[c11tester.git] / history.cc
index 762849bf1fb92a8d3a93df7133ecab65da6a00cb..f84af3f0f4cd024e954fdf7c9e642b2510adb5ae 100644 (file)
 /** @brief Constructor */
 ModelHistory::ModelHistory() :
        func_counter(1),        /* function id starts with 1 */
+       last_seq_number(INIT_SEQ_NUMBER),
        func_map(),
        func_map_rev(),
-       func_nodes(),
-       last_action(NULL)
+       func_nodes()
 {
        /* The following are snapshot data structures */
        write_history = new HashTable<void *, value_set_t *, uintptr_t, 0>();
@@ -28,7 +28,6 @@ ModelHistory::ModelHistory() :
        thrd_last_entered_func = new SnapVector<uint32_t>();
        thrd_waiting_write = new SnapVector<ConcretePredicate *>();
        thrd_wait_obj = new SnapVector<WaitObj *>();
-       func_inst_act_maps = new HashTable<uint32_t, SnapVector<inst_act_map_t *> *, int, 0>(128);
 }
 
 ModelHistory::~ModelHistory()
@@ -87,8 +86,7 @@ void ModelHistory::exit_function(const uint32_t func_id, thread_id_t tid)
 
                (*thrd_func_list)[id].pop_back();
        } else {
-               model_print("trying to exit with a wrong function id\n");
-               model_print("--- last_func: %d, func_id: %d\n", last_func_id, func_id);
+               ASSERT(false);
        }
        //model_print("thread %d exiting func %d\n", tid, func_id);
 }
@@ -149,28 +147,8 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
        FuncNode * func_node = func_nodes[func_id];
        func_node->add_inst(act);
 
-       if (act->is_read()) {
-               func_node->update_inst_act_map(tid, act);
-
-//             Fuzzer * fuzzer = model->get_execution()->getFuzzer();
-//             Predicate * selected_branch = ((NewFuzzer *)fuzzer)->get_selected_child_branch(tid);
-//             func_node->set_predicate_tree_position(tid, selected_branch);
-       }
-/*
-       if (act->is_write()) {
-               Predicate * curr_pred = func_node->get_predicate_tree_position(tid);
-               FuncInst * curr_inst = func_node->get_inst(act);
-
-               if (curr_pred) {
-                       // Follow child
-                       curr_pred = curr_pred->follow_write_child(curr_inst);
-               }
-               func_node->set_predicate_tree_position(tid, curr_pred);
-       }
-*/
-
        func_node->update_tree(act);
-       last_action = act;
+       last_seq_number = act->get_seq_number();
 }
 
 /* Return the FuncNode given its func_id  */
@@ -403,19 +381,6 @@ void ModelHistory::stop_waiting_for_node(thread_id_t self_id,
        }
 }
 
-SnapVector<inst_act_map_t *> * ModelHistory::getThrdInstActMap(uint32_t func_id)
-{
-       ASSERT(func_id != 0);
-
-       SnapVector<inst_act_map_t *> * maps = func_inst_act_maps->get(func_id);
-       if (maps == NULL) {
-               maps = new SnapVector<inst_act_map_t *>();
-               func_inst_act_maps->put(func_id, maps);
-       }
-
-       return maps;
-}
-
 bool ModelHistory::skip_action(ModelAction * act)
 {
        bool second_part_of_rmw = act->is_rmwc() || act->is_rmw();
@@ -426,10 +391,8 @@ bool ModelHistory::skip_action(ModelAction * act)
                return true;
 
        /* Skip actions with the same sequence number */
-       if (last_action != NULL) {
-               if (last_action->get_seq_number() == curr_seq_number)
-                       return true;
-       }
+       if (last_seq_number != INIT_SEQ_NUMBER && last_seq_number == curr_seq_number)
+               return true;
 
        /* Skip actions that are paused by fuzzer (sequence number is 0) */
        if (curr_seq_number == 0)
@@ -539,15 +502,15 @@ void ModelHistory::print_func_node()
                func_node->print_predicate_tree();
 
 /*
-               func_inst_list_mt * entry_insts = func_node->get_entry_insts();
-               model_print("function %s has entry actions\n", func_node->get_func_name());
-
-               mllnode<FuncInst*>* it;
-               for (it = entry_insts->begin();it != NULL;it=it->getNext()) {
-                       FuncInst *inst = it->getVal();
-                       model_print("type: %d, at: %s\n", inst->get_type(), inst->get_position());
-               }
-*/
+                func_inst_list_mt * entry_insts = func_node->get_entry_insts();
+                model_print("function %s has entry actions\n", func_node->get_func_name());
+
+                mllnode<FuncInst*>* it;
+                for (it = entry_insts->begin();it != NULL;it=it->getNext()) {
+                        FuncInst *inst = it->getVal();
+                        model_print("type: %d, at: %s\n", inst->get_type(), inst->get_position());
+                }
+ */
        }
 }