sal/cppunittester/cppunittester.cxx |   13 +++++++++++++
 1 file changed, 13 insertions(+)

New commits:
commit 0e883d6dbee8d72257f77605ae0c8a1d5bfbf044
Author:     Noel Grandin <n...@peralex.com>
AuthorDate: Mon Aug 2 12:29:57 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Aug 2 13:52:15 2021 +0200

    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 <noel.gran...@collabora.co.uk>

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 <sal/backtrace.hxx>
+#include <signal.h>
 #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<sal::BacktraceState> 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.

Reply via email to