1 /* Copyright (c) 2007-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SIMGRID_MC_MODEL_CHECKER_HPP
8 #define SIMGRID_MC_MODEL_CHECKER_HPP
10 #include <sys/types.h>
16 #include <event2/event.h>
18 #include <simgrid_config.h>
20 #include <sys/types.h>
22 #include "src/mc/PageStore.hpp"
23 #include "src/mc/Process.hpp"
24 #include "src/mc/Transition.hpp"
25 #include "src/mc/mc_forward.hpp"
26 #include "src/mc/remote/mc_protocol.h"
31 /** State of the model-checker (global variables for the model checker)
34 struct event_base *base_;
35 struct event* socket_event_;
36 struct event* signal_event_;
37 /** String pool for host names */
38 // TODO, use std::set with heterogeneous comparison lookup (C++14)?
39 std::set<std::string> hostnames_;
40 // This is the parent snapshot of the current state:
41 PageStore page_store_;
42 std::unique_ptr<Process> process_;
43 Checker* checker_ = nullptr;
45 std::shared_ptr<simgrid::mc::Snapshot> parent_snapshot_;
48 ModelChecker(ModelChecker const&) = delete;
49 ModelChecker& operator=(ModelChecker const&) = delete;
50 explicit ModelChecker(std::unique_ptr<Process> process);
57 PageStore& page_store()
62 std::string const& get_host_name(const char* hostname)
64 return *this->hostnames_.insert(hostname).first;
66 std::string const& get_host_name(std::string const& hostname)
68 return *this->hostnames_.insert(hostname).first;
73 void resume(simgrid::mc::Process& process);
75 void handle_events(int fd, short events);
76 void wait_client(simgrid::mc::Process& process);
77 void handle_simcall(Transition const& transition);
78 void wait_for_requests()
80 mc_model_checker->wait_client(mc_model_checker->process());
82 void exit(int status);
86 Checker* getChecker() const { return checker_; }
87 void setChecker(Checker* checker) { checker_ = checker; }
91 bool handle_message(char* buffer, ssize_t size);
92 void handle_waitpid();
93 void on_signal(int signo);
96 unsigned long visited_states = 0;
97 unsigned long executed_transitions = 0;