fix bug
[c11tester.git] / funcnode.cc
index 2da1f66d200df993f16989e1f258a03cfd502286..2b2525466d24652e4f7d703f8caf1ceed63077cb 100644 (file)
@@ -5,9 +5,7 @@ FuncNode::FuncNode() :
        func_inst_map(),
        inst_list(),
        entry_insts(),
-       thrd_read_map(),
-       write_history(),
-       write_locations()
+       thrd_read_map()
 {}
 
 /* Check whether FuncInst with the same type, position, and location
@@ -63,9 +61,9 @@ void FuncNode::add_entry_inst(FuncInst * inst)
        if (inst == NULL)
                return;
 
-       func_inst_list_mt::iterator it;
-       for (it = entry_insts.begin();it != entry_insts.end();it++) {
-               if (inst == *it)
+       mllnode<FuncInst*>* it;
+       for (it = entry_insts.begin();it != NULL;it=it->getNext()) {
+               if (inst == it->getVal())
                        return;
        }
 
@@ -80,28 +78,28 @@ void FuncNode::link_insts(func_inst_list_t * inst_list)
        if (inst_list == NULL)
                return;
 
-       func_inst_list_t::iterator it = inst_list->begin();
-       func_inst_list_t::iterator prev;
+       sllnode<FuncInst *>* it = inst_list->begin();
+       sllnode<FuncInst *>* prev;
 
        if (inst_list->size() == 0)
                return;
 
        /* add the first instruction to the list of entry insts */
-       FuncInst * entry_inst = *it;
+       FuncInst * entry_inst = it->getVal();
        add_entry_inst(entry_inst);
 
-       it++;
-       while (it != inst_list->end()) {
+       it=it->getNext();
+       while (it != NULL) {
                prev = it;
-               prev--;
+               prev = it->getPrev();
 
-               FuncInst * prev_inst = *prev;
-               FuncInst * curr_inst = *it;
+               FuncInst * prev_inst = prev->getVal();
+               FuncInst * curr_inst = it->getVal();
 
                prev_inst->add_succ(curr_inst);
                curr_inst->add_pred(prev_inst);
 
-               it++;
+               it=it->getNext();
        }
 }
 
@@ -118,7 +116,7 @@ void FuncNode::store_read(ModelAction * act, uint32_t tid)
        uint32_t old_size = thrd_read_map.size();
        if (old_size <= tid) {
                thrd_read_map.resize(tid + 1);
-               for (uint32_t i = old_size; i < tid + 1; i++)
+               for (uint32_t i = old_size;i < tid + 1;i++)
                        thrd_read_map[i] = new read_map_t();
        }
 
@@ -156,22 +154,9 @@ void FuncNode::clear_read_map(uint32_t tid)
        thrd_read_map[tid]->reset();
 }
 
-void FuncNode::add_to_write_history(void * location, uint64_t write_val)
-{
-       write_set_t * write_set = write_history.get(location);
-
-       if (write_set == NULL) {
-               write_set = new write_set_t();
-               write_history.put(location, write_set);
-       }
-
-       write_set->add(write_val);
-       write_locations.add(location);
-}
-
 void FuncNode::generate_predicate(FuncInst *func_inst)
 {
-       
+
 }
 
 /* @param tid thread id
@@ -182,42 +167,13 @@ void FuncNode::print_last_read(uint32_t tid)
        ASSERT(thrd_read_map.size() > tid);
        read_map_t * read_map = thrd_read_map[tid];
 /*
-       ModelList<void *>::iterator it;
-       for (it = read_locations.begin();it != read_locations.end();it++) {
-               if ( !read_map->contains(*it) )
+       mllnode<void *> * it;
+       for (it = read_locations.begin();it != NULL;it=it->getNext()) {
+               if ( !read_map->contains(it->getVal()) )
                        break;
 
-               uint64_t read_val = read_map->get(*it);
-               model_print("last read of thread %d at %p: 0x%x\n", tid, *it, read_val);
+               uint64_t read_val = read_map->get(it->getVal());
+               model_print("last read of thread %d at %p: 0x%x\n", tid, it->getVal(), read_val);
        }
 */
 }
-
-void FuncNode::print_write()
-{
-       HSIterator<void *, uintptr_t, 4, model_malloc, model_calloc, model_free> * iter;
-       HSIterator<uint64_t, uint64_t, 0, model_malloc, model_calloc, model_free> * write_iter;
-       iter = write_locations.iterator();
-
-       if (write_locations.getSize() > 10) {
-               while (iter->hasNext()) {
-                       void * location = iter->next();
-                       write_set_t * write_set = write_history.get(location);
-
-//                     model_print("location: %p contains %d writes\n", location, write_set->getSize());
-                       if (write_set->getSize() > 5) {
-                               model_print("location %p has writes: ", location);
-                               write_iter = write_set->iterator();
-
-                               while (write_iter->hasNext()) {
-                                       uint64_t val = write_iter->next();
-                                       model_print("%lx ", val);
-                               }
-                               model_print("\n");
-                       }
-               }
-       } else {
-               model_print("\n");
-       }
-       delete iter;
-}