Little adjustment
authorweiyu <weiyuluo1232@gmail.com>
Tue, 15 Oct 2019 00:48:50 +0000 (17:48 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Tue, 15 Oct 2019 00:48:50 +0000 (17:48 -0700)
fuzzer.h
history.cc
newfuzzer.cc
newfuzzer.h
predicate.cc

index 0d5734d0f193d517209cd34ae46d9ff1454d3a68..c5248d726310b8bab5db32b80e0fccc2bbd0556a 100644 (file)
--- a/fuzzer.h
+++ b/fuzzer.h
@@ -9,7 +9,6 @@ class Fuzzer {
 public:
        Fuzzer() {}
        virtual int selectWrite(ModelAction *read, SnapVector<ModelAction *>* 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);
index 34ec08011bfa3d60008c158e95a6f69158d3cedc..afd1f1d1752d9d4a0fde35ccef3d91c99ae572f2 100644 (file)
@@ -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());
                }
+               */
        }
 }
 
index 5675c7907152d53169ed83981405f1f2dc2a6e4c..e61cfb647b8bd3122b822d4f8fe69a48400b821a 100644 (file)
@@ -47,6 +47,7 @@ int NewFuzzer::selectWrite(ModelAction *read, SnapVector<ModelAction *> * 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<Predicate *> * branches, uint32_t numerat
        SnapVector<double> factors = SnapVector<double>( 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)++;
 
index a4699bdd5d394897fc7f7e286ad553111a07bf77..61925c1379935816064dea4d568e9b24c1f15f48 100644 (file)
@@ -10,7 +10,6 @@ class NewFuzzer : public Fuzzer {
 public:
        NewFuzzer();
        int selectWrite(ModelAction *read, SnapVector<ModelAction *>* 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<Predicate *> thrd_selected_child_branch;
        SnapVector< SnapVector<ModelAction *> *> thrd_pruned_writes;
 
+       Predicate * get_selected_child_branch(thread_id_t tid);
        bool prune_writes(thread_id_t tid, Predicate * pred, SnapVector<ModelAction *> * 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<Predicate *> * branches, uint32_t numerator);
index 4094b615514b48deee3caa34c98c73f6ebba4902..09e4739b0882aadc5f7cd5aa9d2aa01383fbeee2 100644 (file)
@@ -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");
 }