Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : end of cleanup for stateful and stateless model checking
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Thu, 21 Jun 2012 12:03:02 +0000 (14:03 +0200)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Thu, 21 Jun 2012 12:03:02 +0000 (14:03 +0200)
src/mc/mc_dpor.c
src/mc/mc_global.c

index b03fd4bb84023695c963de94d46b462862541257..a15b0a3ce476eea98369484000e5dd4a4f4cc381 100644 (file)
@@ -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 {
index dd6761cee213ae29945c79b607bdcdd97b19a2c9..211f26bbd163b5f49334cceddb41d228cc39ea0b 100644 (file)
@@ -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)) {