--- /dev/null
+/* Copyright (c) 2015-2022. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "src/mc/Transition.hpp"
+#include "src/mc/ModelChecker.hpp"
+#include "src/mc/Session.hpp"
+#include "xbt/asserts.h"
+
+namespace simgrid {
+namespace mc {
+
+std::string Transition::to_string()
+{
+ xbt_assert(mc_model_checker != nullptr, "Must be called from MCer");
+
+ return textual;
+}
+RemotePtr<simgrid::kernel::actor::SimcallObserver> Transition::execute()
+{
+ textual = mc_model_checker->simcall_to_string(aid_, times_considered_);
+ return session_singleton->execute(*this);
+}
+} // namespace mc
+} // namespace simgrid
#define SIMGRID_MC_TRANSITION_HPP
#include "simgrid/forward.h" // aid_t
+#include "src/mc/remote/RemotePtr.hpp"
#include <string>
namespace simgrid {
/* Textual representation of the transition, to display backtraces */
std::string textual = "";
+
+ std::string to_string();
+ RemotePtr<simgrid::kernel::actor::SimcallObserver> execute();
};
} // namespace mc
return false;
}
-std::string Api::request_to_string(aid_t aid, int value) const
-{
- xbt_assert(mc_model_checker != nullptr, "Must be called from MCer");
-
- return mc_model_checker->simcall_to_string(aid, value);
-}
-
std::string Api::request_get_dot_output(aid_t aid, int value) const
{
const char* color = get_color(aid - 1);
session_singleton->close();
}
-RemotePtr<simgrid::kernel::actor::SimcallObserver> Api::execute(Transition& transition) const
-{
- /* FIXME: once all simcalls have observers, kill the simcall parameter and use mc_model_checker->simcall_to_string() */
- transition.textual = request_to_string(transition.aid_, transition.times_considered_);
- return session_singleton->execute(transition);
-}
-
void Api::automaton_load(const char* file) const
{
MC_automaton_load(file);
// SIMCALL APIs
bool requests_are_dependent(RemotePtr<kernel::actor::SimcallObserver> obs1,
RemotePtr<kernel::actor::SimcallObserver> obs2) const;
- std::string request_to_string(aid_t aid, int value) const;
std::string request_get_dot_output(aid_t aid, int value) const;
smx_actor_t simcall_get_issuer(s_smx_simcall const* req) const;
RemotePtr<kernel::activity::MailboxImpl> get_mbox_remote_addr(smx_simcall_t const req) const;
// SESSION APIs
void s_close() const;
- RemotePtr<simgrid::kernel::actor::SimcallObserver> execute(Transition& transition) const;
// AUTOMATION APIs
#if SIMGRID_HAVE_MC
{
std::vector<std::string> trace;
for (auto const& state : stack_)
- trace.push_back(api::get().request_to_string(state->transition_.aid_, state->transition_.times_considered_));
+ trace.push_back(state->transition_.to_string());
return trace;
}
int req_num = cur_state->transition_.times_considered_;
smx_simcall_t req = &cur_state->executed_req_;
- XBT_DEBUG("Execute: %s", api::get().request_to_string(aid, req_num).c_str());
+ XBT_DEBUG("Execute: %s", cur_state->transition_.to_string().c_str());
std::string req_str;
if (dot_output != nullptr)
std::shared_ptr<State> state = pair->graph_state;
if (pair->exploration_started) {
- /* Debug information */
- XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth,
- api::get().request_to_string(state->transition_.aid_, state->transition_.times_considered_).c_str(),
- state.get());
-
- api::get().execute(state->transition_);
+ state->transition_.execute();
+ XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth, state->transition_.to_string().c_str(), state.get());
}
/* Update statistics */
for (std::shared_ptr<Pair> const& pair : exploration_stack_) {
smx_simcall_t req = &pair->graph_state->executed_req_;
if (req->call_ != simix::Simcall::NONE)
- trace.push_back(api::get().request_to_string(pair->graph_state->transition_.aid_,
- pair->graph_state->transition_.times_considered_));
+ trace.push_back(pair->graph_state->transition_.to_string());
}
return trace;
}
fflush(dot_output);
}
- XBT_DEBUG("Execute: %s", api::get().request_to_string(aid, req_num).c_str());
+ XBT_DEBUG("Execute: %s", current_pair->graph_state->transition_.to_string().c_str());
/* Update stats */
api::get().mc_inc_executed_trans();
}
/* Actually answer the request: let execute the selected request (MCed does one step) */
- auto remote_observer = api::get().execute(state->transition_);
+ auto remote_observer = state->transition_.execute();
// If there are processes to interleave and the maximum depth has not been
// reached then perform one step of the exploration algorithm.
- XBT_DEBUG("Execute: %s", state->transition_.textual.c_str());
+ XBT_DEBUG("Execute: %s", state->transition_.to_string().c_str());
std::string req_str;
if (dot_output != nullptr)
for (std::unique_ptr<State> const& state : stack_) {
if (state == stack_.back())
break;
- api::get().execute(state->transition_);
+ state->transition_.execute();
/* Update statistics */
api::get().mc_inc_visited_states();
api::get().mc_inc_executed_trans();
src/mc/mc_client_api.cpp
src/mc/mc_smx.cpp
src/mc/mc_exit.hpp
+ src/mc/Transition.cpp
src/mc/Transition.hpp
src/mc/udpor_global.cpp
src/mc/udpor_global.hpp