Skip to content

Commit

Permalink
Log alive hpx threads on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pansysk75 committed Sep 1, 2023
1 parent bc993dd commit 0b9c5a6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions libs/core/runtime_local/src/runtime_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@
#include <thread>
#include <utility>

namespace hpx{ namespace detail {
void log_all_runtime_threads()
{
auto rt = hpx::get_runtime_ptr();
if (rt)
{
rt->get_thread_manager().enumerate_threads(
[](hpx::threads::thread_id_type id) -> bool {
hpx::threads::thread_data* td = get_thread_id_data(id);
auto sched = td->get_scheduler_base();
LTM_(debug).format(
"Logging all runtime threads: pool({}), scheduler({}),"
"thread({}), description({}), state({})",
sched->get_parent_pool(), sched, id,
td->get_description(), td->get_state().state());
return true;
});
}
}
}}; // namespace hpx::detail

///////////////////////////////////////////////////////////////////////////////
// Make sure the system gets properly shut down while handling Ctrl-C and other
// system signals
Expand Down Expand Up @@ -91,6 +112,11 @@ namespace hpx {
}
#endif

#if defined(HPX_HAVE_LOGGING)
LRT_(debug).format("Terminating due to system signal({})", reason);
hpx::detail::log_all_runtime_threads();
#endif

std::cerr << "{what}: " << (reason ? reason : "Unknown reason")
<< "\n";
}
Expand Down Expand Up @@ -164,6 +190,11 @@ namespace hpx {
}
#endif

#if defined(HPX_HAVE_LOGGING)
LRT_(debug).format("Terminating due to system signal({})", signum);
hpx::detail::log_all_runtime_threads();
#endif

std::cerr << "{what}: " << (reason ? reason : "Unknown reason")
<< "\n";
}
Expand Down

0 comments on commit 0b9c5a6

Please sign in to comment.