Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
219547cee548be3826889103949c5f0e5f30aade
[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   // Fetch the data of the request and translate it:
98   state->internal_req_ = *req;
99   state->internal_req_.mc_value_ = state->transition_.times_considered_;
100
101   return req;
102 }
103
104 kernel::activity::CommImpl* Api::get_comm_or_nullptr(smx_simcall_t const r) const
105 {
106   if (auto wait = dynamic_cast<kernel::actor::ActivityWaitSimcall*>(r->observer_))
107     return static_cast<kernel::activity::CommImpl*>(wait->get_activity());
108   if (auto test = dynamic_cast<kernel::actor::ActivityTestSimcall*>(r->observer_))
109     return static_cast<kernel::activity::CommImpl*>(test->get_activity());
110   return nullptr;
111 }
112
113 /** Statically "upcast" a s_smx_actor_t into an ActorInformation
114  *
115  *  This gets 'actorInfo' from '&actorInfo->copy'. It upcasts in the
116  *  sense that we could achieve the same thing by having ActorInformation
117  *  inherit from s_smx_actor_t but we don't really want to do that.
118  */
119 simgrid::mc::ActorInformation* Api::actor_info_cast(smx_actor_t actor) const
120 {
121   simgrid::mc::ActorInformation temp;
122   std::size_t offset = (char*)temp.copy.get_buffer() - (char*)&temp;
123
124   auto* process_info = reinterpret_cast<simgrid::mc::ActorInformation*>((char*)actor - offset);
125   return process_info;
126 }
127
128 bool Api::simcall_check_dependency(smx_simcall_t req1, smx_simcall_t req2) const
129 {
130   // FIXME: this should be removed now
131   /* Make sure that req1 and req2 are in alphabetic order */
132   if (req1->call_ > req2->call_) {
133     auto temp = req1;
134     req1      = req2;
135     req2      = temp;
136   }
137   return true;
138 }
139
140 xbt::string const& Api::get_actor_host_name(smx_actor_t actor) const
141 {
142   if (mc_model_checker == nullptr)
143     return actor->get_host()->get_name();
144
145   const simgrid::mc::RemoteProcess* process = &mc_model_checker->get_remote_process();
146
147   // Read the simgrid::xbt::string in the MCed process:
148   simgrid::mc::ActorInformation* info = actor_info_cast(actor);
149
150   if (not info->hostname) {
151     Remote<s4u::Host> temp_host = process->read(remote(actor->get_host()));
152     auto remote_string_address  = remote(&xbt::string::to_string_data(temp_host.get_buffer()->get_impl()->get_name()));
153     simgrid::xbt::string_data remote_string = process->read(remote_string_address);
154     std::vector<char> hostname(remote_string.len + 1);
155     // no need to read the terminating null byte, and thus hostname[remote_string.len] is guaranteed to be '\0'
156     process->read_bytes(hostname.data(), remote_string.len, remote(remote_string.data));
157     info->hostname = &mc_model_checker->get_host_name(hostname.data());
158   }
159   return *info->hostname;
160 }
161
162 xbt::string const& Api::get_actor_name(smx_actor_t actor) const
163 {
164   if (mc_model_checker == nullptr)
165     return actor->get_name();
166
167   simgrid::mc::ActorInformation* info = actor_info_cast(actor);
168   if (info->name.empty()) {
169     const simgrid::mc::RemoteProcess* process = &mc_model_checker->get_remote_process();
170
171     simgrid::xbt::string_data string_data = simgrid::xbt::string::to_string_data(actor->name_);
172     info->name = process->read_string(remote(string_data.data), string_data.len);
173   }
174   return info->name;
175 }
176
177 std::string Api::get_actor_string(smx_actor_t actor) const
178 {
179   std::string res;
180   if (actor) {
181     res = "(" + std::to_string(actor->get_pid()) + ")";
182     if (actor->get_host())
183       res += std::string(get_actor_host_name(actor)) + " (" + std::string(get_actor_name(actor)) + ")";
184     else
185       res += get_actor_name(actor);
186   } else
187     res = "(0) ()";
188   return res;
189 }
190
191 std::string Api::get_actor_dot_label(smx_actor_t actor) const
192 {
193   std::string res = "(" + std::to_string(actor->get_pid()) + ")";
194   if (actor->get_host())
195     res += get_actor_host_name(actor);
196   return res;
197 }
198
199 simgrid::mc::Checker* Api::initialize(char** argv, simgrid::mc::CheckerAlgorithm algo) const
200 {
201   auto session = new simgrid::mc::Session([argv] {
202     int i = 1;
203     while (argv[i] != nullptr && argv[i][0] == '-')
204       i++;
205     xbt_assert(argv[i] != nullptr,
206                "Unable to find a binary to exec on the command line. Did you only pass config flags?");
207     execvp(argv[i], argv + i);
208     xbt_die("The model-checked process failed to exec(%s): %s", argv[i], strerror(errno));
209   });
210
211   simgrid::mc::Checker* checker;
212   switch (algo) {
213     case CheckerAlgorithm::CommDeterminism:
214       checker = simgrid::mc::create_communication_determinism_checker(session);
215       break;
216
217     case CheckerAlgorithm::UDPOR:
218       checker = simgrid::mc::create_udpor_checker(session);
219       break;
220
221     case CheckerAlgorithm::Safety:
222       checker = simgrid::mc::create_safety_checker(session);
223       break;
224
225     case CheckerAlgorithm::Liveness:
226       checker = simgrid::mc::create_liveness_checker(session);
227       break;
228
229     default:
230       THROW_IMPOSSIBLE;
231   }
232
233   // FIXME: session and checker are never deleted
234   simgrid::mc::session_singleton = session;
235   mc_model_checker->setChecker(checker);
236   return checker;
237 }
238
239 std::vector<simgrid::mc::ActorInformation>& Api::get_actors() const
240 {
241   return mc_model_checker->get_remote_process().actors();
242 }
243
244 unsigned long Api::get_maxpid() const
245 {
246   return mc_model_checker->get_remote_process().get_maxpid();
247 }
248
249 int Api::get_actors_size() const
250 {
251   return mc_model_checker->get_remote_process().actors().size();
252 }
253
254 RemotePtr<kernel::activity::CommImpl> Api::get_comm_isend_raw_addr(smx_simcall_t request) const
255 {
256   return remote(static_cast<kernel::activity::CommImpl*>(simcall_comm_isend__getraw__result(request)));
257 }
258
259 RemotePtr<kernel::activity::CommImpl> Api::get_comm_waitany_raw_addr(smx_simcall_t request, int value) const
260 {
261   auto addr      = simcall_comm_waitany__getraw__comms(request) + value;
262   auto comm_addr = mc_model_checker->get_remote_process().read(remote(addr));
263   return RemotePtr<kernel::activity::CommImpl>(static_cast<kernel::activity::CommImpl*>(comm_addr));
264 }
265
266 std::string Api::get_pattern_comm_rdv(RemotePtr<kernel::activity::CommImpl> const& addr) const
267 {
268   Remote<kernel::activity::CommImpl> temp_activity;
269   mc_model_checker->get_remote_process().read(temp_activity, addr);
270   const kernel::activity::CommImpl* activity = temp_activity.get_buffer();
271
272   char* remote_name = mc_model_checker->get_remote_process().read<char*>(RemotePtr<char*>(
273       (uint64_t)(activity->get_mailbox() ? &activity->get_mailbox()->get_name() : &activity->mbox_cpy->get_name())));
274   auto rdv          = mc_model_checker->get_remote_process().read_string(RemotePtr<char>(remote_name));
275   return rdv;
276 }
277
278 unsigned long Api::get_pattern_comm_src_proc(RemotePtr<kernel::activity::CommImpl> const& addr) const
279 {
280   Remote<kernel::activity::CommImpl> temp_activity;
281   mc_model_checker->get_remote_process().read(temp_activity, addr);
282   const kernel::activity::CommImpl* activity = temp_activity.get_buffer();
283   auto src_proc =
284       mc_model_checker->get_remote_process().resolve_actor(mc::remote(activity->src_actor_.get()))->get_pid();
285   return src_proc;
286 }
287
288 unsigned long Api::get_pattern_comm_dst_proc(RemotePtr<kernel::activity::CommImpl> const& addr) const
289 {
290   Remote<kernel::activity::CommImpl> temp_activity;
291   mc_model_checker->get_remote_process().read(temp_activity, addr);
292   const kernel::activity::CommImpl* activity = temp_activity.get_buffer();
293   auto src_proc =
294       mc_model_checker->get_remote_process().resolve_actor(mc::remote(activity->dst_actor_.get()))->get_pid();
295   return src_proc;
296 }
297
298 std::vector<char> Api::get_pattern_comm_data(RemotePtr<kernel::activity::CommImpl> const& addr) const
299 {
300   simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
301   mc_model_checker->get_remote_process().read(temp_comm, addr);
302   const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
303
304   std::vector<char> buffer{};
305   if (comm->src_buff_ != nullptr) {
306     buffer.resize(comm->src_buff_size_);
307     mc_model_checker->get_remote_process().read_bytes(buffer.data(), buffer.size(), remote(comm->src_buff_));
308   }
309   return buffer;
310 }
311
312 #if HAVE_SMPI
313 bool Api::check_send_request_detached(smx_simcall_t const& simcall) const
314 {
315   Remote<simgrid::smpi::Request> mpi_request;
316   mc_model_checker->get_remote_process().read(
317       mpi_request, remote(static_cast<smpi::Request*>(simcall_comm_isend__get__data(simcall))));
318   return mpi_request.get_buffer()->detached();
319 }
320 #endif
321
322 smx_actor_t Api::get_src_actor(RemotePtr<kernel::activity::CommImpl> const& comm_addr) const
323 {
324   simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
325   mc_model_checker->get_remote_process().read(temp_comm, comm_addr);
326   const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
327
328   auto src_proc = mc_model_checker->get_remote_process().resolve_actor(simgrid::mc::remote(comm->src_actor_.get()));
329   return src_proc;
330 }
331
332 smx_actor_t Api::get_dst_actor(RemotePtr<kernel::activity::CommImpl> const& comm_addr) const
333 {
334   simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
335   mc_model_checker->get_remote_process().read(temp_comm, comm_addr);
336   const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
337
338   auto dst_proc = mc_model_checker->get_remote_process().resolve_actor(simgrid::mc::remote(comm->dst_actor_.get()));
339   return dst_proc;
340 }
341
342 std::size_t Api::get_remote_heap_bytes() const
343 {
344   RemoteProcess& process    = mc_model_checker->get_remote_process();
345   auto heap_bytes_used      = mmalloc_get_bytes_used_remote(process.get_heap()->heaplimit, process.get_malloc_info());
346   return heap_bytes_used;
347 }
348
349 void Api::mc_inc_visited_states() const
350 {
351   mc_model_checker->visited_states++;
352 }
353
354 void Api::mc_inc_executed_trans() const
355 {
356   mc_model_checker->executed_transitions++;
357 }
358
359 unsigned long Api::mc_get_visited_states() const
360 {
361   return mc_model_checker->visited_states;
362 }
363
364 unsigned long Api::mc_get_executed_trans() const
365 {
366   return mc_model_checker->executed_transitions;
367 }
368
369 void Api::mc_check_deadlock() const
370 {
371   if (mc_model_checker->checkDeadlock()) {
372     XBT_CINFO(mc_global, "**************************");
373     XBT_CINFO(mc_global, "*** DEADLOCK DETECTED ***");
374     XBT_CINFO(mc_global, "**************************");
375     XBT_CINFO(mc_global, "Counter-example execution trace:");
376     for (auto const& s : mc_model_checker->getChecker()->get_textual_trace())
377       XBT_CINFO(mc_global, "  %s", s.c_str());
378     simgrid::mc::dumpRecordPath();
379     simgrid::mc::session_singleton->log_state();
380     throw DeadlockError();
381   }
382 }
383
384 /** Get the issuer of a simcall (`req->issuer`)
385  *
386  *  In split-process mode, it does the black magic necessary to get an address
387  *  of a (shallow) copy of the data structure the issuer SIMIX actor in the local
388  *  address space.
389  *
390  *  @param process the MCed process
391  *  @param req     the simcall (copied in the local process)
392  */
393 smx_actor_t Api::simcall_get_issuer(s_smx_simcall const* req) const
394 {
395   xbt_assert(mc_model_checker != nullptr);
396
397   // This is the address of the smx_actor in the MCed process:
398   auto address = simgrid::mc::remote(req->issuer_);
399
400   // Lookup by address:
401   for (auto& actor : mc_model_checker->get_remote_process().actors())
402     if (actor.address == address)
403       return actor.copy.get_buffer();
404   for (auto& actor : mc_model_checker->get_remote_process().dead_actors())
405     if (actor.address == address)
406       return actor.copy.get_buffer();
407
408   xbt_die("Issuer not found");
409 }
410
411 RemotePtr<kernel::activity::MailboxImpl> Api::get_mbox_remote_addr(smx_simcall_t const req) const
412 {
413   if (req->call_ == Simcall::COMM_ISEND)
414     return remote(simcall_comm_isend__get__mbox(req));
415   if (req->call_ == Simcall::COMM_IRECV)
416     return remote(simcall_comm_irecv__get__mbox(req));
417   THROW_IMPOSSIBLE;
418 }
419
420 RemotePtr<kernel::activity::ActivityImpl> Api::get_comm_remote_addr(smx_simcall_t const req) const
421 {
422   if (req->call_ == Simcall::COMM_ISEND)
423     return remote(simcall_comm_isend__getraw__result(req));
424   if (req->call_ == Simcall::COMM_IRECV)
425     return remote(simcall_comm_irecv__getraw__result(req));
426   THROW_IMPOSSIBLE;
427 }
428
429 void Api::handle_simcall(Transition const& transition) const
430 {
431   mc_model_checker->handle_simcall(transition);
432 }
433
434 void Api::mc_wait_for_requests() const
435 {
436   mc_model_checker->wait_for_requests();
437 }
438
439 void Api::mc_exit(int status) const
440 {
441   mc_model_checker->exit(status);
442 }
443
444 void Api::dump_record_path() const
445 {
446   simgrid::mc::dumpRecordPath();
447 }
448
449 smx_simcall_t Api::mc_state_choose_request(simgrid::mc::State* state) const
450 {
451   RemoteProcess& process = mc_model_checker->get_remote_process();
452   XBT_DEBUG("Search for an actor to run. %zu actors to consider", process.actors().size());
453   for (auto& actor : process.actors()) {
454     /* Only consider the actors that were marked as interleaving by the checker algorithm */
455     if (not state->actor_states_[actor.copy.get_buffer()->get_pid()].is_todo())
456       continue;
457
458     smx_simcall_t res = MC_state_choose_request_for_process(process, state, actor.copy.get_buffer());
459     if (res) {
460       XBT_DEBUG("Let's run actor %ld, going for transition %s", actor.copy.get_buffer()->get_pid(),
461                 SIMIX_simcall_name(*res));
462       return res;
463     }
464   }
465   return nullptr;
466 }
467
468 std::list<transition_detail_t> Api::get_enabled_transitions(simgrid::mc::State* state) const
469 {
470   std::list<transition_detail_t> tr_list{};
471
472   for (auto& actor : mc_model_checker->get_remote_process().actors()) {
473     auto actor_pid  = actor.copy.get_buffer()->get_pid();
474     auto actor_impl = actor.copy.get_buffer();
475
476     // Only consider the actors that were marked as interleaving by the checker algorithm
477     if (not state->actor_states_[actor_pid].is_todo())
478       continue;
479     // Not executable in the application
480     if (not simgrid::mc::actor_is_enabled(actor_impl))
481       continue;
482
483     auto transition       = std::make_unique<s_transition_detail>();
484     Simcall simcall_call  = actor_impl->simcall_.call_;
485     smx_simcall_t simcall = &actor_impl->simcall_;
486     transition->call_     = simcall_call;
487     switch (simcall_call) {
488       case Simcall::COMM_ISEND:
489       case Simcall::COMM_IRECV:
490         transition->mbox_remote_addr = get_mbox_remote_addr(simcall);
491         transition->comm_remote_addr = get_comm_remote_addr(simcall);
492         break;
493
494       default:
495         break;
496     }
497     tr_list.emplace_back(std::move(transition));
498   }
499
500   return tr_list;
501 }
502
503 std::string Api::request_to_string(smx_simcall_t req, int value) const
504 {
505   xbt_assert(mc_model_checker != nullptr, "Must be called from MCer");
506
507   smx_actor_t issuer = simcall_get_issuer(req);
508
509   if (issuer->simcall_.observer_ != nullptr)
510     return mc_model_checker->simcall_to_string(issuer->get_pid(), value);
511   else
512     return "[" + get_actor_string(issuer) + "] " + SIMIX_simcall_name(*req) + "(unknown?)";
513 }
514
515 std::string Api::request_get_dot_output(smx_simcall_t req, int value) const
516 {
517   if (req->observer_ != nullptr) {
518     const smx_actor_t issuer = simcall_get_issuer(req);
519     const char* color        = get_color(issuer->get_pid() - 1);
520     return "label = \"" + mc_model_checker->simcall_dot_label(issuer->get_pid(), value) + "\", color = " + color +
521            ", fontcolor = " + color;
522   } else
523     return "UNIMPLEMENTED";
524 }
525
526 #if HAVE_SMPI
527 int Api::get_smpi_request_tag(smx_simcall_t const& simcall, simgrid::simix::Simcall type) const
528 {
529   void* simcall_data = nullptr;
530   if (type == Simcall::COMM_ISEND)
531     simcall_data = simcall_comm_isend__get__data(simcall);
532   else if (type == Simcall::COMM_IRECV)
533     simcall_data = simcall_comm_irecv__get__data(simcall);
534   Remote<simgrid::smpi::Request> mpi_request;
535   mc_model_checker->get_remote_process().read(mpi_request, remote(static_cast<smpi::Request*>(simcall_data)));
536   return mpi_request.get_buffer()->tag();
537 }
538 #endif
539
540 void Api::restore_state(std::shared_ptr<simgrid::mc::Snapshot> system_state) const
541 {
542   system_state->restore(&mc_model_checker->get_remote_process());
543 }
544
545 void Api::log_state() const
546 {
547   session_singleton->log_state();
548 }
549
550 bool Api::snapshot_equal(const Snapshot* s1, const Snapshot* s2) const
551 {
552   return simgrid::mc::snapshot_equal(s1, s2);
553 }
554
555 simgrid::mc::Snapshot* Api::take_snapshot(int num_state) const
556 {
557   auto snapshot = new simgrid::mc::Snapshot(num_state);
558   return snapshot;
559 }
560
561 void Api::s_close() const
562 {
563   session_singleton->close();
564 }
565
566 void Api::execute(Transition& transition, smx_simcall_t simcall) const
567 {
568   /* FIXME: once all simcalls have observers, kill the simcall parameter and use mc_model_checker->simcall_to_string() */
569   transition.textual = request_to_string(simcall, transition.times_considered_);
570   session_singleton->execute(transition);
571 }
572
573 void Api::automaton_load(const char* file) const
574 {
575   MC_automaton_load(file);
576 }
577
578 std::vector<int> Api::automaton_propositional_symbol_evaluate() const
579 {
580   unsigned int cursor = 0;
581   std::vector<int> values;
582   xbt_automaton_propositional_symbol_t ps = nullptr;
583   xbt_dynar_foreach (mc::property_automaton->propositional_symbols, cursor, ps)
584     values.push_back(xbt_automaton_propositional_symbol_evaluate(ps));
585   return values;
586 }
587
588 std::vector<xbt_automaton_state_t> Api::get_automaton_state() const
589 {
590   std::vector<xbt_automaton_state_t> automaton_stack;
591   unsigned int cursor = 0;
592   xbt_automaton_state_t automaton_state;
593   xbt_dynar_foreach (mc::property_automaton->states, cursor, automaton_state)
594     if (automaton_state->type == -1)
595       automaton_stack.push_back(automaton_state);
596   return automaton_stack;
597 }
598
599 int Api::compare_automaton_exp_label(const xbt_automaton_exp_label* l) const
600 {
601   unsigned int cursor                    = 0;
602   xbt_automaton_propositional_symbol_t p = nullptr;
603   xbt_dynar_foreach (simgrid::mc::property_automaton->propositional_symbols, cursor, p) {
604     if (std::strcmp(xbt_automaton_propositional_symbol_get_name(p), l->u.predicat) == 0)
605       return cursor;
606   }
607   return -1;
608 }
609
610 void Api::set_property_automaton(xbt_automaton_state_t const& automaton_state) const
611 {
612   mc::property_automaton->current_state = automaton_state;
613 }
614
615 xbt_automaton_exp_label_t Api::get_automaton_transition_label(xbt_dynar_t const& dynar, int index) const
616 {
617   const xbt_automaton_transition* transition = xbt_dynar_get_as(dynar, index, xbt_automaton_transition_t);
618   return transition->label;
619 }
620
621 xbt_automaton_state_t Api::get_automaton_transition_dst(xbt_dynar_t const& dynar, int index) const
622 {
623   const xbt_automaton_transition* transition = xbt_dynar_get_as(dynar, index, xbt_automaton_transition_t);
624   return transition->dst;
625 }
626
627 } // namespace mc
628 } // namespace simgrid