namespace simgrid {
namespace mc {
-CommWaitTransition::CommWaitTransition(aid_t issuer, int times_considered, char* buffer)
+CommWaitTransition::CommWaitTransition(aid_t issuer, int times_considered, std::stringstream& stream)
: Transition(Type::COMM_WAIT, issuer, times_considered)
{
- std::stringstream stream(buffer);
stream >> timeout_ >> comm_ >> sender_ >> receiver_ >> mbox_ >> src_buff_ >> dst_buff_ >> size_;
XBT_DEBUG("CommWaitTransition %s comm:%p, sender:%ld receiver:%ld mbox:%u sbuff:%p rbuff:%p size:%zu",
(timeout_ ? "timeout" : "no-timeout"), comm_, sender_, receiver_, mbox_, src_buff_, dst_buff_, size_);
return true;
}
-CommTestTransition::CommTestTransition(aid_t issuer, int times_considered, char* buffer)
+CommTestTransition::CommTestTransition(aid_t issuer, int times_considered, std::stringstream& stream)
: Transition(Type::COMM_TEST, issuer, times_considered)
{
- std::stringstream stream(buffer);
stream >> comm_ >> sender_ >> receiver_ >> mbox_ >> src_buff_ >> dst_buff_ >> size_;
XBT_DEBUG("CommTestTransition comm:%p, sender:%ld receiver:%ld mbox:%u sbuff:%p rbuff:%p size:%zu", comm_, sender_,
receiver_, mbox_, src_buff_, dst_buff_, size_);
return true;
}
-CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, char* buffer)
+CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream)
: Transition(Type::COMM_RECV, issuer, times_considered)
{
- std::stringstream stream(buffer);
stream >> mbox_ >> dst_buff_;
}
std::string CommRecvTransition::to_string(bool verbose) const
return true;
}
-CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, char* buffer)
+CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream)
: Transition(Type::COMM_SEND, issuer, times_considered)
{
- std::stringstream stream(buffer);
stream >> mbox_ >> src_buff_ >> size_;
XBT_DEBUG("SendTransition mbox:%u buff:%p size:%zu", mbox_, src_buff_, size_);
}
res += ")";
return res;
}
+TestAnyTransition::TestAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream)
+ : Transition(Type::TESTANY, issuer, times_considered)
+{
+ int size;
+ stream >> size;
+ for (int i = 0; i < size; i++) {
+
+ Transition* t = recv_transition(issuer, 0, stream);
+ transitions_.push_back(t);
+ }
+}
+std::string TestAnyTransition::to_string(bool verbose) const
+{
+ auto res = xbt::string_printf("%ld: TestAny{ ", aid_);
+ for (auto const* t : transitions_)
+ res += t->to_string(verbose);
+ res += "}";
+ return res;
+}
+bool TestAnyTransition::depends(const Transition* other) const
+{
+ return true;
+}
bool CommSendTransition::depends(const Transition* other) const
{
return true;
}
-Transition* recv_transition(aid_t issuer, int times_considered, Transition::Type simcall, char* buffer)
+Transition* recv_transition(aid_t issuer, int times_considered, std::stringstream& stream)
{
+ short type;
+ stream >> type;
+ xbt_assert(type >= 0 && type <= static_cast<short>(Transition::Type::UNKNOWN), "Invalid transition type %d received",
+ type);
+
+ auto simcall = static_cast<Transition::Type>(type);
+
switch (simcall) {
case Transition::Type::COMM_RECV:
- return new CommRecvTransition(issuer, times_considered, buffer);
+ return new CommRecvTransition(issuer, times_considered, stream);
case Transition::Type::COMM_SEND:
- return new CommSendTransition(issuer, times_considered, buffer);
+ return new CommSendTransition(issuer, times_considered, stream);
case Transition::Type::COMM_TEST:
- return new CommTestTransition(issuer, times_considered, buffer);
+ return new CommTestTransition(issuer, times_considered, stream);
case Transition::Type::COMM_WAIT:
- return new CommWaitTransition(issuer, times_considered, buffer);
+ return new CommWaitTransition(issuer, times_considered, stream);
+
+ case Transition::Type::TESTANY:
+ return new TestAnyTransition(issuer, times_considered, stream);
case Transition::Type::RANDOM:
- return new RandomTransition(issuer, times_considered, buffer);
+ return new RandomTransition(issuer, times_considered, stream);
case Transition::Type::UNKNOWN:
return new Transition(Transition::Type::UNKNOWN, issuer, times_considered);
- default:
- xbt_die("recv_transition of type %s unimplemented", Transition::to_c_str(simcall));
}
+ THROW_IMPOSSIBLE; // Some compilers don't detect that each branch of the above switch has a return
}
} // namespace mc