diff --git a/Source/Core/Core/ArmMemTools.cpp b/Source/Core/Core/ArmMemTools.cpp deleted file mode 100644 index 634c2a7bf8..0000000000 --- a/Source/Core/Core/ArmMemTools.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - - -#include -#include -#ifdef ANDROID -#include -#else -#include -#include // Look in here for the context definition. -#endif - -#include "Common/CommonFuncs.h" -#include "Common/CommonTypes.h" -#include "Core/MemTools.h" -#include "Core/HW/Memmap.h" -#include "Core/PowerPC/JitInterface.h" -#include "Core/PowerPC/PowerPC.h" -#include "Core/PowerPC/JitCommon/JitBase.h" - -namespace EMM -{ -#ifdef ANDROID -typedef struct sigcontext mcontext_t; -typedef struct ucontext { - uint32_t uc_flags; - struct ucontext* uc_link; - stack_t uc_stack; - mcontext_t uc_mcontext; - // Other fields are not used by Google Breakpad. Don't define them. -} ucontext_t; -#endif - -static void sigsegv_handler(int sig, siginfo_t *info, void *raw_context) -{ - if (sig != SIGSEGV) - { - // We are not interested in other signals - handle it as usual. - return; - } - ucontext_t *context = (ucontext_t *)raw_context; - int sicode = info->si_code; - if (sicode != SEGV_MAPERR && sicode != SEGV_ACCERR) - { - // Huh? Return. - return; - } - - // Get all the information we can out of the context. - mcontext_t *ctx = &context->uc_mcontext; - - // comex says hello, and is most curious whether this is arm_r10 for a - // reason as opposed to si_addr like the x64MemTools.cpp version. Is there - // even a need for this file to be architecture specific? - uintptr_t fault_memory_ptr = (uintptr_t)ctx->arm_r10; - - if (!JitInterface::HandleFault(fault_memory_ptr, ctx)) - { - // retry and crash - signal(SIGSEGV, SIG_DFL); - } -} - -void InstallExceptionHandler() -{ - struct sigaction sa; - sa.sa_handler = 0; - sa.sa_sigaction = &sigsegv_handler; - sa.sa_flags = SA_SIGINFO; - sigemptyset(&sa.sa_mask); - sigaction(SIGSEGV, &sa, nullptr); -} - -void UninstallExceptionHandler() {} - -} // namespace diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 7b0e00a595..52ec66d4b8 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -9,6 +9,7 @@ set(SRCS ActionReplay.cpp ec_wii.cpp GeckoCodeConfig.cpp GeckoCode.cpp + MemTools.cpp Movie.cpp NetPlayClient.cpp NetPlayServer.cpp @@ -179,7 +180,6 @@ set(SRCS ActionReplay.cpp if(_M_X86) set(SRCS ${SRCS} - x64MemTools.cpp PowerPC/Jit64IL/IR_X86.cpp PowerPC/Jit64IL/JitIL.cpp PowerPC/Jit64IL/JitIL_Tables.cpp @@ -201,7 +201,6 @@ if(_M_X86) PowerPC/JitCommon/TrampolineCache.cpp) elseif(_M_ARM_32) set(SRCS ${SRCS} - ArmMemTools.cpp PowerPC/JitArm32/Jit.cpp PowerPC/JitArm32/JitAsm.cpp PowerPC/JitArm32/JitArm_BackPatch.cpp diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 5d2ff0ab96..76d217efc8 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -255,10 +255,8 @@ static void CpuThread() g_video_backend->Video_Prepare(); } - #if _M_X86_64 || _M_ARM_32 if (_CoreParameter.bFastmem) EMM::InstallExceptionHandler(); // Let's run under memory watch - #endif if (!s_state_filename.empty()) State::LoadAs(s_state_filename); @@ -283,9 +281,7 @@ static void CpuThread() if (!_CoreParameter.bCPUThread) g_video_backend->Video_Cleanup(); - #if _M_X86_64 || _M_ARM_32 EMM::UninstallExceptionHandler(); - #endif return; } diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index b46357fd3d..611658f65f 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -187,6 +187,7 @@ + @@ -240,7 +241,6 @@ - @@ -383,6 +383,7 @@ + @@ -403,7 +404,6 @@ - diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index faeb9bcd24..4ddaee9aa4 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -141,13 +141,13 @@ + - ActionReplay @@ -631,9 +631,6 @@ PowerPC\JitCommon - - PowerPC\JitCommon - PowerPC\JitCommon @@ -718,6 +715,7 @@ + @@ -1176,9 +1174,6 @@ PowerPC\JitCommon - - PowerPC\JitCommon - PowerPC\JitCommon diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.h b/Source/Core/Core/MachineContext.h similarity index 95% rename from Source/Core/Core/PowerPC/JitCommon/JitBackpatch.h rename to Source/Core/Core/MachineContext.h index 6cc0bcdf42..47d665b3b2 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.h +++ b/Source/Core/Core/MachineContext.h @@ -87,9 +87,24 @@ #define CTX_RIP __ss.__rip #elif defined(__linux__) #include - #if _M_X86_64 + + #ifdef ANDROID + #include + typedef struct sigcontext mcontext_t; + typedef struct ucontext + { + uint32_t uc_flags; + struct ucontext* uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + // ... + } ucontext_t; + #else #include - typedef mcontext_t SContext; + #endif + typedef mcontext_t SContext; + + #if _M_X86_64 #define CTX_RAX gregs[REG_RAX] #define CTX_RBX gregs[REG_RBX] #define CTX_RCX gregs[REG_RCX] @@ -108,14 +123,11 @@ #define CTX_R15 gregs[REG_R15] #define CTX_RIP gregs[REG_RIP] #elif _M_ARM_64 - typedef struct sigcontext SContext; #define CTX_REG(x) regs[x] #define CTX_SP sp #define CTX_PC pc #elif _M_ARM_32 - #include // Add others if required. - typedef sigcontext SContext; #define CTX_PC arm_pc #else #warning No context definition for OS diff --git a/Source/Core/Core/x64MemTools.cpp b/Source/Core/Core/MemTools.cpp similarity index 94% rename from Source/Core/Core/x64MemTools.cpp rename to Source/Core/Core/MemTools.cpp index db7a307fc3..13029f245d 100644 --- a/Source/Core/Core/x64MemTools.cpp +++ b/Source/Core/Core/MemTools.cpp @@ -10,6 +10,7 @@ #include "Common/Thread.h" #include "Common/x64Analyzer.h" +#include "Core/MachineContext.h" #include "Core/MemTools.h" #include "Core/HW/Memmap.h" #include "Core/PowerPC/JitInterface.h" @@ -23,6 +24,8 @@ namespace EMM #ifdef _WIN32 +const bool g_exception_handlers_supported = true; + LONG NTAPI Handler(PEXCEPTION_POINTERS pPtrs) { switch (pPtrs->ExceptionRecord->ExceptionCode) @@ -91,6 +94,8 @@ void UninstallExceptionHandler() {} #elif defined(__APPLE__) && !defined(USE_SIGACTION_ON_APPLE) +const bool g_exception_handlers_supported = true; + static void CheckKR(const char* name, kern_return_t kr) { if (kr) @@ -209,7 +214,9 @@ void InstallExceptionHandler() void UninstallExceptionHandler() {} -#elif defined(_POSIX_VERSION) +#elif defined(_POSIX_VERSION) && !defined(_M_GENERIC) + +const bool g_exception_handlers_supported = true; static void sigsegv_handler(int sig, siginfo_t *info, void *raw_context) { @@ -275,9 +282,11 @@ void UninstallExceptionHandler() free(old_stack.ss_sp); } } -#else +#else // _M_GENERIC or unsupported platform -#error Unsupported x86_64 platform! Report this if you support sigaction +const bool g_exception_handlers_supported = false; +void InstallExceptionHandler() {} +void UninstallExceptionHandler() {} #endif diff --git a/Source/Core/Core/MemTools.h b/Source/Core/Core/MemTools.h index fcc671b799..cd01d1ae60 100644 --- a/Source/Core/Core/MemTools.h +++ b/Source/Core/Core/MemTools.h @@ -9,7 +9,7 @@ namespace EMM { - typedef u32 EAddr; + extern const bool g_exception_handlers_supported; void InstallExceptionHandler(); void UninstallExceptionHandler(); } diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.h b/Source/Core/Core/PowerPC/Jit64/Jit.h index 7fe8b75506..e60a7b0c3e 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit.h @@ -37,7 +37,6 @@ #include "Core/PowerPC/Jit64/JitAsm.h" #include "Core/PowerPC/Jit64/JitRegCache.h" #include "Core/PowerPC/JitCommon/Jit_Util.h" -#include "Core/PowerPC/JitCommon/JitBackpatch.h" #include "Core/PowerPC/JitCommon/JitBase.h" #include "Core/PowerPC/JitCommon/JitCache.h" diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.h b/Source/Core/Core/PowerPC/Jit64IL/JitIL.h index 8afa6d9ae5..bb3cce01bd 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.h +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.h @@ -30,7 +30,6 @@ #include "Core/PowerPC/PPCTables.h" #include "Core/PowerPC/Jit64/JitAsm.h" #include "Core/PowerPC/JitCommon/Jit_Util.h" -#include "Core/PowerPC/JitCommon/JitBackpatch.h" #include "Core/PowerPC/JitCommon/JitBase.h" #include "Core/PowerPC/JitCommon/JitCache.h" #include "Core/PowerPC/JitILCommon/IR.h" diff --git a/Source/Core/Core/PowerPC/JitArm32/JitArm_BackPatch.cpp b/Source/Core/Core/PowerPC/JitArm32/JitArm_BackPatch.cpp index b3c77cdab4..339e7d8a5c 100644 --- a/Source/Core/Core/PowerPC/JitArm32/JitArm_BackPatch.cpp +++ b/Source/Core/Core/PowerPC/JitArm32/JitArm_BackPatch.cpp @@ -9,7 +9,6 @@ #include "Core/HW/Memmap.h" #include "Core/PowerPC/JitArm32/Jit.h" -#include "Core/PowerPC/JitCommon/JitBackpatch.h" using namespace ArmGen; diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.cpp b/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.cpp index ea921817b8..43526e9d37 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.cpp @@ -6,7 +6,6 @@ #include "disasm.h" -#include "Core/PowerPC/JitCommon/JitBackpatch.h" #include "Core/PowerPC/JitCommon/JitBase.h" using namespace Gen; diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.h b/Source/Core/Core/PowerPC/JitCommon/JitBase.h index 22c4ac9d2b..845db78b01 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.h +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.h @@ -16,6 +16,7 @@ #include "Core/Core.h" #include "Core/CoreTiming.h" +#include "Core/MachineContext.h" #include "Core/HW/GPFifo.h" #include "Core/HW/Memmap.h" #include "Core/PowerPC/CPUCoreBase.h" @@ -24,7 +25,6 @@ #include "Core/PowerPC/PPCTables.h" #include "Core/PowerPC/JitCommon/Jit_Util.h" #include "Core/PowerPC/JitCommon/JitAsmCommon.h" -#include "Core/PowerPC/JitCommon/JitBackpatch.h" #include "Core/PowerPC/JitCommon/JitCache.h" #include "Core/PowerPC/JitCommon/TrampolineCache.h" diff --git a/Source/Core/Core/PowerPC/JitInterface.h b/Source/Core/Core/PowerPC/JitInterface.h index 3ed62edd40..4cbe27f604 100644 --- a/Source/Core/Core/PowerPC/JitInterface.h +++ b/Source/Core/Core/PowerPC/JitInterface.h @@ -6,8 +6,8 @@ #include #include "Common/ChunkFile.h" +#include "Core/MachineContext.h" #include "Core/PowerPC/CPUCoreBase.h" -#include "Core/PowerPC/JitCommon/JitBackpatch.h" namespace JitInterface {