/* Initialize a model-checker thread, for special ModelActions */
model_thread = new Thread(get_next_id());
add_thread(model_thread);
- fuzzer->register_engine(m->get_history(), this);
+ fuzzer->register_engine(this);
scheduler->register_engine(this);
#ifdef TLS
pthread_key_create(&pthreadkey, tlsdestructor);
read_from(curr, rf);
get_thread(curr)->set_return_value(curr->get_return_value());
delete priorset;
- return canprune && curr->get_type() == ATOMIC_READ;
+ return canprune && (curr->get_type() == ATOMIC_READ);
}
priorset->clear();
(*rf_set)[index] = rf_set->back();
void *mutex_loc = (void *) act->get_value();
get_safe_ptr_action(&obj_map, mutex_loc)->erase(listref);
}
- } else if (act->is_write()) {
+ } else if (act->is_free()) {
sllnode<ModelAction *> * listref = act->getActionRef();
if (listref != NULL) {
SnapVector<action_list_t> *vec = get_safe_ptr_vect_action(&obj_wr_thrd_map, act->get_location());
Fuzzer() {}
virtual int selectWrite(ModelAction *read, SnapVector<ModelAction *>* rf_set);
virtual bool has_paused_threads() { return false; }
- virtual void notify_paused_thread(Thread * thread) = 0;
virtual Thread * selectThread(int * threadlist, int numthreads);
Thread * selectNotify(action_list_t * waiters);
bool shouldSleep(const ModelAction *sleep);
bool shouldWake(const ModelAction *sleep);
- virtual bool shouldWait(const ModelAction *wait) = 0;
- virtual void register_engine(ModelHistory * history, ModelExecution * execution) = 0;
- virtual Predicate * get_selected_child_branch(thread_id_t tid) = 0;
+ virtual bool shouldWait(const ModelAction *wait);
+ virtual void register_engine(ModelExecution * execution) {}
SNAPSHOTALLOC
private:
};
func_node->update_inst_act_map(tid, act);
Fuzzer * fuzzer = model->get_execution()->getFuzzer();
- Predicate * selected_branch = fuzzer->get_selected_child_branch(tid);
+ Predicate * selected_branch = ((NewFuzzer *)fuzzer)->get_selected_child_branch(tid);
func_node->set_predicate_tree_position(tid, selected_branch);
}
Thread * thread = model->get_thread(tid);
//model_print("** thread %d is woken up\n", thread->get_id());
- model->get_execution()->getFuzzer()->notify_paused_thread(thread);
+ ((NewFuzzer *)model->get_execution()->getFuzzer())->notify_paused_thread(thread);
}
index++;
// model_print("\tthread %d waits for nobody, wake up\n", self_id);
ModelExecution * execution = model->get_execution();
Thread * thread = execution->get_thread(self_id);
- execution->getFuzzer()->notify_paused_thread(thread);
+ ((NewFuzzer *)execution->getFuzzer())->notify_paused_thread(thread);
}
}
}
// model_print("\tthread %d waits for nobody, wake up\n", self_id);
ModelExecution * execution = model->get_execution();
Thread * thread = execution->get_thread(waited_by_id);
- execution->getFuzzer()->notify_paused_thread(thread);
+ ((NewFuzzer *)execution->getFuzzer())->notify_paused_thread(thread);
}
}
}
/**
* @brief Register the ModelHistory and ModelExecution engine
*/
-void NewFuzzer::register_engine(ModelHistory * history, ModelExecution *execution)
+void NewFuzzer::register_engine(ModelExecution *execution)
{
- this->history = history;
+ this->history = model->get_history();
this->execution = execution;
}
//model_print("the %d read action of thread %d at %p is unsuccessful\n", read->get_seq_number(), read_thread->get_id(), read->get_location());
SnapVector<ModelAction *> * pruned_writes = thrd_pruned_writes[thread_id];
- for (uint i = 0; i < pruned_writes->size(); i++) {
+ for (uint i = 0;i < pruned_writes->size();i++) {
rf_set->push_back( (*pruned_writes)[i] );
}
* @return False if no child matches read_inst
*/
bool NewFuzzer::check_branch_inst(Predicate * curr_pred, FuncInst * read_inst,
-inst_act_map_t * inst_act_map, SnapVector<ModelAction *> * rf_set)
+ inst_act_map_t * inst_act_map, SnapVector<ModelAction *> * rf_set)
{
available_branches_tmp_storage.clear();
double total_weight = 0;
SnapVector<double> weights;
- for (uint i = 0; i < branches->size(); i++) {
+ for (uint i = 0;i < branches->size();i++) {
Predicate * branch = (*branches)[i];
double weight = branch->get_weight();
total_weight += weight;
double prob_sum = 0;
int index = 0;
- for (uint i = 0; i < weights.size(); i++) {
+ for (uint i = 0;i < weights.size();i++) {
index = i;
prob_sum += (double) (weights[i] / total_weight);
if (prob_sum > prob) {
* @return true if rf_set is pruned
*/
bool NewFuzzer::prune_writes(thread_id_t tid, Predicate * pred,
-SnapVector<ModelAction *> * rf_set, inst_act_map_t * inst_act_map)
+ SnapVector<ModelAction *> * rf_set, inst_act_map_t * inst_act_map)
{
if (pred == NULL)
return false;
}
bool NewFuzzer::check_predicate_expressions(PredExprSet * pred_expressions,
-inst_act_map_t * inst_act_map, uint64_t write_val, bool * no_predicate)
+ inst_act_map_t * inst_act_map, uint64_t write_val, bool * no_predicate)
{
bool satisfy_predicate = true;
bool equality;
switch (expression->token) {
- case NOPREDICATE:
- *no_predicate = true;
- break;
- case EQUALITY:
- FuncInst * to_be_compared;
- ModelAction * last_act;
- uint64_t last_read;
-
- to_be_compared = expression->func_inst;
- last_act = inst_act_map->get(to_be_compared);
- last_read = last_act->get_reads_from_value();
-
- equality = (write_val == last_read);
- if (equality != expression->value)
- satisfy_predicate = false;
- break;
- case NULLITY:
- // TODO: implement likely to be null
- equality = ((void*) (write_val & 0xffffffff) == NULL);
- if (equality != expression->value)
- satisfy_predicate = false;
- break;
- default:
- model_print("unknown predicate token\n");
- break;
+ case NOPREDICATE:
+ *no_predicate = true;
+ break;
+ case EQUALITY:
+ FuncInst * to_be_compared;
+ ModelAction * last_act;
+ uint64_t last_read;
+
+ to_be_compared = expression->func_inst;
+ last_act = inst_act_map->get(to_be_compared);
+ last_read = last_act->get_reads_from_value();
+
+ equality = (write_val == last_read);
+ if (equality != expression->value)
+ satisfy_predicate = false;
+ break;
+ case NULLITY:
+ // TODO: implement likely to be null
+ equality = ((void*) (write_val & 0xffffffff) == NULL);
+ if (equality != expression->value)
+ satisfy_predicate = false;
+ break;
+ default:
+ model_print("unknown predicate token\n");
+ break;
}
if (!satisfy_predicate)