1 /* Copyright (c) 2019-2021. The SimGrid Team. All rights reserved. */
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. */
6 #include "src/mc/checker/SimcallObserver.hpp"
7 #include "simgrid/s4u/Host.hpp"
8 #include "src/kernel/activity/MutexImpl.hpp"
9 #include "src/kernel/actor/ActorImpl.hpp"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_observer, mc, "Logging specific to MC simcall observation");
16 std::string SimcallObserver::to_string(int /*time_considered*/) const
18 return simgrid::xbt::string_printf("[(%ld)%s (%s)] ", issuer_->get_pid(), issuer_->get_host()->get_cname(),
19 issuer_->get_cname());
22 std::string SimcallObserver::dot_label() const
24 if (issuer_->get_host())
25 return xbt::string_printf("[(%ld)%s] ", issuer_->get_pid(), issuer_->get_cname());
26 return xbt::string_printf("[(%ld)] ", issuer_->get_pid());
29 std::string RandomSimcall::to_string(int time_considered) const
31 return SimcallObserver::to_string(time_considered) + "MC_RANDOM(" + std::to_string(time_considered) + ")";
34 std::string RandomSimcall::dot_label() const
36 return SimcallObserver::dot_label() + "MC_RANDOM(" + std::to_string(next_value_) + ")";
39 void RandomSimcall::prepare(int times_considered)
41 next_value_ = min_ + times_considered;
42 XBT_DEBUG("MC_RANDOM(%d, %d) will return %d after %d times", min_, max_, next_value_, times_considered);
45 int RandomSimcall::get_max_consider() const
47 return max_ - min_ + 1;
50 std::string MutexUnlockSimcall::to_string(int time_considered) const
52 return SimcallObserver::to_string(time_considered) + "Mutex UNLOCK";
55 std::string MutexUnlockSimcall::dot_label() const
57 return SimcallObserver::dot_label() + "Mutex UNLOCK";
60 std::string MutexTrylockSimcall::to_string(int time_considered) const
62 std::string res = SimcallObserver::to_string(time_considered) + "Mutex TRYLOCK";
63 res += "(locked = " + std::to_string(mutex_->is_locked());
64 res += ", owner = " + std::to_string(mutex_->get_owner() ? mutex_->get_owner()->get_pid() : -1);
65 res += ", sleeping = n/a)";
69 std::string MutexTrylockSimcall::dot_label() const
71 return SimcallObserver::dot_label() + "Mutex TRYLOCK";
75 } // namespace simgrid