Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Better documentation of AddressSpace
[simgrid.git] / src / mc / mc_client_api.cpp
index cb8a785..0e4fcf0 100644 (file)
@@ -15,7 +15,7 @@
 #include "src/mc/Client.hpp"
 #include "src/mc/ModelChecker.hpp"
 
-/** \file mc_client_api.cpp
+/** @file mc_client_api.cpp
  *
  *  This is the implementation of the API used by the user simulated program to
  *  communicate with the MC (declared in modelchecker.h).
@@ -28,40 +28,41 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client_api, mc,
 
 void MC_assert(int prop)
 {
+  xbt_assert(mc_model_checker == nullptr);
   if (MC_is_active() && !prop)
     simgrid::mc::Client::get()->reportAssertionFailure();
 }
 
 void MC_cut(void)
 {
+  xbt_assert(mc_model_checker == nullptr);
+  if (!MC_is_active())
+    return;
   // FIXME, We want to do this in the model-checker:
-  // user_max_depth_reached = 1;
   xbt_die("MC_cut() not implemented");
 }
 
 void MC_ignore(void* addr, size_t size)
 {
-  xbt_assert(mc_mode != MC_MODE_SERVER);
-  if (mc_mode != MC_MODE_CLIENT)
+  xbt_assert(mc_model_checker == nullptr);
+  if (!MC_is_active())
     return;
   simgrid::mc::Client::get()->ignoreMemory(addr, size);
 }
 
 void MC_automaton_new_propositional_symbol(const char *id, int(*fct)(void))
 {
-  xbt_assert(mc_mode != MC_MODE_SERVER);
-  if (mc_mode != MC_MODE_CLIENT)
+  xbt_assert(mc_model_checker == nullptr);
+  if (!MC_is_active())
     return;
-
   xbt_die("Support for client-side function proposition is not implemented: "
-    "use MC_automaton_new_propositional_symbol_pointer instead."
-  );
+    "use MC_automaton_new_propositional_symbol_pointer instead.");
 }
 
 void MC_automaton_new_propositional_symbol_pointer(const char *name, int* value)
 {
-  xbt_assert(mc_mode != MC_MODE_SERVER);
-  if (mc_mode != MC_MODE_CLIENT)
+  xbt_assert(mc_model_checker == nullptr);
+  if (!MC_is_active())
     return;
   simgrid::mc::Client::get()->declareSymbol(name, value);
 }
@@ -69,7 +70,7 @@ void MC_automaton_new_propositional_symbol_pointer(const char *name, int* value)
 /** @brief Register a stack in the model checker
  *
  *  The stacks are allocated in the heap. The MC handle them especially
- *  when we analyse/compare the content of the heap so it must be told where
+ *  when we analyze/compare the content of the heap so it must be told where
  *  they are with this function.
  *
  *  @param stack
@@ -79,27 +80,33 @@ void MC_automaton_new_propositional_symbol_pointer(const char *name, int* value)
  */
 void MC_register_stack_area(void *stack, smx_process_t process, ucontext_t* context, size_t size)
 {
-  if (mc_mode != MC_MODE_CLIENT)
+  xbt_assert(mc_model_checker == nullptr);
+  if (!MC_is_active())
     return;
   simgrid::mc::Client::get()->declareStack(stack, size, process, context);
 }
 
 void MC_ignore_global_variable(const char *name)
 {
+  xbt_assert(mc_model_checker == nullptr);
+  if (!MC_is_active())
+    return;
   // TODO, send a message to the model_checker
   xbt_die("Unimplemented");
 }
 
 void MC_ignore_heap(void *address, size_t size)
 {
-  if (mc_mode != MC_MODE_CLIENT)
+  xbt_assert(mc_model_checker == nullptr);
+  if (!MC_is_active())
     return;
   simgrid::mc::Client::get()->ignoreHeap(address, size);
 }
 
 void MC_remove_ignore_heap(void *address, size_t size)
 {
-  if (mc_mode != MC_MODE_CLIENT)
+  xbt_assert(mc_model_checker == nullptr);
+  if (!MC_is_active())
     return;
   simgrid::mc::Client::get()->unignoreHeap(address, size);
 }