From: weiyu Date: Sat, 20 Jul 2019 00:39:33 +0000 (-0700) Subject: able to get a FuncNode by function id X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3af3ac7e5138cbb6e239edfbc857d71ab8cb60cf;p=c11tester.git able to get a FuncNode by function id --- diff --git a/funcnode.cc b/funcnode.cc index 6b1f1997..f5fa7127 100644 --- a/funcnode.cc +++ b/funcnode.cc @@ -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) { diff --git a/history.cc b/history.cc index ee4c90a0..4dfbd409 100644 --- a/history.cc +++ b/history.cc @@ -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 */ diff --git a/history.h b/history.h index 6da1be11..2c359c92 100644 --- a/history.h +++ b/history.h @@ -20,6 +20,7 @@ public: ModelVector * getFuncMapRev() { return &func_map_rev; } ModelVector * getFuncNodes() { return &func_nodes; } + FuncNode * get_func_node(uint32_t func_id); void print();