Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Communication of heap_area_to_ignore to the remote MCer
[simgrid.git] / src / simix / smx_global.c
index cbf502f..d568b5a 100644 (file)
@@ -4,6 +4,8 @@
 /* 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 <stdlib.h>
+
 #include "smx_private.h"
 #include "xbt/heap.h"
 #include "xbt/sysdep.h"
 
 #ifdef HAVE_MC
 #include "mc/mc_private.h"
+#include "mc/mc_model_checker.h"
+#include "mc/mc_protocol.h"
+#include "mc/mc_client.h"
 #endif
+#include "mc/mc_record.h"
 
 #ifdef HAVE_SMPI
 #include "smpi/private.h"
@@ -205,6 +211,20 @@ void SIMIX_global_init(int *argc, char **argv)
   if (sg_cfg_get_boolean("clean_atexit"))
     atexit(SIMIX_clean);
 
+#ifdef HAVE_MC
+  // The communication initialisation is done ASAP.
+  // We need to commuicate  initialisation of the different layers to the model-checker.
+  if (mc_mode == MC_MODE_NONE) {
+    if (getenv(MC_ENV_SOCKET_FD)) {
+      mc_mode = MC_MODE_CLIENT;
+      MC_client_init();
+      MC_client_hello();
+    } else {
+      mc_mode = MC_MODE_STANDALONE;
+    }
+  }
+#endif
+
   if (_sg_cfg_exit_asap)
     exit(0);
 }
@@ -280,7 +300,7 @@ void SIMIX_clean(void)
  */
 XBT_INLINE double SIMIX_get_clock(void)
 {
-  if(MC_is_active()){
+  if(MC_is_active() || MC_record_replay_is_active()){
     return MC_process_clock_get(SIMIX_process_self());
   }else{
     return surf_get_clock();
@@ -306,6 +326,12 @@ static int process_syscall_color(void *p)
  */
 void SIMIX_run(void)
 {
+  if(MC_record_path) {
+    MC_record_replay_init();
+    MC_record_replay_from_string(MC_record_path);
+    return;
+  }
+
   double time = 0;
   smx_process_t process;
   surf_action_t action;
@@ -607,4 +633,3 @@ xbt_dict_t SIMIX_asr_get_properties(const char *name)
 {
   return xbt_lib_get_or_null(as_router_lib, name, ROUTING_PROP_ASR_LEVEL);
 }
-