* is important in cases
*/
class ActorState {
-
/**
* @brief The transitions that the actor is allowed to execute from this
* state, viz. those that are enabled for this actor
// <----- send ACTORS_STATUS_REPLY
// <----- send `N` `s_mc_message_actors_status_one_t` structs
// <----- send `M` `s_mc_message_simcall_probe_one_t` structs
- s_mc_message_t msg;
- memset(&msg, 0, sizeof msg);
- msg.type = simgrid::mc::MessageType::ACTORS_STATUS;
- model_checker_->channel().send(msg);
+ model_checker_->channel().send(MessageType::ACTORS_STATUS);
s_mc_message_actors_status_answer_t answer;
ssize_t received = model_checker_->channel().receive(answer);
long State::expended_states_ = 0;
-State::State(const RemoteApp& remote_app) : default_transition(std::make_unique<Transition>()), num_(++expended_states_)
+State::State(const RemoteApp& remote_app) : num_(++expended_states_)
{
remote_app.get_actors_status(actors_to_run_);
- transition_ = default_transition.get();
-
/* Stateful model checking */
if ((_sg_mc_checkpoint > 0 && (num_ % _sg_mc_checkpoint == 0)) || _sg_mc_termination) {
system_state_ = std::make_shared<simgrid::mc::Snapshot>(num_);
Transition* State::get_transition() const
{
- if (transition_ == nullptr) {
- return default_transition.get();
- }
return transition_;
}
class XBT_PRIVATE State : public xbt::Extendable<State> {
static long expended_states_; /* Count total amount of states, for stats */
+ /**
+ * @brief An empty transition that leads to this state by default
+ */
+ const std::unique_ptr<Transition> default_transition_ = std::make_unique<Transition>();
+
/**
* @brief The outgoing transition: what was the last transition that
* we took to leave this state?
* or a reference to the internal default transition `Transition()` if no transition has been
* set
*/
- Transition* transition_ = nullptr;
-
- /**
- * @brief An empty transition that leads to this state by default
- */
- const std::unique_ptr<Transition> default_transition;
+ Transition* transition_ = default_transition_.get();
/** Sequential state ID (used for debugging) */
long num_ = 0;
ssize_t received_size = channel_.receive(message_buffer.data(), message_buffer.size());
xbt_assert(received_size >= 0, "Could not receive commands from the model-checker");
+ xbt_assert(static_cast<size_t>(received_size) >= sizeof(s_mc_message_t), "Cannot handle short message (size=%zd)",
+ received_size);
const s_mc_message_t* message = (s_mc_message_t*)message_buffer.data();
switch (message->type) {
}
}
- if (is_valid_MessageType(*(int*)message)) {
- XBT_DEBUG("Sending %s (%lu bytes sent)", to_c_str(*(MessageType*)message), size);
+ if (is_valid_MessageType(*static_cast<const int*>(message))) {
+ XBT_DEBUG("Sending %s (%lu bytes sent)", to_c_str(*static_cast<const MessageType*>(message)), size);
} else {
XBT_DEBUG("Sending bytes directly (from address %p) (%lu bytes sent)", message, size);
}
{
ssize_t res = recv(this->socket_, message, size, block ? 0 : MSG_DONTWAIT);
if (res != -1) {
- if (is_valid_MessageType(*(int*)message)) {
- XBT_DEBUG("Receive %s (requested %lu; received %ld)", to_c_str(*(MessageType*)message), size, res);
+ if (is_valid_MessageType(*static_cast<int*>(message))) {
+ XBT_DEBUG("Receive %s (requested %lu; received %ld)", to_c_str(*static_cast<MessageType*>(message)), size, res);
} else {
XBT_DEBUG("Receive %ld bytes", res);
}