Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Enable record in liveness mode
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 2 Jun 2015 08:25:21 +0000 (10:25 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 2 Jun 2015 10:33:18 +0000 (12:33 +0200)
src/mc/mc_liveness.cpp
src/mc/mc_record.cpp

index 0a46c4a..123352e 100644 (file)
@@ -246,6 +246,7 @@ static void MC_modelcheck_liveness_main(void)
           XBT_INFO("|             ACCEPTANCE CYCLE            |");
           XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
           XBT_INFO("Counter-example that violates formula :");
           XBT_INFO("|             ACCEPTANCE CYCLE            |");
           XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
           XBT_INFO("Counter-example that violates formula :");
+          MC_record_dump_path(mc_stack);
           MC_show_stack_liveness(mc_stack);
           MC_dump_stack_liveness(mc_stack);
           MC_print_statistics(mc_stats);
           MC_show_stack_liveness(mc_stack);
           MC_dump_stack_liveness(mc_stack);
           MC_print_statistics(mc_stats);
index 6734597..72831b8 100644 (file)
@@ -17,6 +17,7 @@
 #include "mc_private.h"
 #include "mc_state.h"
 #include "mc_smx.h"
 #include "mc_private.h"
 #include "mc_state.h"
 #include "mc_smx.h"
+#include "mc_liveness.h"
 #endif
 
 extern "C" {
 #endif
 
 extern "C" {
@@ -89,8 +90,40 @@ fail:
 }
 
 #ifdef HAVE_MC
 }
 
 #ifdef HAVE_MC
+static char* MC_record_stack_to_string_liveness(xbt_fifo_t stack)
+{
+  char* buffer;
+  size_t size;
+  FILE* file = open_memstream(&buffer, &size);
+
+  xbt_fifo_item_t item;
+  xbt_fifo_item_t start = xbt_fifo_get_last_item(stack);
+  for (item = start; item; item = xbt_fifo_get_prev_item(item)) {
+    mc_pair_t pair = (mc_pair_t) xbt_fifo_get_item_content(item);
+    int value;
+    smx_simcall_t req = MC_state_get_executed_request(pair->graph_state, &value);
+    if (req && req->call != SIMCALL_NONE) {
+      smx_process_t issuer = MC_smx_simcall_get_issuer(req);
+      const int pid = issuer->pid;
+
+      // Serialization the (pid, value) pair:
+      const char* sep = (item!=start) ? ";" : "";
+      if (value)
+        fprintf(file, "%s%u/%u", sep, pid, value);
+      else
+        fprintf(file, "%s%u", sep, pid);
+    }
+  }
+
+  fclose(file);
+  return buffer;
+}
+
 char* MC_record_stack_to_string(xbt_fifo_t stack)
 {
 char* MC_record_stack_to_string(xbt_fifo_t stack)
 {
+  if (_sg_mc_liveness)
+    return MC_record_stack_to_string_liveness(stack);
+
   xbt_fifo_item_t start = xbt_fifo_get_last_item(stack);
 
   if (!start) {
   xbt_fifo_item_t start = xbt_fifo_get_last_item(stack);
 
   if (!start) {