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.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2021-08-02 12:29:57 +02:00 committed by Noel Grandin
parent 914762f837
commit 0e883d6dbe

View file

@ -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.