Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill a function that is unused and unimplemented
[simgrid.git] / src / mc / mc_client_api.cpp
1 /* Copyright (c) 2008-2022. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
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"
14
15 /** @file mc_client_api.cpp
16  *
17  *  This is the implementation of the API used by the user simulated program to
18  *  communicate with the MC (declared in modelchecker.h).
19  */
20
21 // MC_random() is in mc_base.cpp
22
23 void MC_assert(int prop)
24 {
25   xbt_assert(mc_model_checker == nullptr);
26   if (not prop) {
27     if (MC_is_active())
28       simgrid::mc::AppSide::get()->report_assertion_failure();
29     if (MC_record_replay_is_active())
30       xbt_die("MC assertion failed");
31   }
32 }
33
34 void MC_ignore(void* addr, size_t size)
35 {
36   xbt_assert(mc_model_checker == nullptr);
37   if (not MC_is_active())
38     return;
39   simgrid::mc::AppSide::get()->ignore_memory(addr, size);
40 }
41
42 void MC_automaton_new_propositional_symbol(const char* /*id*/, int (*/*fct*/)())
43 {
44   xbt_assert(mc_model_checker == nullptr);
45   if (not MC_is_active())
46     return;
47   xbt_die("Support for client-side function proposition is not implemented: "
48     "use MC_automaton_new_propositional_symbol_pointer instead.");
49 }
50
51 void MC_automaton_new_propositional_symbol_pointer(const char *name, int* value)
52 {
53   xbt_assert(mc_model_checker == nullptr);
54   if (not MC_is_active())
55     return;
56   simgrid::mc::AppSide::get()->declare_symbol(name, value);
57 }
58
59 /** @brief Register a stack in the model checker
60  *
61  *  The stacks are allocated in the heap. The MC handle them specifically
62  *  when we analyze/compare the content of the heap so it must be told where
63  *  they are with this function.
64  *
65  *  @param stack Where the stack is
66  *  @param actor Actor owning the stack
67  *  @param context The context associated to that stack
68  *  @param size    Size of the stack
69  */
70 void MC_register_stack_area(void* stack, ucontext_t* context, size_t size)
71 {
72   xbt_assert(mc_model_checker == nullptr);
73   if (not MC_is_active())
74     return;
75   simgrid::mc::AppSide::get()->declare_stack(stack, size, context);
76 }
77
78 void MC_ignore_global_variable(const char* /*name*/)
79 {
80   xbt_assert(mc_model_checker == nullptr);
81   if (not MC_is_active())
82     return;
83   // TODO, send a message to the model_checker
84   xbt_die("Unimplemented");
85 }
86
87 void MC_ignore_heap(void *address, size_t size)
88 {
89   xbt_assert(mc_model_checker == nullptr);
90   if (not MC_is_active())
91     return;
92   simgrid::mc::AppSide::get()->ignore_heap(address, size);
93 }
94
95 void MC_unignore_heap(void* address, size_t size)
96 {
97   xbt_assert(mc_model_checker == nullptr);
98   if (not MC_is_active())
99     return;
100   simgrid::mc::AppSide::get()->unignore_heap(address, size);
101 }