1 /* Copyright (c) 2016. 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_SESSION_HPP
8 #define SIMGRID_MC_SESSION_HPP
11 #include <sys/prctl.h>
14 #include <sys/types.h>
15 #include <sys/socket.h>
16 #include <xbt/sysdep.h>
17 #include <xbt/system_error.hpp>
23 #include "src/mc/mc_forward.hpp"
24 #include "src/mc/ModelChecker.hpp"
29 /** A model-checking session
31 * This is expected to become the interface used by model-checking
32 * algorithms to control the execution of the model-checked process
33 * and the exploration of the execution graph. Model-checking
34 * algorithms should be able to be written in high-level languages
35 * (e.g. Python) using bindings on this interface.
39 std::unique_ptr<ModelChecker> modelChecker_;
42 Session(pid_t pid, int socket);
45 Session(Session const&) = delete;
46 Session& operator=(Session const&) = delete;
52 public: // static constructors
54 /** Create a new session by forking
56 * The code is expected to `exec` the model-checker program.
58 static Session* fork(std::function<void(void)> code);
60 /** Create a session using `execv` */
61 static Session* spawnv(const char *path, char *const argv[]);
63 /** Create a session using `execvp` */
64 static Session* spawnvp(const char *path, char *const argv[]);
68 extern simgrid::mc::Session* session;