From de2555e45b30f59cea6ac189452aee8603125c43 Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Wed, 4 Jun 2025 10:56:37 +0000 Subject: [PATCH] crimson/common/fatal_signal: rework print_backtrace * Move to GENERIC_LOG * Print backtrace in log and in std out * Switch to fmt::format Signed-off-by: Matan Breizman --- src/crimson/common/fatal_signal.cc | 32 ++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/crimson/common/fatal_signal.cc b/src/crimson/common/fatal_signal.cc index f2983769de42d..cab96c13891c9 100644 --- a/src/crimson/common/fatal_signal.cc +++ b/src/crimson/common/fatal_signal.cc @@ -7,13 +7,23 @@ #include #include +// boost is able to translate addresses +// to lines with the following definition. +// Similar to Seastar's seastar-addr2line #define BOOST_STACKTRACE_USE_ADDR2LINE + +// Consider std once C++23 is available #include + #include +#include "crimson/common/log.h" + #include "common/safe_io.h" #include "include/scope_guard.h" +SET_SUBSYS(osd); + FatalSignal::FatalSignal() { install_oneshot_signals_handler(-1)/* max depth same as the default one */); - std::cerr << std::flush; + static_cast(-1)/* max depth same as the default one */))); + + // Print backtrace in log and in std out + GENERIC_ERROR("{}", backtrace); + std::cerr << backtrace << std::flush; + // TODO: dump crash related meta data to $crash_dir // see handle_fatal_signal() } -- 2.39.5