From: Brian Norris Date: Sat, 26 May 2012 00:53:56 +0000 (-0700) Subject: model: make thread_map heap allocated X-Git-Tag: pldi2013~392^2~34 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=728a295c57047984407babb1aa0184cd2fb022b1;p=model-checker.git model: make thread_map heap allocated I want to snapshot this structure, so make it heap-allocated. --- diff --git a/model.cc b/model.cc index 62be087..09ee4b4 100644 --- a/model.cc +++ b/model.cc @@ -24,6 +24,7 @@ ModelChecker::ModelChecker() diverge(NULL), nextThread(THREAD_ID_T_NONE), action_trace(new action_list_t()), + thread_map(new std::map), node_stack(new NodeStack()), next_backtrack(NULL) { @@ -32,9 +33,9 @@ ModelChecker::ModelChecker() ModelChecker::~ModelChecker() { std::map::iterator it; - for (it = thread_map.begin(); it != thread_map.end(); it++) + for (it = thread_map->begin(); it != thread_map->end(); it++) delete (*it).second; - thread_map.clear(); + delete thread_map; delete action_trace; @@ -46,9 +47,9 @@ void ModelChecker::reset_to_initial_state() { DEBUG("+++ Resetting to initial state +++\n"); std::map::iterator it; - for (it = thread_map.begin(); it != thread_map.end(); it++) + for (it = thread_map->begin(); it != thread_map->end(); it++) delete (*it).second; - thread_map.clear(); + thread_map->clear(); delete action_trace; action_trace = new action_list_t(); node_stack->reset_execution(); @@ -75,7 +76,7 @@ Thread * ModelChecker::schedule_next_thread() Thread *t; if (nextThread == THREAD_ID_T_NONE) return NULL; - t = thread_map[id_to_int(nextThread)]; + t = (*thread_map)[id_to_int(nextThread)]; ASSERT(t != NULL); @@ -248,7 +249,7 @@ void ModelChecker::print_list(action_list_t *list) int ModelChecker::add_thread(Thread *t) { - thread_map[id_to_int(t->get_id())] = t; + (*thread_map)[id_to_int(t->get_id())] = t; scheduler->add_thread(t); return 0; } diff --git a/model.h b/model.h index 9d2fd5a..57959b7 100644 --- a/model.h +++ b/model.h @@ -34,7 +34,7 @@ public: int add_thread(Thread *t); void remove_thread(Thread *t); - Thread * get_thread(thread_id_t tid) { return thread_map[id_to_int(tid)]; } + Thread * get_thread(thread_id_t tid) { return (*thread_map)[id_to_int(tid)]; } thread_id_t get_next_id(); int get_next_seq_num(); @@ -63,7 +63,7 @@ private: ucontext_t *system_context; action_list_t *action_trace; - std::map thread_map; + std::map *thread_map; class NodeStack *node_stack; ModelAction *next_backtrack; };