9 /* Check whether FuncInst with the same type, position, and location
10 * as act has been added to func_inst_map or not. If so, return it;
11 * if not, add it and return it.
13 * @return FuncInst with the same type, position, and location as act */
14 FuncInst * FuncNode::get_or_add_action(ModelAction *act)
17 const char * position = act->get_position();
19 /* Actions THREAD_CREATE, THREAD_START, THREAD_YIELD, THREAD_JOIN,
20 * THREAD_FINISH, PTHREAD_CREATE, PTHREAD_JOIN,
21 * ATOMIC_LOCK, ATOMIC_TRYLOCK, and ATOMIC_UNLOCK are not tagged with their
27 if ( func_inst_map.contains(position) ) {
28 FuncInst * inst = func_inst_map.get(position);
30 if (inst->get_type() != act->get_type() ) {
31 // model_print("action with a different type occurs at line number %s\n", position);
32 FuncInst * func_inst = inst->search_in_collision(act);
34 if (func_inst != NULL) {
35 // return the FuncInst found in the collision list
39 func_inst = new FuncInst(act, this);
40 inst->get_collisions()->push_back(func_inst);
41 inst_list.push_back(func_inst); // delete?
49 FuncInst * func_inst = new FuncInst(act, this);
51 func_inst_map.put(position, func_inst);
52 inst_list.push_back(func_inst);
57 void FuncNode::add_entry_inst(FuncInst * inst)
62 func_inst_list_mt::iterator it;
63 for (it = entry_insts.begin(); it != entry_insts.end(); it++) {
68 entry_insts.push_back(inst);
71 /* Store the values read by atomic read actions into loc_thrd_read_map */
72 void FuncNode::store_read(ModelAction * act, uint32_t tid)
76 void * location = act->get_location();
77 uint64_t read_from_val = act->get_reads_from_value();
79 ModelVector<uint64_t> * read_vals = loc_thrd_read_map.get(location);
80 if (read_vals == NULL) {
81 read_vals = new ModelVector<uint64_t>();
82 loc_thrd_read_map.put(location, read_vals);
85 if (read_vals->size() <= tid) {
86 read_vals->resize(tid + 1);
88 read_vals->at(tid) = read_from_val;
90 /* Store keys of loc_thrd_read_map into read_locations */
92 ModelList<void *>::iterator it;
93 for (it = read_locations.begin(); it != read_locations.end(); it++) {
94 if (location == *it) {
101 read_locations.push_back(location);
104 /* @param tid thread id
105 * Print the values read by the last read actions per memory location
107 void FuncNode::print_last_read(uint32_t tid)
109 ModelList<void *>::iterator it;
110 for (it = read_locations.begin(); it != read_locations.end(); it++) {
111 ModelVector<uint64_t> * read_vals = loc_thrd_read_map.get(*it);
112 if (read_vals->size() <= tid)
115 int64_t read_val = read_vals->at(tid);
116 model_print("last read of thread %d at %p: 0x%x\n", tid, *it, read_val);