From f863142ca1ffcf37908e0beb8dd4b71eb2a74c86 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 10 Dec 2019 10:03:36 +0100 Subject: [PATCH] SIMIX_display_process_status becomes Global::display_all_actor_status --- include/simgrid/simix.h | 3 +- src/simix/smx_global.cpp | 85 ++++++++++++++++++++------------------- src/simix/smx_private.hpp | 1 + src/surf/HostImpl.cpp | 2 +- 4 files changed, 47 insertions(+), 44 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 8ffb312ae5..9b6ff412a1 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -57,7 +57,8 @@ XBT_ATTRIB_DEPRECATED_v329("Please use simgrid::simix::Timer::next()") XBT_PUBLI XBT_ATTRIB_DEPRECATED_v329("Please use simgrid::simix::Timer::get_date()") XBT_PUBLIC double SIMIX_timer_get_date(smx_timer_t timer); -XBT_PUBLIC void SIMIX_display_process_status(); +XBT_ATTRIB_DEPRECATED_v329("Please use simix_global->display_all_actor_status()") XBT_PUBLIC + void SIMIX_display_process_status(); SG_END_DECL /******************************** Deployment **********************************/ diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index a3fc1e9a15..d951bccf1b 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -43,7 +43,7 @@ XBT_ATTRIB_NORETURN static void inthandler(int) if (simgrid::simix::cfg_verbose_exit) { XBT_INFO("CTRL-C pressed. The current status will be displayed before exit (disable that behavior with option " "'debug/verbose-exit')."); - SIMIX_display_process_status(); + simix_global->display_all_actor_status(); } else { XBT_INFO("CTRL-C pressed, exiting. Hiding the current process status since 'debug/verbose-exit' is set to false."); @@ -220,6 +220,45 @@ void Global::wake_all_waiting_actors() } } +void Global::display_all_actor_status() +{ + XBT_INFO("%lu actors are still running, waiting for something.", process_list.size()); + /* List the actors and their state */ + XBT_INFO("Legend of the following listing: \"Actor (@): \""); + for (auto const& kv : process_list) { + kernel::actor::ActorImpl* actor = kv.second; + + if (actor->waiting_synchro) { + const char* synchro_description = "unknown"; + // we don't care about the Activity type to get its name, use RawImpl + const char* name = boost::static_pointer_cast>( + actor->waiting_synchro) + ->get_cname(); + + if (boost::dynamic_pointer_cast(actor->waiting_synchro) != nullptr) + synchro_description = "execution"; + + if (boost::dynamic_pointer_cast(actor->waiting_synchro) != nullptr) + synchro_description = "communication"; + + if (boost::dynamic_pointer_cast(actor->waiting_synchro) != nullptr) + synchro_description = "sleeping"; + + if (boost::dynamic_pointer_cast(actor->waiting_synchro) != nullptr) + synchro_description = "synchronization"; + + if (boost::dynamic_pointer_cast(actor->waiting_synchro) != nullptr) + synchro_description = "I/O"; + + XBT_INFO("Actor %ld (%s@%s): waiting for %s activity %p (%s) in state %d to finish", actor->get_pid(), + actor->get_cname(), actor->get_host()->get_cname(), synchro_description, actor->waiting_synchro.get(), + name, (int)actor->waiting_synchro->state_); + } else { + XBT_INFO("Actor %ld (%s@%s)", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname()); + } + } +} + config::Flag cfg_breakpoint{ "debug/breakpoint", {"simix/breakpoint"}, "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0}; } // namespace simix @@ -523,7 +562,7 @@ void SIMIX_run() } else { XBT_CRITICAL("Oops! Deadlock or code not perfectly clean."); } - SIMIX_display_process_status(); + simix_global->display_all_actor_status(); simgrid::s4u::Engine::on_deadlock(); xbt_abort(); } @@ -552,47 +591,9 @@ double SIMIX_timer_get_date(smx_timer_t timer) // XBT_ATTRIB_DEPRECATED_v329 return timer ? timer->get_date() : 0; } -void SIMIX_display_process_status() +void SIMIX_display_process_status() // XBT_ATTRIB_DEPRECATED_v329 { - int nbprocess = simix_global->process_list.size(); - - XBT_INFO("%d processes are still running, waiting for something.", nbprocess); - /* List the process and their state */ - XBT_INFO("Legend of the following listing: \"Process (@): \""); - for (auto const& kv : simix_global->process_list) { - simgrid::kernel::actor::ActorImpl* actor = kv.second; - - if (actor->waiting_synchro) { - const char* synchro_description = "unknown"; - // we don't care about the Activity type to get its name, use RawImpl - const char* name = - boost::static_pointer_cast>( - actor->waiting_synchro) - ->get_cname(); - - if (boost::dynamic_pointer_cast(actor->waiting_synchro) != nullptr) - synchro_description = "execution"; - - if (boost::dynamic_pointer_cast(actor->waiting_synchro) != nullptr) - synchro_description = "communication"; - - if (boost::dynamic_pointer_cast(actor->waiting_synchro) != nullptr) - synchro_description = "sleeping"; - - if (boost::dynamic_pointer_cast(actor->waiting_synchro) != nullptr) - synchro_description = "synchronization"; - - if (boost::dynamic_pointer_cast(actor->waiting_synchro) != nullptr) - synchro_description = "I/O"; - - XBT_INFO("Actor %ld (%s@%s): waiting for %s activity %p (%s) in state %d to finish", actor->get_pid(), - actor->get_cname(), actor->get_host()->get_cname(), synchro_description, actor->waiting_synchro.get(), - name, (int)actor->waiting_synchro->state_); - } - else { - XBT_INFO("Actor %ld (%s@%s)", actor->get_pid(), actor->get_cname(), actor->get_host()->get_cname()); - } - } + simix_global->display_all_actor_status(); } int SIMIX_is_maestro() diff --git a/src/simix/smx_private.hpp b/src/simix/smx_private.hpp index 147a1f6d11..8ffc2edc33 100644 --- a/src/simix/smx_private.hpp +++ b/src/simix/smx_private.hpp @@ -31,6 +31,7 @@ public: void empty_trash(); void run_all_actors(); void wake_all_waiting_actors(); + void display_all_actor_status(); smx_context_factory_t context_factory = nullptr; std::vector actors_to_run; diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index e9c5984977..d8d97be06c 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -40,7 +40,7 @@ HostImpl::~HostImpl() for (auto const& actor : actor_list_) msg += "\n\t" + std::string(actor.get_name()); - SIMIX_display_process_status(); + simix_global->display_all_actor_status(); xbt_die("%s", msg.c_str()); } for (auto const& arg : actors_at_boot_) -- 2.20.1