#ifndef CLASSLIST_H
#define CLASSLIST_H
+#include <inttypes.h>
#include "stl-model.h"
class ClockVector;
struct model_snapshot_members;
struct bug_message;
typedef SnapList<ModelAction *> action_list_t;
+typedef SnapList<uint32_t> func_id_list_t;
#endif
HashTable<pthread_cond_t *, cdsc::condition_variable *, uintptr_t, 4> * getCondMap() {return &cond_map;}
HashTable<pthread_mutex_t *, cdsc::mutex *, uintptr_t, 4> * getMutexMap() {return &mutex_map;}
+ SnapVector<func_id_list_t *> * get_thrd_func_list() { return &thrd_func_list; }
+
SNAPSHOTALLOC
private:
int get_execution_number() const;
Fuzzer * fuzzer;
Thread * action_select_next_thread(const ModelAction *curr) const;
+
+ /* thrd_func_list stores a list of function ids for each thread.
+ * Each element in thrd_func_list stores the functions that
+ * thread i has entered and yet to exit from */
+ SnapVector< func_id_list_t * > thrd_func_list;
+
};
#endif /* __EXECUTION_H__ */
void add_action(ModelAction *act);
- HashTable<const char *, FuncInst *, uintptr_t, 4> * getFuncInsts() { return &func_insts; }
+ HashTable<const char *, FuncInst *, uintptr_t, 4, model_malloc, model_calloc, model_free> * getFuncInsts() { return &func_insts; }
func_inst_list_t * get_inst_list() { return &inst_list; }
MEMALLOC
* To do: cds_atomic_compare_exchange contains three atomic operations
* that are feeded with the same source line number by llvm pass
*/
- HashTable<const char *, FuncInst *, uintptr_t, 4> func_insts;
+ HashTable<const char *, FuncInst *, uintptr_t, 4, model_malloc, model_calloc, model_free> func_insts;
func_inst_list_t inst_list;
};
#include "action.h"
#include "funcnode.h"
+#include "model.h"
+#include "execution.h"
+
/** @brief Constructor */
ModelHistory::ModelHistory() :
func_counter(0), /* function id starts with 0 */
func_map(),
- func_atomics(),
- work_list(2) /* we have at least two threads */
+ func_atomics()
{}
void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
{
uint32_t id = id_to_int(tid);
- if ( work_list.size() <= id )
- work_list.resize( id + 1 );
+ SnapVector<func_id_list_t *> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+
+ if ( thrd_func_list->size() <= id )
+ thrd_func_list->resize( id + 1 );
- func_id_list_t * func_list = work_list[id];
+ func_id_list_t * func_list = thrd_func_list->at(id);
if (func_list == NULL) {
func_list = new func_id_list_t();
- work_list[id] = func_list;
+ thrd_func_list->at(id) = func_list;
}
func_list->push_back(func_id);
void ModelHistory::exit_function(const uint32_t func_id, thread_id_t tid)
{
- func_id_list_t * func_list = work_list[ id_to_int(tid) ];
+ SnapVector<func_id_list_t *> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+
+ func_id_list_t * func_list = thrd_func_list->at( id_to_int(tid) );
uint32_t last_func_id = func_list->back();
if (last_func_id == func_id) {
}
}
-void ModelHistory::add_func_atomic(ModelAction *act, thread_id_t tid) {
+void ModelHistory::add_func_atomic(ModelAction *act, thread_id_t tid)
+{
/* return if thread i has not entered any function or has exited
from all functions */
+ SnapVector<func_id_list_t *> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+
uint32_t id = id_to_int(tid);
- if ( work_list.size() <= id )
+ if ( thrd_func_list->size() <= id )
return;
- else if (work_list[id] == NULL)
+ else if (thrd_func_list->at(id) == NULL)
return;
/* get the function id that thread i is currently in */
- func_id_list_t * func_list = work_list[id];
+ func_id_list_t * func_list = thrd_func_list->at(id);
uint32_t func_id = func_list->back();
if ( func_atomics.size() <= func_id )
func_node->add_action(act);
}
-void ModelHistory::print() {
+void ModelHistory::print()
+{
for (uint32_t i = 0; i < func_atomics.size(); i++ ) {
FuncNode * funcNode = func_atomics[i];
func_inst_list_t * inst_list = funcNode->get_inst_list();
#include "hashtable.h"
#include "threads-model.h"
-typedef SnapList<uint32_t> func_id_list_t;
-
class ModelHistory {
public:
ModelHistory();
void add_func_atomic(ModelAction *act, thread_id_t tid);
- HashTable<const char *, uint32_t, uintptr_t, 4> * getFuncMap() { return &func_map; }
+ HashTable<const char *, uint32_t, uintptr_t, 4, model_malloc, model_calloc, model_free> * getFuncMap() { return &func_map; }
ModelVector<FuncNode *> * getFuncAtomics() { return &func_atomics; }
void print();
uint32_t func_counter;
/* map function names to integer ids */
- HashTable<const char *, uint32_t, uintptr_t, 4> func_map;
+ HashTable<const char *, uint32_t, uintptr_t, 4, model_malloc, model_calloc, model_free> func_map;
ModelVector<FuncNode *> func_atomics;
-
- /* Work_list stores a list of function ids for each thread.
- * Each element in work_list is intended to be used as a stack storing
- * the functions that thread i has entered and yet to exit from
- */
-
- /* todo: move work_list to execution.cc to avoid seg fault */
- SnapVector< func_id_list_t * > work_list;
};