diff --git a/Source/Core/Core/MemTools.cpp b/Source/Core/Core/MemTools.cpp index c427c8ba7e..c9109bfd1f 100644 --- a/Source/Core/Core/MemTools.cpp +++ b/Source/Core/Core/MemTools.cpp @@ -113,6 +113,11 @@ void UninstallExceptionHandler() s_veh_handle = nullptr; } +bool IsExceptionHandlerSupported() +{ + return true; +} + #elif defined(__APPLE__) && !defined(USE_SIGACTION_ON_APPLE) static void CheckKR(const char* name, kern_return_t kr) @@ -245,6 +250,11 @@ void UninstallExceptionHandler() { } +bool IsExceptionHandlerSupported() +{ + return true; +} + #elif defined(_POSIX_VERSION) && !defined(_M_GENERIC) static struct sigaction old_sa_segv; @@ -353,15 +363,27 @@ void UninstallExceptionHandler() sigaction(SIGBUS, &old_sa_bus, nullptr); #endif } + +bool IsExceptionHandlerSupported() +{ + return true; +} + #else // _M_GENERIC or unsupported platform void InstallExceptionHandler() { } + void UninstallExceptionHandler() { } +bool IsExceptionHandlerSupported() +{ + return false; +} + #endif } // namespace EMM diff --git a/Source/Core/Core/MemTools.h b/Source/Core/Core/MemTools.h index 65c06e7023..e71f2bb2f9 100644 --- a/Source/Core/Core/MemTools.h +++ b/Source/Core/Core/MemTools.h @@ -7,4 +7,5 @@ namespace EMM { void InstallExceptionHandler(); void UninstallExceptionHandler(); +bool IsExceptionHandlerSupported(); } // namespace EMM diff --git a/Source/UnitTests/Core/PageFaultTest.cpp b/Source/UnitTests/Core/PageFaultTest.cpp index 841ba54609..e340ca7646 100644 --- a/Source/UnitTests/Core/PageFaultTest.cpp +++ b/Source/UnitTests/Core/PageFaultTest.cpp @@ -61,6 +61,11 @@ static void ASAN_DISABLE perform_invalid_access(void* data) TEST(PageFault, PageFault) { + if (!EMM::IsExceptionHandlerSupported()) + { + // TODO: Use GTEST_SKIP() instead when GTest is updated to 1.10+ + return; + } EMM::InstallExceptionHandler(); void* data = Common::AllocateMemoryPages(PAGE_GRAN); EXPECT_NE(data, nullptr);