Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change "if(...) xbt_die(...)" to "xbt_assert(...)".
[simgrid.git] / src / mc / remote / AppSide.cpp
index b19fd09..27c7277 100644 (file)
@@ -46,8 +46,7 @@ AppSide* AppSide::initialize()
   // Check the socket type/validity:
   int type;
   socklen_t socklen = sizeof(type);
-  if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &socklen) != 0)
-    xbt_die("Could not check socket type");
+  xbt_assert(getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &socklen) == 0, "Could not check socket type");
   xbt_assert(type == SOCK_SEQPACKET, "Unexpected socket type %i", type);
   XBT_DEBUG("Model-checked application found expected socket type");
 
@@ -62,8 +61,8 @@ AppSide* AppSide::initialize()
 #else
 #error "no ptrace equivalent coded for this platform"
 #endif
-  if (errno != 0 || raise(SIGSTOP) != 0)
-    xbt_die("Could not wait for the model-checker (errno = %d: %s)", errno, strerror(errno));
+  xbt_assert(errno == 0 && raise(SIGSTOP) == 0, "Could not wait for the model-checker (errno = %d: %s)", errno,
+             strerror(errno));
 
   s_mc_message_initial_addresses_t message{
       MessageType::INITIAL_ADDRESSES, mmalloc_preinit(), simgrid::kernel::actor::get_maxpid_addr(),
@@ -97,8 +96,7 @@ void AppSide::handle_simcall_execute(const s_mc_message_simcall_handle_t* messag
   kernel::actor::ActorImpl* process = kernel::actor::ActorImpl::by_pid(message->aid_);
   xbt_assert(process != nullptr, "Invalid pid %lu", message->aid_);
   process->simcall_handle(message->times_considered_);
-  if (channel_.send(MessageType::WAITING))
-    xbt_die("Could not send MESSAGE_WAITING to model-checker");
+  xbt_assert(channel_.send(MessageType::WAITING) == 0, "Could not send MESSAGE_WAITING to model-checker");
 }
 
 void AppSide::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) const
@@ -231,8 +229,7 @@ void AppSide::main_loop() const
 
 void AppSide::report_assertion_failure() const
 {
-  if (channel_.send(MessageType::ASSERTION_FAILED))
-    xbt_die("Could not send assertion to model-checker");
+  xbt_assert(channel_.send(MessageType::ASSERTION_FAILED) == 0, "Could not send assertion to model-checker");
   this->handle_messages();
 }
 
@@ -242,8 +239,7 @@ void AppSide::ignore_memory(void* addr, std::size_t size) const
   message.type = MessageType::IGNORE_MEMORY;
   message.addr = (std::uintptr_t)addr;
   message.size = size;
-  if (channel_.send(message))
-    xbt_die("Could not send IGNORE_MEMORY message to model-checker");
+  xbt_assert(channel_.send(message) == 0, "Could not send IGNORE_MEMORY message to model-checker");
 }
 
 void AppSide::ignore_heap(void* address, std::size_t size) const
@@ -263,8 +259,7 @@ void AppSide::ignore_heap(void* address, std::size_t size) const
     heap->heapinfo[message.block].busy_frag.ignore[message.fragment]++;
   }
 
-  if (channel_.send(message))
-    xbt_die("Could not send ignored region to MCer");
+  xbt_assert(channel_.send(message) == 0, "Could not send ignored region to MCer");
 }
 
 void AppSide::unignore_heap(void* address, std::size_t size) const
@@ -273,21 +268,18 @@ void AppSide::unignore_heap(void* address, std::size_t size) const
   message.type = MessageType::UNIGNORE_HEAP;
   message.addr = (std::uintptr_t)address;
   message.size = size;
-  if (channel_.send(message))
-    xbt_die("Could not send IGNORE_HEAP message to model-checker");
+  xbt_assert(channel_.send(message) == 0, "Could not send IGNORE_HEAP message to model-checker");
 }
 
 void AppSide::declare_symbol(const char* name, int* value) const
 {
   s_mc_message_register_symbol_t message;
   message.type = MessageType::REGISTER_SYMBOL;
-  if (strlen(name) + 1 > message.name.size())
-    xbt_die("Symbol is too long");
+  xbt_assert(strlen(name) + 1 <= message.name.size(), "Symbol is too long");
   strncpy(message.name.data(), name, message.name.size());
   message.callback = nullptr;
   message.data     = value;
-  if (channel_.send(message))
-    xbt_die("Could send REGISTER_SYMBOL message to model-checker");
+  xbt_assert(channel_.send(message) == 0, "Could send REGISTER_SYMBOL message to model-checker");
 }
 
 void AppSide::declare_stack(void* stack, size_t size, ucontext_t* context) const
@@ -304,8 +296,7 @@ void AppSide::declare_stack(void* stack, size_t size, ucontext_t* context) const
   s_mc_message_stack_region_t message;
   message.type         = MessageType::STACK_REGION;
   message.stack_region = region;
-  if (channel_.send(message))
-    xbt_die("Could not send STACK_REGION to model-checker");
+  xbt_assert(channel_.send(message) == 0, "Could not send STACK_REGION to model-checker");
 }
 } // namespace mc
 } // namespace simgrid