Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mc: rename Inspector to Observer
[simgrid.git] / src / mc / checker / SimcallObserver.cpp
1 /* Copyright (c) 2019-2021. 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 "src/mc/checker/SimcallObserver.hpp"
7 #include "simgrid/s4u/Host.hpp"
8 #include "src/kernel/actor/ActorImpl.hpp"
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_observer, mc, "Logging specific to MC simcall observation");
11
12 namespace simgrid {
13 namespace mc {
14
15 std::string SimcallObserver::to_string(int /*time_considered*/) const
16 {
17   return simgrid::xbt::string_printf("[(%ld)%s (%s)] ", issuer_->get_pid(), issuer_->get_host()->get_cname(),
18                                      issuer_->get_cname());
19 }
20
21 std::string SimcallObserver::dot_label() const
22 {
23   if (issuer_->get_host())
24     return xbt::string_printf("[(%ld)%s] ", issuer_->get_pid(), issuer_->get_cname());
25   return xbt::string_printf("[(%ld)] ", issuer_->get_pid());
26 }
27
28 std::string RandomSimcall::to_string(int time_considered) const
29 {
30   return SimcallObserver::to_string(time_considered) + "MC_RANDOM(" + std::to_string(time_considered) + ")";
31 }
32
33 std::string RandomSimcall::dot_label() const
34 {
35   return SimcallObserver::dot_label() + "MC_RANDOM(" + std::to_string(next_value_) + ")";
36 }
37
38 void RandomSimcall::prepare(int times_considered)
39 {
40   next_value_ = min_ + times_considered;
41   XBT_DEBUG("MC_RANDOM(%d, %d) will return %d after %d times", min_, max_, next_value_, times_considered);
42 }
43
44 int RandomSimcall::get_max_consider() const
45 {
46   return max_ - min_ + 1;
47 }
48
49 int RandomSimcall::get_value() const
50 {
51   return next_value_;
52 }
53
54 std::string MutexUnlockSimcall::to_string(int time_considered) const
55 {
56   return SimcallObserver::to_string(time_considered) + "Mutex UNLOCK";
57 }
58
59 std::string MutexUnlockSimcall::dot_label() const
60 {
61   return SimcallObserver::dot_label() + "Mutex UNLOCK";
62 }
63
64 } // namespace mc
65 } // namespace simgrid