Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
8f3e698142897488d2699369acdba3d48baca452
[simgrid.git] / src / mc / api.cpp
1 /* Copyright (c) 2020-2022. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "api.hpp"
7
8 #include "src/kernel/activity/MailboxImpl.hpp"
9 #include "src/kernel/activity/MutexImpl.hpp"
10 #include "src/kernel/actor/SimcallObserver.hpp"
11 #include "src/mc/Session.hpp"
12 #include "src/mc/checker/Checker.hpp"
13 #include "src/mc/mc_base.hpp"
14 #include "src/mc/mc_comm_pattern.hpp"
15 #include "src/mc/mc_exit.hpp"
16 #include "src/mc/mc_pattern.hpp"
17 #include "src/mc/mc_private.hpp"
18 #include "src/mc/remote/RemoteProcess.hpp"
19 #include "src/surf/HostImpl.hpp"
20
21 #include <xbt/asserts.h>
22 #include <xbt/log.h>
23 #include "simgrid/s4u/Host.hpp"
24 #include "xbt/string.hpp"
25 #if HAVE_SMPI
26 #include "src/smpi/include/smpi_request.hpp"
27 #endif
28
29 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(Api, mc, "Logging specific to MC Facade APIs ");
30 XBT_LOG_EXTERNAL_CATEGORY(mc_global);
31
32 using Simcall = simgrid::simix::Simcall;
33
34 namespace simgrid {
35 namespace mc {
36
37 static inline const char* get_color(int id)
38 {
39   static constexpr std::array<const char*, 13> colors{{"blue", "red", "green3", "goldenrod", "brown", "purple",
40                                                        "magenta", "turquoise4", "gray25", "forestgreen", "hotpink",
41                                                        "lightblue", "tan"}};
42   return colors[id % colors.size()];
43 }
44
45 static std::string pointer_to_string(void* pointer)
46 {
47   return XBT_LOG_ISENABLED(Api, xbt_log_priority_verbose) ? xbt::string_printf("%p", pointer) : "(verbose only)";
48 }
49
50 static std::string buff_size_to_string(size_t buff_size)
51 {
52   return XBT_LOG_ISENABLED(Api, xbt_log_priority_verbose) ? std::to_string(buff_size) : "(verbose only)";
53 }
54
55 /* Search an enabled transition for the given process.
56  *
57  * This can be seen as an iterator returning the next transition of the process.
58  *
59  * We only consider the processes that are both
60  *  - marked "to be interleaved" in their ActorState (controlled by the checker algorithm).
61  *  - which simcall can currently be executed (like a comm where the other partner is already known)
62  * Once we returned the last enabled transition of a process, it is marked done.
63  *
64  * Things can get muddled with the WAITANY and TESTANY simcalls, that are rewritten on the fly to a bunch of WAIT
65  * (resp TEST) transitions using the transition.argument field to remember what was the last returned sub-transition.
66  */
67 static inline smx_simcall_t MC_state_choose_request_for_process(const RemoteProcess& process, simgrid::mc::State* state,
68                                                                 smx_actor_t actor)
69 {
70   /* reset the outgoing transition */
71   simgrid::mc::ActorState* procstate = &state->actor_states_[actor->get_pid()];
72   state->transition_.aid_              = -1;
73   state->transition_.times_considered_ = -1;
74   state->transition_.textual[0]        = '\0';
75   state->executed_req_.call_         = Simcall::NONE;
76
77   if (not simgrid::mc::actor_is_enabled(actor))
78     return nullptr; // Not executable in the application
79
80   smx_simcall_t req = nullptr;
81   if (actor->simcall_.observer_ != nullptr) {
82     state->transition_.times_considered_ = procstate->get_times_considered_and_inc();
83     if (actor->simcall_.mc_max_consider_ <= procstate->get_times_considered())
84       procstate->set_done();
85     req = &actor->simcall_;
86   } else {
87     procstate->set_done();
88     state->transition_.times_considered_ = 0;
89     req                                  = &actor->simcall_;
90   }
91   if (not req)
92     return nullptr;
93
94   state->transition_.aid_ = actor->get_pid();
95   state->executed_req_    = *req;
96
97   return req;
98 }
99
100 kernel::activity::CommImpl* Api::get_comm_or_nullptr(smx_simcall_t const r) const
101 {
102   if (auto wait = dynamic_cast<kernel::actor::ActivityWaitSimcall*>(r->observer_))
103     return static_cast<kernel::activity::CommImpl*>(wait->get_activity());
104   if (auto test = dynamic_cast<kernel::actor::ActivityTestSimcall*>(r->observer_))
105     return static_cast<kernel::activity::CommImpl*>(test->get_activity());
106   return nullptr;
107 }
108
109 /** Statically "upcast" a s_smx_actor_t into an ActorInformation
110  *
111  *  This gets 'actorInfo' from '&actorInfo->copy'. It upcasts in the
112  *  sense that we could achieve the same thing by having ActorInformation
113  *  inherit from s_smx_actor_t but we don't really want to do that.
114  */
115 simgrid::mc::ActorInformation* Api::actor_info_cast(smx_actor_t actor) const
116 {
117   simgrid::mc::ActorInformation temp;
118   std::size_t offset = (char*)temp.copy.get_buffer() - (char*)&temp;
119
120   auto* process_info = reinterpret_cast<simgrid::mc::ActorInformation*>((char*)actor - offset);
121   return process_info;
122 }
123
124 bool Api::requests_are_dependent(RemotePtr<kernel::actor::SimcallObserver> obs1,
125                                  RemotePtr<kernel::actor::SimcallObserver> obs2) const
126 {
127   xbt_assert(mc_model_checker != nullptr, "Must be called from MCer");
128
129   return mc_model_checker->requests_are_dependent(obs1, obs2);
130 }
131
132 xbt::string const& Api::get_actor_host_name(smx_actor_t actor) const
133 {
134   if (mc_model_checker == nullptr)
135     return actor->get_host()->get_name();
136
137   const simgrid::mc::RemoteProcess* process = &mc_model_checker->get_remote_process();
138
139   // Read the simgrid::xbt::string in the MCed process:
140   simgrid::mc::ActorInformation* info = actor_info_cast(actor);
141
142   if (not info->hostname) {
143     Remote<s4u::Host> temp_host = process->read(remote(actor->get_host()));
144     auto remote_string_address  = remote(&xbt::string::to_string_data(temp_host.get_buffer()->get_impl()->get_name()));
145     simgrid::xbt::string_data remote_string = process->read(remote_string_address);
146     std::vector<char> hostname(remote_string.len + 1);
147     // no need to read the terminating null byte, and thus hostname[remote_string.len] is guaranteed to be '\0'
148     process->read_bytes(hostname.data(), remote_string.len, remote(remote_string.data));
149     info->hostname = &mc_model_checker->get_host_name(hostname.data());
150   }
151   return *info->hostname;
152 }
153
154 xbt::string const& Api::get_actor_name(smx_actor_t actor) const
155 {
156   if (mc_model_checker == nullptr)
157     return actor->get_name();
158
159   simgrid::mc::ActorInformation* info = actor_info_cast(actor);
160   if (info->name.empty()) {
161     const simgrid::mc::RemoteProcess* process = &mc_model_checker->get_remote_process();
162
163     simgrid::xbt::string_data string_data = simgrid::xbt::string::to_string_data(actor->name_);
164     info->name = process->read_string(remote(string_data.data), string_data.len);
165   }
166   return info->name;
167 }
168
169 std::string Api::get_actor_string(smx_actor_t actor) const
170 {
171   std::string res;
172   if (actor) {
173     res = "(" + std::to_string(actor->get_pid()) + ")";
174     if (actor->get_host())
175       res += std::string(get_actor_host_name(actor)) + " (" + std::string(get_actor_name(actor)) + ")";
176     else
177       res += get_actor_name(actor);
178   } else
179     res = "(0) ()";
180   return res;
181 }
182
183 std::string Api::get_actor_dot_label(smx_actor_t actor) const
184 {
185   std::string res = "(" + std::to_string(actor->get_pid()) + ")";
186   if (actor->get_host())
187     res += get_actor_host_name(actor);
188   return res;
189 }
190
191 simgrid::mc::Checker* Api::initialize(char** argv, simgrid::mc::CheckerAlgorithm algo) const
192 {
193   auto session = new simgrid::mc::Session([argv] {
194     int i = 1;
195     while (argv[i] != nullptr && argv[i][0] == '-')
196       i++;
197     xbt_assert(argv[i] != nullptr,
198                "Unable to find a binary to exec on the command line. Did you only pass config flags?");
199     execvp(argv[i], argv + i);
200     xbt_die("The model-checked process failed to exec(%s): %s", argv[i], strerror(errno));
201   });
202
203   simgrid::mc::Checker* checker;
204   switch (algo) {
205     case CheckerAlgorithm::CommDeterminism:
206       checker = simgrid::mc::create_communication_determinism_checker(session);
207       break;
208
209     case CheckerAlgorithm::UDPOR:
210       checker = simgrid::mc::create_udpor_checker(session);
211       break;
212
213     case CheckerAlgorithm::Safety:
214       checker = simgrid::mc::create_safety_checker(session);
215       break;
216
217     case CheckerAlgorithm::Liveness:
218       checker = simgrid::mc::create_liveness_checker(session);
219       break;
220
221     default:
222       THROW_IMPOSSIBLE;
223   }
224
225   // FIXME: session and checker are never deleted
226   simgrid::mc::session_singleton = session;
227   mc_model_checker->setChecker(checker);
228   return checker;
229 }
230
231 std::vector<simgrid::mc::ActorInformation>& Api::get_actors() const
232 {
233   return mc_model_checker->get_remote_process().actors();
234 }
235
236 unsigned long Api::get_maxpid() const
237 {
238   return mc_model_checker->get_remote_process().get_maxpid();
239 }
240
241 int Api::get_actors_size() const
242 {
243   return mc_model_checker->get_remote_process().actors().size();
244 }
245
246 RemotePtr<kernel::activity::CommImpl> Api::get_comm_isend_raw_addr(smx_simcall_t request) const
247 {
248   return remote(static_cast<kernel::activity::CommImpl*>(simcall_comm_isend__getraw__result(request)));
249 }
250
251 RemotePtr<kernel::activity::CommImpl> Api::get_comm_waitany_raw_addr(smx_simcall_t request, int value) const
252 {
253   auto addr      = simcall_comm_waitany__getraw__comms(request) + value;
254   auto comm_addr = mc_model_checker->get_remote_process().read(remote(addr));
255   return RemotePtr<kernel::activity::CommImpl>(static_cast<kernel::activity::CommImpl*>(comm_addr));
256 }
257
258 std::string Api::get_pattern_comm_rdv(RemotePtr<kernel::activity::CommImpl> const& addr) const
259 {
260   Remote<kernel::activity::CommImpl> temp_activity;
261   mc_model_checker->get_remote_process().read(temp_activity, addr);
262   const kernel::activity::CommImpl* activity = temp_activity.get_buffer();
263
264   char* remote_name = mc_model_checker->get_remote_process().read<char*>(RemotePtr<char*>(
265       (uint64_t)(activity->get_mailbox() ? &activity->get_mailbox()->get_name() : &activity->mbox_cpy->get_name())));
266   auto rdv          = mc_model_checker->get_remote_process().read_string(RemotePtr<char>(remote_name));
267   return rdv;
268 }
269
270 unsigned long Api::get_pattern_comm_src_proc(RemotePtr<kernel::activity::CommImpl> const& addr) const
271 {
272   Remote<kernel::activity::CommImpl> temp_activity;
273   mc_model_checker->get_remote_process().read(temp_activity, addr);
274   const kernel::activity::CommImpl* activity = temp_activity.get_buffer();
275   auto src_proc =
276       mc_model_checker->get_remote_process().resolve_actor(mc::remote(activity->src_actor_.get()))->get_pid();
277   return src_proc;
278 }
279
280 unsigned long Api::get_pattern_comm_dst_proc(RemotePtr<kernel::activity::CommImpl> const& addr) const
281 {
282   Remote<kernel::activity::CommImpl> temp_activity;
283   mc_model_checker->get_remote_process().read(temp_activity, addr);
284   const kernel::activity::CommImpl* activity = temp_activity.get_buffer();
285   auto src_proc =
286       mc_model_checker->get_remote_process().resolve_actor(mc::remote(activity->dst_actor_.get()))->get_pid();
287   return src_proc;
288 }
289
290 std::vector<char> Api::get_pattern_comm_data(RemotePtr<kernel::activity::CommImpl> const& addr) const
291 {
292   simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
293   mc_model_checker->get_remote_process().read(temp_comm, addr);
294   const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
295
296   std::vector<char> buffer{};
297   if (comm->src_buff_ != nullptr) {
298     buffer.resize(comm->src_buff_size_);
299     mc_model_checker->get_remote_process().read_bytes(buffer.data(), buffer.size(), remote(comm->src_buff_));
300   }
301   return buffer;
302 }
303
304 #if HAVE_SMPI
305 bool Api::check_send_request_detached(smx_simcall_t const& simcall) const
306 {
307   Remote<simgrid::smpi::Request> mpi_request;
308   mc_model_checker->get_remote_process().read(
309       mpi_request, remote(static_cast<smpi::Request*>(simcall_comm_isend__get__data(simcall))));
310   return mpi_request.get_buffer()->detached();
311 }
312 #endif
313
314 smx_actor_t Api::get_src_actor(RemotePtr<kernel::activity::CommImpl> const& comm_addr) const
315 {
316   simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
317   mc_model_checker->get_remote_process().read(temp_comm, comm_addr);
318   const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
319
320   auto src_proc = mc_model_checker->get_remote_process().resolve_actor(simgrid::mc::remote(comm->src_actor_.get()));
321   return src_proc;
322 }
323
324 smx_actor_t Api::get_dst_actor(RemotePtr<kernel::activity::CommImpl> const& comm_addr) const
325 {
326   simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
327   mc_model_checker->get_remote_process().read(temp_comm, comm_addr);
328   const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
329
330   auto dst_proc = mc_model_checker->get_remote_process().resolve_actor(simgrid::mc::remote(comm->dst_actor_.get()));
331   return dst_proc;
332 }
333
334 std::size_t Api::get_remote_heap_bytes() const
335 {
336   RemoteProcess& process    = mc_model_checker->get_remote_process();
337   auto heap_bytes_used      = mmalloc_get_bytes_used_remote(process.get_heap()->heaplimit, process.get_malloc_info());
338   return heap_bytes_used;
339 }
340
341 void Api::mc_inc_visited_states() const
342 {
343   mc_model_checker->visited_states++;
344 }
345
346 void Api::mc_inc_executed_trans() const
347 {
348   mc_model_checker->executed_transitions++;
349 }
350
351 unsigned long Api::mc_get_visited_states() const
352 {
353   return mc_model_checker->visited_states;
354 }
355
356 unsigned long Api::mc_get_executed_trans() const
357 {
358   return mc_model_checker->executed_transitions;
359 }
360
361 void Api::mc_check_deadlock() const
362 {
363   if (mc_model_checker->checkDeadlock()) {
364     XBT_CINFO(mc_global, "**************************");
365     XBT_CINFO(mc_global, "*** DEADLOCK DETECTED ***");
366     XBT_CINFO(mc_global, "**************************");
367     XBT_CINFO(mc_global, "Counter-example execution trace:");
368     for (auto const& s : mc_model_checker->getChecker()->get_textual_trace())
369       XBT_CINFO(mc_global, "  %s", s.c_str());
370     simgrid::mc::dumpRecordPath();
371     simgrid::mc::session_singleton->log_state();
372     throw DeadlockError();
373   }
374 }
375
376 /** Get the issuer of a simcall (`req->issuer`)
377  *
378  *  In split-process mode, it does the black magic necessary to get an address
379  *  of a (shallow) copy of the data structure the issuer SIMIX actor in the local
380  *  address space.
381  *
382  *  @param process the MCed process
383  *  @param req     the simcall (copied in the local process)
384  */
385 smx_actor_t Api::simcall_get_issuer(s_smx_simcall const* req) const
386 {
387   xbt_assert(mc_model_checker != nullptr);
388
389   // This is the address of the smx_actor in the MCed process:
390   auto address = simgrid::mc::remote(req->issuer_);
391
392   // Lookup by address:
393   for (auto& actor : mc_model_checker->get_remote_process().actors())
394     if (actor.address == address)
395       return actor.copy.get_buffer();
396   for (auto& actor : mc_model_checker->get_remote_process().dead_actors())
397     if (actor.address == address)
398       return actor.copy.get_buffer();
399
400   xbt_die("Issuer not found");
401 }
402
403 RemotePtr<kernel::activity::MailboxImpl> Api::get_mbox_remote_addr(smx_simcall_t const req) const
404 {
405   if (req->call_ == Simcall::COMM_ISEND)
406     return remote(simcall_comm_isend__get__mbox(req));
407   if (req->call_ == Simcall::COMM_IRECV)
408     return remote(simcall_comm_irecv__get__mbox(req));
409   THROW_IMPOSSIBLE;
410 }
411
412 RemotePtr<kernel::activity::ActivityImpl> Api::get_comm_remote_addr(smx_simcall_t const req) const
413 {
414   if (req->call_ == Simcall::COMM_ISEND)
415     return remote(simcall_comm_isend__getraw__result(req));
416   if (req->call_ == Simcall::COMM_IRECV)
417     return remote(simcall_comm_irecv__getraw__result(req));
418   THROW_IMPOSSIBLE;
419 }
420
421 void Api::handle_simcall(Transition const& transition) const
422 {
423   mc_model_checker->handle_simcall(transition);
424 }
425
426 void Api::mc_wait_for_requests() const
427 {
428   mc_model_checker->wait_for_requests();
429 }
430
431 void Api::mc_exit(int status) const
432 {
433   mc_model_checker->exit(status);
434 }
435
436 void Api::dump_record_path() const
437 {
438   simgrid::mc::dumpRecordPath();
439 }
440
441 smx_simcall_t Api::mc_state_choose_request(simgrid::mc::State* state) const
442 {
443   RemoteProcess& process = mc_model_checker->get_remote_process();
444   XBT_DEBUG("Search for an actor to run. %zu actors to consider", process.actors().size());
445   for (auto& actor : process.actors()) {
446     /* Only consider the actors that were marked as interleaving by the checker algorithm */
447     if (not state->actor_states_[actor.copy.get_buffer()->get_pid()].is_todo())
448       continue;
449
450     smx_simcall_t res = MC_state_choose_request_for_process(process, state, actor.copy.get_buffer());
451     if (res) {
452       XBT_DEBUG("Let's run actor %ld, going for transition %s", actor.copy.get_buffer()->get_pid(),
453                 SIMIX_simcall_name(*res));
454       return res;
455     }
456   }
457   return nullptr;
458 }
459
460 std::list<transition_detail_t> Api::get_enabled_transitions(simgrid::mc::State* state) const
461 {
462   std::list<transition_detail_t> tr_list{};
463
464   for (auto& actor : mc_model_checker->get_remote_process().actors()) {
465     auto actor_pid  = actor.copy.get_buffer()->get_pid();
466     auto actor_impl = actor.copy.get_buffer();
467
468     // Only consider the actors that were marked as interleaving by the checker algorithm
469     if (not state->actor_states_[actor_pid].is_todo())
470       continue;
471     // Not executable in the application
472     if (not simgrid::mc::actor_is_enabled(actor_impl))
473       continue;
474
475     auto transition       = std::make_unique<s_transition_detail>();
476     Simcall simcall_call  = actor_impl->simcall_.call_;
477     smx_simcall_t simcall = &actor_impl->simcall_;
478     transition->call_     = simcall_call;
479     switch (simcall_call) {
480       case Simcall::COMM_ISEND:
481       case Simcall::COMM_IRECV:
482         transition->mbox_remote_addr = get_mbox_remote_addr(simcall);
483         transition->comm_remote_addr = get_comm_remote_addr(simcall);
484         break;
485
486       default:
487         break;
488     }
489     tr_list.emplace_back(std::move(transition));
490   }
491
492   return tr_list;
493 }
494
495 std::string Api::request_to_string(smx_simcall_t req, int value) const
496 {
497   xbt_assert(mc_model_checker != nullptr, "Must be called from MCer");
498
499   smx_actor_t issuer = simcall_get_issuer(req);
500
501   if (issuer->simcall_.observer_ != nullptr)
502     return mc_model_checker->simcall_to_string(issuer->get_pid(), value);
503   else
504     return "[" + get_actor_string(issuer) + "] " + SIMIX_simcall_name(*req) + "(unknown?)";
505 }
506
507 std::string Api::request_get_dot_output(smx_simcall_t req, int value) const
508 {
509   if (req->observer_ != nullptr) {
510     const smx_actor_t issuer = simcall_get_issuer(req);
511     const char* color        = get_color(issuer->get_pid() - 1);
512     return "label = \"" + mc_model_checker->simcall_dot_label(issuer->get_pid(), value) + "\", color = " + color +
513            ", fontcolor = " + color;
514   } else
515     return "UNIMPLEMENTED";
516 }
517
518 #if HAVE_SMPI
519 int Api::get_smpi_request_tag(smx_simcall_t const& simcall, simgrid::simix::Simcall type) const
520 {
521   void* simcall_data = nullptr;
522   if (type == Simcall::COMM_ISEND)
523     simcall_data = simcall_comm_isend__get__data(simcall);
524   else if (type == Simcall::COMM_IRECV)
525     simcall_data = simcall_comm_irecv__get__data(simcall);
526   Remote<simgrid::smpi::Request> mpi_request;
527   mc_model_checker->get_remote_process().read(mpi_request, remote(static_cast<smpi::Request*>(simcall_data)));
528   return mpi_request.get_buffer()->tag();
529 }
530 #endif
531
532 void Api::restore_state(std::shared_ptr<simgrid::mc::Snapshot> system_state) const
533 {
534   system_state->restore(&mc_model_checker->get_remote_process());
535 }
536
537 void Api::log_state() const
538 {
539   session_singleton->log_state();
540 }
541
542 bool Api::snapshot_equal(const Snapshot* s1, const Snapshot* s2) const
543 {
544   return simgrid::mc::snapshot_equal(s1, s2);
545 }
546
547 simgrid::mc::Snapshot* Api::take_snapshot(int num_state) const
548 {
549   auto snapshot = new simgrid::mc::Snapshot(num_state);
550   return snapshot;
551 }
552
553 void Api::s_close() const
554 {
555   session_singleton->close();
556 }
557
558 RemotePtr<simgrid::kernel::actor::SimcallObserver> Api::execute(Transition& transition, smx_simcall_t simcall) const
559 {
560   /* FIXME: once all simcalls have observers, kill the simcall parameter and use mc_model_checker->simcall_to_string() */
561   transition.textual = request_to_string(simcall, transition.times_considered_);
562   return session_singleton->execute(transition);
563 }
564
565 void Api::automaton_load(const char* file) const
566 {
567   MC_automaton_load(file);
568 }
569
570 std::vector<int> Api::automaton_propositional_symbol_evaluate() const
571 {
572   unsigned int cursor = 0;
573   std::vector<int> values;
574   xbt_automaton_propositional_symbol_t ps = nullptr;
575   xbt_dynar_foreach (mc::property_automaton->propositional_symbols, cursor, ps)
576     values.push_back(xbt_automaton_propositional_symbol_evaluate(ps));
577   return values;
578 }
579
580 std::vector<xbt_automaton_state_t> Api::get_automaton_state() const
581 {
582   std::vector<xbt_automaton_state_t> automaton_stack;
583   unsigned int cursor = 0;
584   xbt_automaton_state_t automaton_state;
585   xbt_dynar_foreach (mc::property_automaton->states, cursor, automaton_state)
586     if (automaton_state->type == -1)
587       automaton_stack.push_back(automaton_state);
588   return automaton_stack;
589 }
590
591 int Api::compare_automaton_exp_label(const xbt_automaton_exp_label* l) const
592 {
593   unsigned int cursor                    = 0;
594   xbt_automaton_propositional_symbol_t p = nullptr;
595   xbt_dynar_foreach (simgrid::mc::property_automaton->propositional_symbols, cursor, p) {
596     if (std::strcmp(xbt_automaton_propositional_symbol_get_name(p), l->u.predicat) == 0)
597       return cursor;
598   }
599   return -1;
600 }
601
602 void Api::set_property_automaton(xbt_automaton_state_t const& automaton_state) const
603 {
604   mc::property_automaton->current_state = automaton_state;
605 }
606
607 xbt_automaton_exp_label_t Api::get_automaton_transition_label(xbt_dynar_t const& dynar, int index) const
608 {
609   const xbt_automaton_transition* transition = xbt_dynar_get_as(dynar, index, xbt_automaton_transition_t);
610   return transition->label;
611 }
612
613 xbt_automaton_state_t Api::get_automaton_transition_dst(xbt_dynar_t const& dynar, int index) const
614 {
615   const xbt_automaton_transition* transition = xbt_dynar_get_as(dynar, index, xbt_automaton_transition_t);
616   return transition->dst;
617 }
618
619 } // namespace mc
620 } // namespace simgrid