From 96023dbffd3fadb8ddf87763c530ddbc659fd441 Mon Sep 17 00:00:00 2001 From: ablangy <32962735+ablangy@users.noreply.github.com> Date: Fri, 17 Jan 2025 22:43:47 +0100 Subject: [PATCH] Issue #541 Linux: access to siginfo_t (#542) By using some informations located in siginfo_t for tracing, it remain accessible to be inspected by debugger even if the code compiled with optimisation flags (typically -O2). --- src/crashhandler_unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crashhandler_unix.cpp b/src/crashhandler_unix.cpp index 924c21bf..9c40449d 100644 --- a/src/crashhandler_unix.cpp +++ b/src/crashhandler_unix.cpp @@ -59,7 +59,7 @@ namespace { // Dump of stack,. then exit through g3log background worker // ALL thanks to this thread at StackOverflow. Pretty much borrowed from: // Ref: http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes - void signalHandler(int signal_number, siginfo_t* /*info*/, void* /*unused_context*/) { + void signalHandler(int signal_number, siginfo_t* info, void* /*unused_context*/) { using namespace g3::internal; @@ -76,7 +76,7 @@ namespace { const auto fatal_reason = exitReasonName(g3::internal::FATAL_SIGNAL, signal_number); fatal_stream << "Received fatal signal: " << fatal_reason; fatal_stream << "(" << signal_number << ")\tPID: " << getpid() << std::endl; - fatal_stream << "\n***** SIGNAL " << fatal_reason << "(" << signal_number << ")" << std::endl; + fatal_stream << "\n***** SIGNAL " << fatal_reason << "(signo= " << signal_number << " si_errno= " << info->si_errno << " si_code = " << info->si_code << ")" << std::endl; LogCapture trigger(FATAL_SIGNAL, static_cast(signal_number), dump.c_str()); trigger.stream() << fatal_stream.str(); } // message sent to g3LogWorker