From e959c4b5ab8614e70611a6a33bef8c172d9d1878 Mon Sep 17 00:00:00 2001 From: Laura Hermanns Date: Sun, 9 Jun 2024 17:15:49 -0400 Subject: [PATCH] [Testbed] Filter only a small set of SEH exceptions on Win32 platform for testbed. We don't want to report floating-point-, debugging-, or other non-critical exceptions with a full callstack. --- tests/Testbed/TestbedMain.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/Testbed/TestbedMain.cpp b/tests/Testbed/TestbedMain.cpp index dcadd54025..68c873f4ee 100644 --- a/tests/Testbed/TestbedMain.cpp +++ b/tests/Testbed/TestbedMain.cpp @@ -183,9 +183,32 @@ namespace LLGL LLGL_EXPORT UTF8String DebugStackTrace(unsigned firstStackFrame = 0, unsigned maxNumStackFrames = 64); }; +// Only report exception with callstack on these critical exceptions. +// There are other exceptions that are of no interest for this testbed, +// such as floating-point exceptions (they can be ignored), debugging exceptions etc. +static bool IsExceptionCodeOfInterest(DWORD exceptionCode) +{ + switch (exceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_DATATYPE_MISALIGNMENT: + case EXCEPTION_ILLEGAL_INSTRUCTION: + case EXCEPTION_IN_PAGE_ERROR: + case EXCEPTION_INT_DIVIDE_BY_ZERO: + case EXCEPTION_INVALID_DISPOSITION: + case EXCEPTION_NONCONTINUABLE_EXCEPTION: + case EXCEPTION_PRIV_INSTRUCTION: + case EXCEPTION_STACK_OVERFLOW: + return true; + default: + return false; + } +} + static LONG WINAPI TestbedVectoredExceptionHandler(EXCEPTION_POINTERS* e) { - if ((e->ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE) == 0) + if (IsExceptionCodeOfInterest(e->ExceptionRecord->ExceptionCode)) { LLGL::UTF8String stackTrace = DebugStackTrace(); ::fprintf(