From 0e883d6dbee8d72257f77605ae0c8a1d5bfbf044 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 2 Aug 2021 12:29:57 +0200 Subject: [PATCH] display stack trace on assert for windows jenkins builds Change-Id: I1c23fda56c013eeeaf4ad1099c164d6d1146f68b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119851 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sal/cppunittester/cppunittester.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx index d2727f1cd98e..f5f34c802c83 100644 --- a/sal/cppunittester/cppunittester.cxx +++ b/sal/cppunittester/cppunittester.cxx @@ -25,6 +25,8 @@ #endif #if defined(_WIN32) && defined(_DEBUG) #include "dbghelp.h" +#include +#include #endif #ifdef UNX @@ -576,8 +578,19 @@ LONG WINAPI ExpFilter(EXCEPTION_POINTERS* ex) return EXCEPTION_EXECUTE_HANDLER; } +void AbortSignalHandler(int signal) +{ + if (signal == SIGABRT) { + std::unique_ptr bs = sal::backtrace_get(50); + SAL_WARN("sal", "CAUGHT SIGABRT:\n" << sal::backtrace_to_string(bs.get())); + } +} + SAL_IMPLEMENT_MAIN() { + // catch the kind of signal that is thrown when an assert fails, and log a stacktrace + signal(SIGABRT, AbortSignalHandler); + bool ok = false; // This magic kind of Windows-specific exception handling has to be in its own function // because it cannot be in a function that has objects with destructors.