1 /* Copyright (c) 2008-2021. 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 #include "src/mc/ModelChecker.hpp"
8 #include "src/mc/mc_ignore.hpp"
9 #include "src/mc/mc_private.hpp"
10 #include "src/mc/mc_record.hpp"
11 #include "src/mc/mc_replay.hpp"
12 #include "src/mc/remote/AppSide.hpp"
13 #include "xbt/asserts.h"
15 /** @file mc_client_api.cpp
17 * This is the implementation of the API used by the user simulated program to
18 * communicate with the MC (declared in modelchecker.h).
21 // MC_random() is in mc_base.cpp
23 void MC_assert(int prop)
25 xbt_assert(mc_model_checker == nullptr);
28 simgrid::mc::AppSide::get()->report_assertion_failure();
29 if (MC_record_replay_is_active())
30 xbt_die("MC assertion failed");
36 xbt_assert(mc_model_checker == nullptr);
37 if (not MC_is_active())
39 // FIXME, We want to do this in the model-checker:
40 xbt_die("MC_cut() not implemented");
43 void MC_ignore(void* addr, size_t size)
45 xbt_assert(mc_model_checker == nullptr);
46 if (not MC_is_active())
48 simgrid::mc::AppSide::get()->ignore_memory(addr, size);
51 void MC_automaton_new_propositional_symbol(const char* /*id*/, int (*/*fct*/)())
53 xbt_assert(mc_model_checker == nullptr);
54 if (not MC_is_active())
56 xbt_die("Support for client-side function proposition is not implemented: "
57 "use MC_automaton_new_propositional_symbol_pointer instead.");
60 void MC_automaton_new_propositional_symbol_pointer(const char *name, int* value)
62 xbt_assert(mc_model_checker == nullptr);
63 if (not MC_is_active())
65 simgrid::mc::AppSide::get()->declare_symbol(name, value);
68 /** @brief Register a stack in the model checker
70 * The stacks are allocated in the heap. The MC handle them specifically
71 * when we analyze/compare the content of the heap so it must be told where
72 * they are with this function.
74 * @param stack Where the stack is
75 * @param actor Actor owning the stack
76 * @param context The context associated to that stack
77 * @param size Size of the stack
79 void MC_register_stack_area(void* stack, ucontext_t* context, size_t size)
81 xbt_assert(mc_model_checker == nullptr);
82 if (not MC_is_active())
84 simgrid::mc::AppSide::get()->declare_stack(stack, size, context);
87 void MC_ignore_global_variable(const char* /*name*/)
89 xbt_assert(mc_model_checker == nullptr);
90 if (not MC_is_active())
92 // TODO, send a message to the model_checker
93 xbt_die("Unimplemented");
96 void MC_ignore_heap(void *address, size_t size)
98 xbt_assert(mc_model_checker == nullptr);
99 if (not MC_is_active())
101 simgrid::mc::AppSide::get()->ignore_heap(address, size);
104 void MC_unignore_heap(void* address, size_t size)
106 xbt_assert(mc_model_checker == nullptr);
107 if (not MC_is_active())
109 simgrid::mc::AppSide::get()->unignore_heap(address, size);