1 /* Copyright (c) 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_CLIENT_H
8 #define SIMGRID_MC_CLIENT_H
10 #include "src/internal_config.h"
17 #include <simgrid/simix.h>
19 #include "src/mc/remote/Channel.hpp"
20 #include "src/mc/remote/mc_protocol.h"
25 /** Model-checked-side of the communication protocol
27 * Send messages to the model-checker and handles message from it.
29 class XBT_PUBLIC() Client {
33 static std::unique_ptr<Client> instance_;
37 explicit Client(int fd) : active_(true), channel_(fd) {}
38 void handleMessages();
41 void handleDeadlockCheck(mc_message_t* msg);
42 void handleContinue(mc_message_t* msg);
43 void handleSimcall(s_mc_message_simcall_handle_t* message);
44 void handleRestore(s_mc_message_restore_t* msg);
47 Channel const& getChannel() const { return channel_; }
48 Channel& getChannel() { return channel_; }
50 void reportAssertionFailure(const char* description = nullptr);
51 void ignoreMemory(void* addr, std::size_t size);
52 void ignoreHeap(void* addr, std::size_t size);
53 void unignoreHeap(void* addr, std::size_t size);
54 void declareSymbol(const char* name, int* value);
56 void declareStack(void* stack, size_t size, smx_actor_t process, ucontext_t* context);
60 // TODO, remove the singleton antipattern.
61 static Client* initialize();
62 static Client* get() { return instance_.get(); }