From f74d34bb1e9ca987d4f0616eb1429bb74f1bff33 Mon Sep 17 00:00:00 2001 From: Marion Guthmuller Date: Thu, 21 Jun 2012 14:03:02 +0200 Subject: [PATCH] model-checker : end of cleanup for stateful and stateless model checking --- src/mc/mc_dpor.c | 6 +++--- src/mc/mc_global.c | 30 ++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/mc/mc_dpor.c b/src/mc/mc_dpor.c index b03fd4bb84..a15b0a3ce4 100644 --- a/src/mc/mc_dpor.c +++ b/src/mc/mc_dpor.c @@ -182,13 +182,13 @@ void MC_dpor(void) MC_UNSET_RAW_MEM; }else{ pos = xbt_fifo_size(mc_stack_safety); - item = xbt_fifo_get_last_item(mc_stack_safety); + item = xbt_fifo_get_first_item(mc_stack_safety); while(pos>0){ restore_state = (mc_state_t) xbt_fifo_get_item_content(item); if(restore_state->system_state != NULL){ break; }else{ - item = xbt_fifo_get_prev_item(item); + item = xbt_fifo_get_next_item(item); pos--; } } @@ -202,7 +202,7 @@ void MC_dpor(void) xbt_fifo_unshift(mc_stack_safety, state); XBT_DEBUG("Back-tracking to depth %d", xbt_fifo_size(mc_stack_safety)); MC_UNSET_RAW_MEM; - MC_replay(mc_stack_safety, 1); + MC_replay(mc_stack_safety, -1); } break; } else { diff --git a/src/mc/mc_global.c b/src/mc/mc_global.c index dd6761cee2..211f26bbd1 100644 --- a/src/mc/mc_global.c +++ b/src/mc/mc_global.c @@ -181,29 +181,39 @@ int MC_deadlock_check() } /** - * \brief Re-executes from the start state all the transitions indicated by + * \brief Re-executes from the state at position start all the transitions indicated by * a given model-checker stack. * \param stack The stack with the transitions to execute. * \param start Start index to begin the re-execution. */ void MC_replay(xbt_fifo_t stack, int start) { - int value; + int value, i = 1; char *req_str; smx_simcall_t req = NULL, saved_req = NULL; - xbt_fifo_item_t item; + xbt_fifo_item_t item, start_item; mc_state_t state; XBT_DEBUG("**** Begin Replay ****"); - /* Restore the initial state */ - MC_restore_snapshot(initial_snapshot); - /* At the moment of taking the snapshot the raw heap was set, so restoring - * it will set it back again, we have to unset it to continue */ - MC_UNSET_RAW_MEM; + if(start == -1){ + /* Restore the initial state */ + MC_restore_snapshot(initial_snapshot); + /* At the moment of taking the snapshot the raw heap was set, so restoring + * it will set it back again, we have to unset it to continue */ + MC_UNSET_RAW_MEM; + } - /* Traverse the stack from the initial state and re-execute the transitions */ - for (item = xbt_fifo_get_last_item(stack); + start_item = xbt_fifo_get_last_item(stack); + if(start != -1){ + while (i != start){ + start_item = xbt_fifo_get_prev_item(start_item); + i++; + } + } + + /* Traverse the stack from the state at position start and re-execute the transitions */ + for (item = start_item; item != xbt_fifo_get_first_item(stack); item = xbt_fifo_get_prev_item(item)) { -- 2.20.1