model: add obj_thrd_map
authorBrian Norris <banorris@uci.edu>
Sat, 26 May 2012 02:17:51 +0000 (19:17 -0700)
committerBrian Norris <banorris@uci.edu>
Sat, 26 May 2012 03:39:00 +0000 (20:39 -0700)
Provides a mapping of ModelActions so that we can efficiently sort through the
actions on a particular object (memory location) in a particular thread.

model.cc
model.h

index 24c46b689272d22a61a3c82561dc68bbfa39a383..86d28ec0bfc4119b16f0c5c0eba62c34d05ea3d5 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -25,6 +25,7 @@ ModelChecker::ModelChecker()
        nextThread(THREAD_ID_T_NONE),
        action_trace(new action_list_t()),
        thread_map(new std::map<int, class Thread *>),
+       obj_thrd_map(new std::map<void *, std::vector<action_list_t> >()),
        node_stack(new NodeStack()),
        next_backtrack(NULL)
 {
@@ -37,8 +38,8 @@ ModelChecker::~ModelChecker()
                delete (*it).second;
        delete thread_map;
 
+       delete obj_thrd_map;
        delete action_trace;
-
        delete node_stack;
        delete scheduler;
 }
@@ -219,6 +220,11 @@ void ModelChecker::check_current_action(void)
 
        set_backtracking(curr);
        this->action_trace->push_back(curr);
+
+       std::vector<action_list_t> *vec = &(*obj_thrd_map)[curr->get_location()];
+       if (id_to_int(curr->get_tid()) >= (int)vec->size())
+               vec->resize(next_thread_id);
+       (*vec)[id_to_int(curr->get_tid())].push_back(curr);
 }
 
 void ModelChecker::print_summary(void)
diff --git a/model.h b/model.h
index 9c69ec4965ecf138c17422045a18c49b569f8796..a1ab45e7b6534238a74c27750dd66af0d3bb4999 100644 (file)
--- a/model.h
+++ b/model.h
@@ -65,6 +65,7 @@ private:
        ucontext_t *system_context;
        action_list_t *action_trace;
        std::map<int, class Thread *> *thread_map;
+       std::map<void *, std::vector<action_list_t> > *obj_thrd_map;
        class NodeStack *node_stack;
        ModelAction *next_backtrack;
 };