Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use assignment to non-trivial class rather than artificial trivialization and memset
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 17 Aug 2019 14:57:04 +0000 (16:57 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 17 Aug 2019 15:28:29 +0000 (17:28 +0200)
plus some other small cleanups

src/mc/mc_config.cpp
src/mc/mc_record.cpp
src/mc/mc_state.cpp
src/simix/popping_private.hpp
teshsuite/mc/random-bug/random-bug.cpp

index 8f60917..9353d3e 100644 (file)
@@ -20,10 +20,6 @@ simgrid::mc::ReductionMode reduction_mode = simgrid::mc::ReductionMode::unset;
 }
 #endif
 
-#if !SIMGRID_HAVE_MC
-#define _sg_do_model_check 0
-#endif
-
 static void _mc_cfg_cb_check(const char* spec, bool more_check = true)
 {
   if (_sg_cfg_init_status && not _sg_do_model_check && more_check)
index 4ea2c95..4c7f441 100644 (file)
@@ -35,7 +35,7 @@ void replay(RecordTrace const& trace)
     if (not process)
       xbt_die("Unexpected process (pid:%d).", transition.pid_);
     smx_simcall_t simcall = &(process->simcall);
-    if (not simcall || simcall->call_ == SIMCALL_NONE)
+    if (simcall == nullptr || simcall->call_ == SIMCALL_NONE)
       xbt_die("No simcall for process %d.", transition.pid_);
     if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(process))
       xbt_die("Unexpected simcall.");
index 8825430..0106b84 100644 (file)
@@ -21,8 +21,8 @@ namespace mc {
 State::State(unsigned long state_number) : num_(state_number)
 {
   this->internal_comm.clear();
-  std::memset(&this->internal_req, 0, sizeof(this->internal_req));
-  std::memset(&this->executed_req_, 0, sizeof(this->executed_req_));
+  this->internal_req  = s_smx_simcall();
+  this->executed_req_ = s_smx_simcall();
 
   actor_states_.resize(MC_smx_get_maxpid());
   /* Stateful model checking */
index fdd0b56..fce643c 100644 (file)
@@ -43,13 +43,13 @@ union u_smx_scalar {
  * @brief Represents a simcall to the kernel.
  */
 struct s_smx_simcall {
-  e_smx_simcall_t call_;
-  smx_actor_t issuer_;
-  smx_timer_t timeout_cb_; // Callback to timeouts
-  simgrid::mc::SimcallInspector* inspector_; // makes that simcall observable by the MC
-  int mc_value_;
-  u_smx_scalar args_[11];
-  u_smx_scalar result_;
+  e_smx_simcall_t call_                     = SIMCALL_NONE;
+  smx_actor_t issuer_                       = nullptr;
+  smx_timer_t timeout_cb_                   = nullptr; // Callback to timeouts
+  simgrid::mc::SimcallInspector* inspector_ = nullptr; // makes that simcall observable by the MC
+  int mc_value_                             = 0;
+  u_smx_scalar args_[11]                    = {{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
+  u_smx_scalar result_                      = {0};
 };
 
 #define SIMCALL_SET_MC_VALUE(simcall, value) ((simcall).mc_value_ = (value))
index 6f8463d..03bc2ae 100644 (file)
@@ -12,7 +12,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(random_bug, "For this example");
 
 enum { ABORT, ASSERT, PRINTF } behavior;
 
-/** An (fake) application with a bug occuring for some random values */
+/** A fake application with a bug occuring for some random values */
 static void app()
 {
   int x = MC_random(0, 5);
@@ -42,6 +42,9 @@ int main(int argc, char* argv[])
   } else if (strcmp(argv[1], "printf") == 0) {
     XBT_INFO("Behavior: printf");
     behavior = PRINTF;
+  } else {
+    xbt_die("Please use either 'abort', 'assert' or 'printf' as first parameter, to specify what to do when the error "
+            "is found.");
   }
 
   e.load_platform(argv[2]);