// 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");
#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(),
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
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();
}
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
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
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
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