namespace simgrid::mc {
-RemoteApp::RemoteApp(const std::vector<char*>& args)
+RemoteApp::RemoteApp(const std::vector<char*>& args, bool need_memory_introspection)
{
- checker_side_ = std::make_unique<simgrid::mc::CheckerSide>(args);
+ for (auto* arg : args)
+ app_args_.push_back(arg);
- initial_snapshot_ = std::make_shared<simgrid::mc::Snapshot>(0, page_store_, checker_side_->get_remote_memory());
+ checker_side_ = std::make_unique<simgrid::mc::CheckerSide>(app_args_);
+
+ if (need_memory_introspection)
+ initial_snapshot_ = std::make_shared<simgrid::mc::Snapshot>(0, page_store_, checker_side_->get_remote_memory());
}
RemoteApp::~RemoteApp()
shutdown();
}
-void RemoteApp::restore_initial_state() const
+void RemoteApp::restore_initial_state()
{
- this->initial_snapshot_->restore(checker_side_->get_remote_memory());
+ if (initial_snapshot_ == nullptr) { // No memory introspection
+ shutdown();
+ checker_side_.reset(
+ nullptr); // We need to destroy the existing CheckerSide before creating the new one, or libevent gets crazy
+ checker_side_.reset(new simgrid::mc::CheckerSide(app_args_));
+ } else
+ initial_snapshot_->restore(checker_side_->get_remote_memory());
}
unsigned long RemoteApp::get_maxpid() const
PageStore page_store_{500};
std::shared_ptr<simgrid::mc::Snapshot> initial_snapshot_;
+ std::vector<char*> app_args_;
+
// No copy:
RemoteApp(RemoteApp const&) = delete;
RemoteApp& operator=(RemoteApp const&) = delete;
*
* The code is expected to `exec` the model-checked application.
*/
- explicit RemoteApp(const std::vector<char*>& args);
+ explicit RemoteApp(const std::vector<char*>& args, bool need_memory_introspection);
~RemoteApp();
- void restore_initial_state() const;
+ void restore_initial_state();
void wait_for_requests();
/** Ask to the application to check for a deadlock. If so, do an error message and throw a DeadlockError. */
} // If no backtracing point, then the stack is empty and the exploration is over
}
-DFSExplorer::DFSExplorer(const std::vector<char*>& args, bool with_dpor) : Exploration(args)
+DFSExplorer::DFSExplorer(const std::vector<char*>& args, bool with_dpor) : Exploration(args, true)
{
if (with_dpor)
reduction_mode_ = ReductionMode::dpor;
Exploration* Exploration::instance_ = nullptr; // singleton instance
-Exploration::Exploration(const std::vector<char*>& args) : remote_app_(std::make_unique<RemoteApp>(args))
+Exploration::Exploration(const std::vector<char*>& args, bool need_memory_introspection)
+ : remote_app_(std::make_unique<RemoteApp>(args, need_memory_introspection))
{
xbt_assert(instance_ == nullptr, "Cannot have more than one exploration instance");
instance_ = this;
FILE* dot_output_ = nullptr;
public:
- explicit Exploration(const std::vector<char*>& args);
+ explicit Exploration(const std::vector<char*>& args, bool need_memory_introspection);
virtual ~Exploration();
static Exploration* get_instance() { return instance_; }
}
}
-LivenessChecker::LivenessChecker(const std::vector<char*>& args) : Exploration(args) {}
+LivenessChecker::LivenessChecker(const std::vector<char*>& args) : Exploration(args, true) {}
LivenessChecker::~LivenessChecker()
{
xbt_automaton_free(property_automaton_);
namespace simgrid::mc::udpor {
-UdporChecker::UdporChecker(const std::vector<char*>& args) : Exploration(args)
+UdporChecker::UdporChecker(const std::vector<char*>& args) : Exploration(args, true)
{
// Initialize the map
}
void CheckerSide::setup_events()
{
+ if (base_ != nullptr)
+ event_base_free(base_.get());
auto* base = event_base_new();
base_.reset(base);
/* CheckerSide: All what the checker needs to interact with a given application process */
class CheckerSide {
+ void (*const free_event_fun)(event*) = [](event* evt) {
+ event_del(evt);
+ event_free(evt);
+ };
+ std::unique_ptr<event, decltype(&event_free)> socket_event_{nullptr, free_event_fun};
+ std::unique_ptr<event, decltype(&event_free)> signal_event_{nullptr, free_event_fun};
std::unique_ptr<event_base, decltype(&event_base_free)> base_{nullptr, &event_base_free};
- std::unique_ptr<event, decltype(&event_free)> socket_event_{nullptr, &event_free};
- std::unique_ptr<event, decltype(&event_free)> signal_event_{nullptr, &event_free};
std::unique_ptr<RemoteProcessMemory> remote_memory_;
- Channel channel_;
+ Channel channel_;
bool running_ = false;
pid_t pid_;