From ddb45d457a6e56461f506cba0add22902ef2c7d7 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 22 Apr 2021 22:45:52 +0200 Subject: [PATCH] Make SIMIX_simcall_name() use the type of observer_ if it exists. It gives more information about the kind of simcall being involved, since most simcalls are nowadays of type RUN_KERNEL or RUN_BLOCKING. --- src/kernel/actor/ActorImpl.cpp | 3 +-- src/mc/api.cpp | 2 +- src/mc/checker/SafetyChecker.cpp | 9 ++++----- src/simix/libsmx.cpp | 18 +++++++++++++++--- src/simix/popping_bodies.cpp | 3 +-- src/simix/popping_generated.cpp | 2 +- src/simix/popping_private.hpp | 2 +- src/simix/simcalls.py | 5 ++--- src/simix/smx_global.cpp | 3 ++- 9 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index fe224fc596..bd04da8f0f 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -446,8 +446,7 @@ void ActorImpl::throw_exception(std::exception_ptr e) void ActorImpl::simcall_answer() { if (this != simix_global->maestro_) { - XBT_DEBUG("Answer simcall %s (%d) issued by %s (%p)", SIMIX_simcall_name(simcall_.call_), (int)simcall_.call_, - get_cname(), this); + XBT_DEBUG("Answer simcall %s issued by %s (%p)", SIMIX_simcall_name(simcall_), get_cname(), this); xbt_assert(simcall_.call_ != simix::Simcall::NONE); simcall_.call_ = simix::Simcall::NONE; xbt_assert(not XBT_LOG_ISENABLED(simix_process, xbt_log_priority_debug) || diff --git a/src/mc/api.cpp b/src/mc/api.cpp index 0fe5c332bf..512c221707 100644 --- a/src/mc/api.cpp +++ b/src/mc/api.cpp @@ -828,7 +828,7 @@ std::string Api::request_to_string(smx_simcall_t req, int value) const break; default: - type = SIMIX_simcall_name(req->call_); + type = SIMIX_simcall_name(*req); args = "??"; break; } diff --git a/src/mc/checker/SafetyChecker.cpp b/src/mc/checker/SafetyChecker.cpp index 4943ad2561..ac21b5fc42 100644 --- a/src/mc/checker/SafetyChecker.cpp +++ b/src/mc/checker/SafetyChecker.cpp @@ -186,13 +186,12 @@ void SafetyChecker::backtrack() std::unique_ptr state = std::move(stack_.back()); stack_.pop_back(); if (reductionMode_ == ReductionMode::dpor) { - auto call = state->executed_req_.call_; kernel::actor::ActorImpl* issuer = api::get().simcall_get_issuer(&state->executed_req_); for (auto i = stack_.rbegin(); i != stack_.rend(); ++i) { State* prev_state = i->get(); if (state->executed_req_.issuer_ == prev_state->executed_req_.issuer_) { - XBT_DEBUG("Simcall %s and %s with same issuer", SIMIX_simcall_name(call), - SIMIX_simcall_name(prev_state->executed_req_.call_)); + XBT_DEBUG("Simcall %s and %s with same issuer", SIMIX_simcall_name(state->executed_req_), + SIMIX_simcall_name(prev_state->executed_req_)); break; } else if (api::get().simcall_check_dependency(&state->internal_req_, &prev_state->internal_req_)) { if (XBT_LOG_ISENABLED(mc_safety, xbt_log_priority_debug)) { @@ -213,8 +212,8 @@ void SafetyChecker::backtrack() } else { const kernel::actor::ActorImpl* previous_issuer = api::get().simcall_get_issuer(&prev_state->executed_req_); XBT_DEBUG("Simcall %s, process %ld (state %d) and simcall %s, process %ld (state %d) are independent", - SIMIX_simcall_name(call), issuer->get_pid(), state->num_, - SIMIX_simcall_name(prev_state->executed_req_.call_), previous_issuer->get_pid(), prev_state->num_); + SIMIX_simcall_name(state->executed_req_), issuer->get_pid(), state->num_, + SIMIX_simcall_name(prev_state->executed_req_), previous_issuer->get_pid(), prev_state->num_); } } } diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 8203c2fd5e..9bec9a4df4 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -25,6 +25,9 @@ #include "popping_bodies.cpp" +#include +#include + /** * @ingroup simix_host_management * @brief Waits for the completion of an execution synchro and destroy it. @@ -369,9 +372,18 @@ int simcall_mc_random(int min, int max) // XBT_ATTRIB_DEPRECATD_v331 /* ************************************************************************** */ /** @brief returns a printable string representing a simcall */ -const char* SIMIX_simcall_name(Simcall kind) -{ - return simcall_names[static_cast(kind)]; +const char* SIMIX_simcall_name(const s_smx_simcall& simcall) +{ + if (simcall.observer_ != nullptr) { + static std::string name; + name = boost::core::demangle(typeid(*simcall.observer_).name()); + const char* cname = name.c_str(); + if (name.rfind("simgrid::kernel::", 0) == 0) + cname += 17; // strip prefix "simgrid::kernel::" + return cname; + } else { + return simcall_names[static_cast(simcall.call_)]; + } } namespace simgrid { diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 1bcba0a0d5..6948f46442 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -32,8 +32,7 @@ inline static R simcall(Simcall call, T const&... t) smx_actor_t self = SIMIX_process_self(); simgrid::simix::marshal(&self->simcall_, call, t...); if (self != simix_global->maestro_) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->get_cname(), SIMIX_simcall_name(self->simcall_.call_), - (int)self->simcall_.call_); + XBT_DEBUG("Yield process '%s' on simcall %s", self->get_cname(), SIMIX_simcall_name(self->simcall_)); self->yield(); } else { self->simcall_handle(0); diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 3a736cb6c0..9b9a7b5d8f 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -48,7 +48,7 @@ constexpr std::array simcall_names{{ */ void simgrid::kernel::actor::ActorImpl::simcall_handle(int times_considered) { - XBT_DEBUG("Handling simcall %p: %s", &simcall_, SIMIX_simcall_name(simcall_.call_)); + XBT_DEBUG("Handling simcall %p: %s", &simcall_, SIMIX_simcall_name(simcall_)); simcall_.mc_value_ = times_considered; if (simcall_.observer_ != nullptr) simcall_.observer_->prepare(times_considered); diff --git a/src/simix/popping_private.hpp b/src/simix/popping_private.hpp index 8b54a2c71a..745d0e614b 100644 --- a/src/simix/popping_private.hpp +++ b/src/simix/popping_private.hpp @@ -56,7 +56,7 @@ struct s_smx_simcall { /******************************** General *************************************/ -XBT_PRIVATE const char* SIMIX_simcall_name(simgrid::simix::Simcall kind); +XBT_PRIVATE const char* SIMIX_simcall_name(const s_smx_simcall& simcall); XBT_PRIVATE void SIMIX_run_kernel(std::function const* code); XBT_PRIVATE void SIMIX_run_blocking(std::function const* code); diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index 9872c193d2..2ed634dc3f 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -336,7 +336,7 @@ if __name__ == '__main__': fd.write(' */\n') fd.write('void simgrid::kernel::actor::ActorImpl::simcall_handle(int times_considered)\n') fd.write('{\n') - fd.write(' XBT_DEBUG("Handling simcall %p: %s", &simcall_, SIMIX_simcall_name(simcall_.call_));\n') + fd.write(' XBT_DEBUG("Handling simcall %p: %s", &simcall_, SIMIX_simcall_name(simcall_));\n') fd.write(' simcall_.mc_value_ = times_considered;\n') fd.write(' if (simcall_.observer_ != nullptr)\n') fd.write(' simcall_.observer_->prepare(times_considered);\n') @@ -381,8 +381,7 @@ inline static R simcall(Simcall call, T const&... t) smx_actor_t self = SIMIX_process_self(); simgrid::simix::marshal(&self->simcall_, call, t...); if (self != simix_global->maestro_) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->get_cname(), SIMIX_simcall_name(self->simcall_.call_), - (int)self->simcall_.call_); + XBT_DEBUG("Yield process '%s' on simcall %s", self->get_cname(), SIMIX_simcall_name(self->simcall_)); self->yield(); } else { self->simcall_handle(0); diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index cf91c83f80..b5f5b98804 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -263,7 +263,8 @@ void Global::display_all_actor_status() const (xbt_log_no_loc ? (size_t)0xDEADBEEF : (size_t)actor->waiting_synchro_.get()), actor->waiting_synchro_->get_cname(), (int)actor->waiting_synchro_->state_); } else { - XBT_INFO("Actor %ld (%s@%s) simcall %s", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname(), SIMIX_simcall_name(actor->simcall_.call_)); + XBT_INFO("Actor %ld (%s@%s) simcall %s", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname(), + SIMIX_simcall_name(actor->simcall_)); } } } -- 2.20.1