able to get a FuncNode by function id
authorweiyu <weiyuluo1232@gmail.com>
Sat, 20 Jul 2019 00:39:33 +0000 (17:39 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Sat, 20 Jul 2019 00:39:33 +0000 (17:39 -0700)
funcnode.cc
history.cc
history.h

index 6b1f199792f299cb64ffdbda5143ddd2ca1acf23..f5fa71279e688e5cce1273d0b7ba54f24321c9f9 100644 (file)
@@ -164,7 +164,7 @@ void FuncNode::clear_read_map(uint32_t tid)
 }
 
 /* @param tid thread id
- * Print the values read by the last read actions per memory location
+ * Print the values read by the last read actions for each memory location
  */
 void FuncNode::print_last_read(uint32_t tid)
 {
index ee4c90a0934240060b62c581840bef111485c5c3..4dfbd409e9a1e72bd0e49539f1a24782ca205851 100644 (file)
@@ -60,8 +60,6 @@ void ModelHistory::exit_function(const uint32_t func_id, thread_id_t tid)
        uint32_t last_func_id = func_list->back();
 
        if (last_func_id == func_id) {
-               func_list->pop_back();
-
                /* clear read map upon exiting functions */
                FuncNode * func_node = func_nodes[func_id];
                func_node->clear_read_map(tid);
@@ -69,6 +67,7 @@ void ModelHistory::exit_function(const uint32_t func_id, thread_id_t tid)
                func_inst_list_t * curr_inst_list = func_inst_lists->back();
                func_node->link_insts(curr_inst_list);
 
+               func_list->pop_back();
                func_inst_lists->pop_back();
        } else {
                model_print("trying to exit with a wrong function id\n");
@@ -125,6 +124,15 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
        curr_inst_list->push_back(inst);
 }
 
+/* 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
+               return NULL;
+
+       return func_nodes[func_id];
+}
+
 void ModelHistory::print()
 {
        /* function id starts with 1 */
index 6da1be11004cca4c16e9df6205d1ff7ac7f98d7e..2c359c92c569f5bad81c4ab6352c9c526ab59ae6 100644 (file)
--- a/history.h
+++ b/history.h
@@ -20,6 +20,7 @@ public:
        ModelVector<const char *> * getFuncMapRev() { return &func_map_rev; }
 
        ModelVector<FuncNode *> * getFuncNodes() { return &func_nodes; }
+       FuncNode * get_func_node(uint32_t func_id);
 
        void print();