Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
(wip) Move the MCed public API in the same file
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 6 Feb 2015 13:58:15 +0000 (14:58 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 6 Feb 2015 13:58:15 +0000 (14:58 +0100)
buildtools/Cmake/DefinePackages.cmake
include/simgrid/modelchecker.h
src/mc/mc_checkpoint.c
src/mc/mc_client.c
src/mc/mc_client_api.c [new file with mode: 0644]
src/mc/mc_compare.cpp
src/mc/mc_global.c

index 64e279f..76cc745 100644 (file)
@@ -643,6 +643,7 @@ set(MC_SRC
   src/mc/mc_memory_map.h
   src/mc/memory_map.c
   src/mc/mc_client.c
+  src/mc/mc_client_api.c
   src/mc/mc_client.h
   src/mc/mc_protocol.h
   src/mc/mc_protocol.c
index 0d41344..b2ce355 100644 (file)
 
 SG_BEGIN_DECL()
 
+/** Replay path (if any) in string representation
+ *
+ *  This is a path as generated by `MC_record_stack_to_string()`.
+ */
+XBT_PUBLIC_DATA(char*) MC_record_path;
+
+/** Whether the replay mode is enabled */
+static inline bool MC_record_replay_is_active(void) {
+  return MC_record_path;
+}
+
 XBT_PUBLIC(int) MC_random(int min, int max);
 
 #ifdef HAVE_MC
@@ -48,17 +59,6 @@ XBT_PUBLIC(void) MC_ignore(void *addr, size_t size);
 
 #endif
 
-/** Replay path (if any) in string representation
- *
- *  This is a path as generated by `MC_record_stack_to_string()`.
- */
-XBT_PUBLIC_DATA(char*) MC_record_path;
-
-/** Whether the replay mode is enabled */
-static inline bool MC_record_replay_is_active(void) {
-  return MC_record_path;
-}
-
 SG_END_DECL()
 
 #endif /* SIMGRID_MODELCHECKER_H */
index fe602a4..82e88c3 100644 (file)
@@ -844,8 +844,3 @@ mc_snapshot_t simcall_HANDLER_mc_snapshot(smx_simcall_t simcall)
 {
   return MC_take_snapshot(1);
 }
-
-void *MC_snapshot(void)
-{
-  return simcall_mc_snapshot();
-}
index c903246..6a8d4ee 100644 (file)
@@ -92,21 +92,3 @@ void MC_client_handle_messages(void)
     }
   }
 }
-
-void MC_ignore(void* addr, size_t size)
-{
-  if (mc_mode == MC_MODE_CLIENT) {
-    s_mc_ignore_memory_message_t message;
-    message.type = MC_MESSAGE_IGNORE_MEMORY;
-    message.addr = addr;
-    message.size = size;
-    MC_client_send_message(&message, sizeof(message));
-  }
-
-  // TODO, remove this once the migration has been completed
-  int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
-  MC_SET_MC_HEAP;
-  MC_process_ignore_memory(&mc_model_checker->process, addr, size);
-  if (!raw_mem_set)
-    MC_SET_STD_HEAP;
-}
diff --git a/src/mc/mc_client_api.c b/src/mc/mc_client_api.c
new file mode 100644 (file)
index 0000000..9c7b2e7
--- /dev/null
@@ -0,0 +1,76 @@
+/* Copyright (c) 2008-2015. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <xbt/log.h>
+#include <xbt/fifo.h>
+#include <xbt/sysdep.h>
+#include <simgrid/modelchecker.h>
+
+#include "mc_record.h"
+#include "mc_private.h"
+#include "mc_mmalloc.h"
+#include "mc_model_checker.h"
+#include "mc_ignore.h"
+#include "mc_protocol.h"
+#include "mc_client.h"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client_api, mc,
+  "Public API for the model-checked application");
+
+void MC_assert(int prop)
+{
+  if (MC_is_active() && !prop) {
+    XBT_INFO("**************************");
+    XBT_INFO("*** PROPERTY NOT VALID ***");
+    XBT_INFO("**************************");
+    XBT_INFO("Counter-example execution trace:");
+    MC_record_dump_path(mc_stack);
+    MC_dump_stack_safety(mc_stack);
+    MC_print_statistics(mc_stats);
+    xbt_abort();
+  }
+}
+
+// TODO, MC_automaton_new_propositional_symbol
+
+void *MC_snapshot(void)
+{
+  return simcall_mc_snapshot();
+}
+
+int simcall_HANDLER_mc_compare_snapshots(smx_simcall_t simcall,
+                                   mc_snapshot_t s1, mc_snapshot_t s2)
+{
+  return snapshot_compare(s1, s2);
+}
+
+int MC_compare_snapshots(void *s1, void *s2)
+{
+  return simcall_mc_compare_snapshots(s1, s2);
+}
+
+void MC_cut(void)
+{
+  user_max_depth_reached = 1;
+}
+
+void MC_ignore(void* addr, size_t size)
+{
+  if (mc_mode == MC_MODE_CLIENT) {
+    s_mc_ignore_memory_message_t message;
+    message.type = MC_MESSAGE_IGNORE_MEMORY;
+    message.addr = addr;
+    message.size = size;
+    MC_client_send_message(&message, sizeof(message));
+  }
+
+  // TODO, remove this once the migration has been completed
+  int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
+  MC_SET_MC_HEAP;
+  MC_process_ignore_memory(&mc_model_checker->process, addr, size);
+  if (!raw_mem_set)
+    MC_SET_STD_HEAP;
+}
index 55db660..5b6352a 100644 (file)
@@ -713,20 +713,4 @@ void print_comparison_times()
   XBT_DEBUG("- Stacks : %f", mc_comp_times->stacks_comparison_time);
 }
 
-/**************************** MC snapshot compare simcall **************************/
-/***********************************************************************************/
-
-int simcall_HANDLER_mc_compare_snapshots(smx_simcall_t simcall,
-                                   mc_snapshot_t s1, mc_snapshot_t s2)
-{
-  return snapshot_compare(s1, s2);
-}
-
-int MC_compare_snapshots(void *s1, void *s2)
-{
-
-  return simcall_mc_compare_snapshots(s1, s2);
-
-}
-
 }
index 22b7535..178fee1 100644 (file)
@@ -730,25 +730,6 @@ void MC_print_statistics(mc_stats_t stats)
   mmalloc_set_current_heap(previous_heap);
 }
 
-void MC_assert(int prop)
-{
-  if (MC_is_active() && !prop) {
-    XBT_INFO("**************************");
-    XBT_INFO("*** PROPERTY NOT VALID ***");
-    XBT_INFO("**************************");
-    XBT_INFO("Counter-example execution trace:");
-    MC_record_dump_path(mc_stack);
-    MC_dump_stack_safety(mc_stack);
-    MC_print_statistics(mc_stats);
-    xbt_abort();
-  }
-}
-
-void MC_cut(void)
-{
-  user_max_depth_reached = 1;
-}
-
 void MC_automaton_load(const char *file)
 {