move write_history to funcnode.cc was a mistake
authorweiyu <weiyuluo1232@gmail.com>
Tue, 30 Jul 2019 20:50:24 +0000 (13:50 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Tue, 30 Jul 2019 20:50:24 +0000 (13:50 -0700)
funcnode.cc
funcnode.h
history.cc
history.h

index 2da1f66..abc94a5 100644 (file)
@@ -5,9 +5,7 @@ FuncNode::FuncNode() :
        func_inst_map(),
        inst_list(),
        entry_insts(),
        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
 {}
 
 /* Check whether FuncInst with the same type, position, and location
@@ -156,19 +154,6 @@ void FuncNode::clear_read_map(uint32_t tid)
        thrd_read_map[tid]->reset();
 }
 
        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)
 {
        
 void FuncNode::generate_predicate(FuncInst *func_inst)
 {
        
@@ -192,32 +177,3 @@ void FuncNode::print_last_read(uint32_t tid)
        }
 */
 }
        }
 */
 }
-
-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;
-}
index b8562d3..d2bc3cf 100644 (file)
@@ -8,7 +8,6 @@
 
 typedef ModelList<FuncInst *> func_inst_list_mt;
 typedef HashTable<void *, uint64_t, uintptr_t, 4, model_malloc, model_calloc, model_free> read_map_t;
 
 typedef ModelList<FuncInst *> func_inst_list_mt;
 typedef HashTable<void *, uint64_t, uintptr_t, 4, model_malloc, model_calloc, model_free> read_map_t;
-typedef HashSet<uint64_t, uint64_t, 0, model_malloc, model_calloc, model_free> write_set_t;
 
 class FuncNode {
 public:
 
 class FuncNode {
 public:
@@ -32,13 +31,10 @@ public:
        uint64_t query_last_read(void * location, uint32_t tid);
        void clear_read_map(uint32_t tid);
 
        uint64_t query_last_read(void * location, uint32_t tid);
        void clear_read_map(uint32_t tid);
 
-       void add_to_write_history(void * location, uint64_t write_val);
-
        /* TODO: generate EQUALITY or NULLITY predicate based on write_history in history.cc */
        void generate_predicate(FuncInst * func_inst);
 
        void print_last_read(uint32_t tid);
        /* TODO: generate EQUALITY or NULLITY predicate based on write_history in history.cc */
        void generate_predicate(FuncInst * func_inst);
 
        void print_last_read(uint32_t tid);
-       void print_write();
 
        MEMALLOC
 private:
 
        MEMALLOC
 private:
@@ -59,8 +55,6 @@ private:
        /* Store the values read by atomic read actions per memory location for each thread */
        ModelVector<read_map_t *> thrd_read_map;
 
        /* Store the values read by atomic read actions per memory location for each thread */
        ModelVector<read_map_t *> thrd_read_map;
 
-       HashTable<void *, write_set_t *, uintptr_t, 4, model_malloc, model_calloc, model_free> write_history;
-       HashSet<void *, uintptr_t, 4, model_malloc, model_calloc, model_free> write_locations;
 };
 
 #endif /* __FUNCNODE_H__ */
 };
 
 #endif /* __FUNCNODE_H__ */
index 3d6599b..820f3df 100644 (file)
@@ -13,7 +13,9 @@ ModelHistory::ModelHistory() :
        func_counter(1),        /* function id starts with 1 */
        func_map(),
        func_map_rev(),
        func_counter(1),        /* function id starts with 1 */
        func_map(),
        func_map_rev(),
-       func_nodes()
+       func_nodes(),
+       write_history(),
+       write_locations()
 {}
 
 void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
 {}
 
 void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
@@ -153,13 +155,21 @@ uint64_t ModelHistory::query_last_read(void * location, thread_id_t tid)
        return last_read_val;
 }
 
        return last_read_val;
 }
 
-void ModelHistory::print_write()
+void ModelHistory::add_to_write_history(void * location, uint64_t write_val)
 {
 {
-       for (uint32_t i = 1; i < func_nodes.size(); i++) {
-               FuncNode * func_node = func_nodes[i];
-               model_print("function id: %d, name: %s --- ", i, func_node->get_func_name());
-               func_node->print_write();
+       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 ModelHistory::print_write()
+{
 }
 
 void ModelHistory::print_func_node()
 }
 
 void ModelHistory::print_func_node()
index 0179d10..f562c0f 100644 (file)
--- a/history.h
+++ b/history.h
@@ -45,6 +45,9 @@ private:
        ModelVector<const char *> func_map_rev;
 
        ModelVector<FuncNode *> func_nodes;
        ModelVector<const char *> func_map_rev;
 
        ModelVector<FuncNode *> func_nodes;
+
+       HashTable<void *, write_set_t *, uintptr_t, 4, model_malloc, model_calloc, model_free> write_history;
+       HashSet<void *, uintptr_t, 4, model_malloc, model_calloc, model_free> write_locations;
 };
 
 #endif /* __HISTORY_H__ */
 };
 
 #endif /* __HISTORY_H__ */