From: weiyu Date: Tue, 15 Oct 2019 00:48:50 +0000 (-0700) Subject: Little adjustment X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=cbcd5a166532cd048a90f1ed3eb70adab4a1cfdc Little adjustment --- diff --git a/fuzzer.h b/fuzzer.h index 0d5734d0..c5248d72 100644 --- a/fuzzer.h +++ b/fuzzer.h @@ -9,7 +9,6 @@ class Fuzzer { public: Fuzzer() {} virtual int selectWrite(ModelAction *read, SnapVector* rf_set); - virtual Predicate * get_selected_child_branch(thread_id_t tid) = 0; virtual bool has_paused_threads() { return false; } virtual void notify_paused_thread(Thread * thread) = 0; virtual Thread * selectThread(int * threadlist, int numthreads); diff --git a/history.cc b/history.cc index 34ec0801..afd1f1d1 100644 --- a/history.cc +++ b/history.cc @@ -200,11 +200,6 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid) if (act->is_read()) { func_node->update_inst_act_map(tid, act); - - // Update predicate tree position - Fuzzer * fuzzer = execution->getFuzzer(); - Predicate * selected_branch = fuzzer->get_selected_child_branch(tid); - func_node->set_predicate_tree_position(tid, selected_branch); } } @@ -569,6 +564,8 @@ void ModelHistory::print_func_node() for (uint32_t i = 1; i < func_nodes.size(); i++) { FuncNode * func_node = func_nodes[i]; + 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()); @@ -577,6 +574,7 @@ void ModelHistory::print_func_node() FuncInst *inst = it->getVal(); model_print("type: %d, at: %s\n", inst->get_type(), inst->get_position()); } + */ } } diff --git a/newfuzzer.cc b/newfuzzer.cc index 5675c790..e61cfb64 100644 --- a/newfuzzer.cc +++ b/newfuzzer.cc @@ -47,6 +47,7 @@ int NewFuzzer::selectWrite(ModelAction *read, SnapVector * rf_set if (read != thrd_last_read_act[thread_id]) { FuncNode * func_node = history->get_curr_func_node(tid); Predicate * curr_pred = func_node->get_predicate_tree_position(tid); + FuncInst * read_inst = func_node->get_inst(read); Predicate * selected_branch = selectBranch(tid, curr_pred, read_inst); @@ -146,6 +147,10 @@ Predicate * NewFuzzer::selectBranch(thread_id_t tid, Predicate * curr_pred, Func Predicate * random_branch = branches[ index ]; thrd_selected_child_branch[thread_id] = random_branch; + // Update predicate tree position + FuncNode * func_node = history->get_curr_func_node(tid); + func_node->set_predicate_tree_position(tid, random_branch); + return random_branch; } @@ -174,7 +179,7 @@ int NewFuzzer::choose_index(SnapVector * branches, uint32_t numerat SnapVector factors = SnapVector( branches->size() + 1 ); for (uint i = 0; i < branches->size(); i++) { Predicate * branch = (*branches)[i]; - double factor = (double) numerator / (branch->get_expl_count() + 2 * branch->get_fail_count() + 1); + double factor = (double) numerator / (branch->get_expl_count() + 5 * branch->get_fail_count() + 1); total_factor += factor; factors.push_back(factor); } @@ -348,7 +353,6 @@ void NewFuzzer::wake_up_paused_threads(int * threadlist, int * numthreads) history->remove_waiting_write(tid); history->remove_waiting_thread(tid); - //model_print("thread %d is woken up\n", tid); threadlist[*numthreads] = tid; (*numthreads)++; diff --git a/newfuzzer.h b/newfuzzer.h index a4699bdd..61925c13 100644 --- a/newfuzzer.h +++ b/newfuzzer.h @@ -10,7 +10,6 @@ class NewFuzzer : public Fuzzer { public: NewFuzzer(); int selectWrite(ModelAction *read, SnapVector* rf_set); - Predicate * get_selected_child_branch(thread_id_t tid); bool has_paused_threads(); void notify_paused_thread(Thread * thread); @@ -33,6 +32,7 @@ private: SnapVector thrd_selected_child_branch; SnapVector< SnapVector *> thrd_pruned_writes; + Predicate * get_selected_child_branch(thread_id_t tid); bool prune_writes(thread_id_t tid, Predicate * pred, SnapVector * rf_set, inst_act_map_t * inst_act_map); Predicate * selectBranch(thread_id_t tid, Predicate * curr_pred, FuncInst * read_inst); int choose_index(SnapVector * branches, uint32_t numerator); diff --git a/predicate.cc b/predicate.cc index 4094b615..09e4739b 100644 --- a/predicate.cc +++ b/predicate.cc @@ -138,7 +138,7 @@ void Predicate::print_predicate() if (does_write) { model_print("Does write\n"); } - model_print("Count: %d\n", exploration_count); + model_print("Count: %d, failed count: %d\n", exploration_count, failure_count); model_print("\"];\n"); }