From 33bff6ccb941147b4ea072e23fbf0f2586b3ece7 Mon Sep 17 00:00:00 2001 From: James Benton Date: Fri, 25 May 2018 18:59:29 +0100 Subject: [PATCH] whb: Fix exception handlers to be globally registered. Was previously only registered for current thread. --- include/coreinit/exception.h | 11 ++++++++++- libraries/libwhb/src/crash.c | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/coreinit/exception.h b/include/coreinit/exception.h index 02658f9..6d17e69 100644 --- a/include/coreinit/exception.h +++ b/include/coreinit/exception.h @@ -14,6 +14,15 @@ extern "C" { typedef BOOL (*OSExceptionCallbackFn)(OSContext *context); +typedef enum OSExceptionMode +{ + OS_EXCEPTION_MODE_SYSTEM = 0, + OS_EXCEPTION_MODE_THREAD = 1, + OS_EXCEPTION_MODE_GLOBAL = 2, + OS_EXCEPTION_MODE_THREAD_ALL_CORES = 3, + OS_EXCEPTION_MODE_GLOBAL_ALL_CORES = 4, +} OSExceptionMode; + typedef enum OSExceptionType { OS_EXCEPTION_TYPE_SYSTEM_RESET = 0, @@ -38,7 +47,7 @@ OSSetExceptionCallback(OSExceptionType exceptionType, OSExceptionCallbackFn callback); OSExceptionCallbackFn -OSSetExceptionCallbackEx(UNKNOWN_ARG, +OSSetExceptionCallbackEx(OSExceptionMode mode, OSExceptionType exceptionType, OSExceptionCallbackFn callback); diff --git a/libraries/libwhb/src/crash.c b/libraries/libwhb/src/crash.c index 85f5b14..fb03fa5 100644 --- a/libraries/libwhb/src/crash.c +++ b/libraries/libwhb/src/crash.c @@ -250,9 +250,9 @@ handleProgram(OSContext *context) BOOL WHBInitCrashHandler() { - OSSetExceptionCallback(OS_EXCEPTION_TYPE_ALIGNMENT, handleAlignment); - OSSetExceptionCallback(OS_EXCEPTION_TYPE_DSI, handleDSI); - OSSetExceptionCallback(OS_EXCEPTION_TYPE_ISI, handleISI); - OSSetExceptionCallback(OS_EXCEPTION_TYPE_PROGRAM, handleProgram); + OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL, OS_EXCEPTION_TYPE_ALIGNMENT, handleAlignment); + OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL, OS_EXCEPTION_TYPE_DSI, handleDSI); + OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL, OS_EXCEPTION_TYPE_ISI, handleISI); + OSSetExceptionCallbackEx(OS_EXCEPTION_MODE_GLOBAL, OS_EXCEPTION_TYPE_PROGRAM, handleProgram); return TRUE; }