diff options
| author | comex <comexk@gmail.com> | 2014-10-30 23:52:57 -0400 |
|---|---|---|
| committer | comex <comexk@gmail.com> | 2014-10-31 00:14:06 -0400 |
| commit | 2ecd849eab86cfc1577143c09d4941ae7b34e8ea (patch) | |
| tree | cf3ff0d95c5d2a5ebe50460b8b73d2786bba19ff /Source | |
| parent | 5ba5aa10e38ca7f1724c3860ec8a66f37366e42a (diff) | |
Reorganize faulting stuff. Differentiate between arch- and OS-specific defines.
- Get rid of ArmMemTools.cpp and rename x64MemTools.cpp to MemTools.cpp.
ArmMemTools was almost identical to the POSIX part of x64MemTools, and
the two differences, (a) lack of sigaltstack, which I added to the
latter recently, and (b) use of r10 to determine the fault address
instead of info->si_addr (meaning it only works for specifically
formatted JIT code), I don't think are necessary. (Plus Android, see
below.)
- Rename Core/PowerPC/JitCommon/JitBackpatch.h to Core/MachineContext.h.
It doesn't contain anything JIT-specific anymore, and e.g. locking
will want to use faulting support regardless of whether any JIT is in
use.
- Get rid of different definitions of SContext for different
architectures under __linux__, since this is POSIX. The exception is
of course Android being shitty; I moved the workaround definition from
ArmMemTools.cpp to here.
- Get rid of #ifdefs around EMM::InstallExceptionHandler and just
provide an empty implementation for unsupported systems (i.e.
_M_GENERIC really). Added const bool g_exception_handlers_supported
for future use; currently exception handlers are only used by the JIT,
whose use implies non-M_GENERIC, but locking will change that.
- Remove an unnecessary typedef.
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/ArmMemTools.cpp | 78 | ||||
| -rw-r--r-- | Source/Core/Core/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | Source/Core/Core/Core.cpp | 4 | ||||
| -rw-r--r-- | Source/Core/Core/Core.vcxproj | 4 | ||||
| -rw-r--r-- | Source/Core/Core/Core.vcxproj.filters | 9 | ||||
| -rw-r--r-- | Source/Core/Core/MachineContext.h (renamed from Source/Core/Core/PowerPC/JitCommon/JitBackpatch.h) | 22 | ||||
| -rw-r--r-- | Source/Core/Core/MemTools.cpp (renamed from Source/Core/Core/x64MemTools.cpp) | 15 | ||||
| -rw-r--r-- | Source/Core/Core/MemTools.h | 2 | ||||
| -rw-r--r-- | Source/Core/Core/PowerPC/Jit64/Jit.h | 1 | ||||
| -rw-r--r-- | Source/Core/Core/PowerPC/Jit64IL/JitIL.h | 1 | ||||
| -rw-r--r-- | Source/Core/Core/PowerPC/JitArm32/JitArm_BackPatch.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/Core/PowerPC/JitCommon/JitBackpatch.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/Core/PowerPC/JitCommon/JitBase.h | 2 | ||||
| -rw-r--r-- | Source/Core/Core/PowerPC/JitInterface.h | 2 |
14 files changed, 37 insertions, 108 deletions
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 <cstdio> -#include <signal.h> -#ifdef ANDROID -#include <asm/sigcontext.h> -#else -#include <execinfo.h> -#include <sys/ucontext.h> // 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 @@ <ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_kbd.cpp" /> <ClCompile Include="IPC_HLE\WII_IPC_HLE_WiiMote.cpp" /> <ClCompile Include="IPC_HLE\WII_Socket.cpp" /> + <ClCompile Include="MemTools.cpp" /> <ClCompile Include="Movie.cpp" /> <ClCompile Include="NetPlayClient.cpp" /> <ClCompile Include="NetPlayServer.cpp" /> @@ -240,7 +241,6 @@ <ClCompile Include="PowerPC\SignatureDB.cpp" /> <ClCompile Include="State.cpp" /> <ClCompile Include="VolumeHandler.cpp" /> - <ClCompile Include="x64MemTools.cpp" /> </ItemGroup> <ItemGroup> <ClInclude Include="ActionReplay.h" /> @@ -383,6 +383,7 @@ <ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_kbd.h" /> <ClInclude Include="IPC_HLE\WII_IPC_HLE_WiiMote.h" /> <ClInclude Include="IPC_HLE\WII_Socket.h" /> + <ClInclude Include="MachineContext.h" /> <ClInclude Include="MemTools.h" /> <ClInclude Include="Movie.h" /> <ClInclude Include="NetPlayClient.h" /> @@ -403,7 +404,6 @@ <ClInclude Include="PowerPC\JitILCommon\IR.h" /> <ClInclude Include="PowerPC\JitILCommon\JitILBase.h" /> <ClInclude Include="PowerPC\JitCommon\JitAsmCommon.h" /> - <ClInclude Include="PowerPC\JitCommon\JitBackpatch.h" /> <ClInclude Include="PowerPC\JitCommon\JitBase.h" /> <ClInclude Include="PowerPC\JitCommon\JitCache.h" /> <ClInclude Include="PowerPC\JitCommon\Jit_Util.h" /> 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 @@ <ClCompile Include="CoreParameter.cpp" /> <ClCompile Include="CoreTiming.cpp" /> <ClCompile Include="ec_wii.cpp" /> + <ClCompile Include="MemTools.cpp" /> <ClCompile Include="Movie.cpp" /> <ClCompile Include="NetPlayClient.cpp" /> <ClCompile Include="NetPlayServer.cpp" /> <ClCompile Include="PatchEngine.cpp" /> <ClCompile Include="State.cpp" /> <ClCompile Include="VolumeHandler.cpp" /> - <ClCompile Include="x64MemTools.cpp" /> <ClCompile Include="ActionReplay.cpp"> <Filter>ActionReplay</Filter> </ClCompile> @@ -631,9 +631,6 @@ <ClCompile Include="PowerPC\JitCommon\JitAsmCommon.cpp"> <Filter>PowerPC\JitCommon</Filter> </ClCompile> - <ClCompile Include="PowerPC\JitCommon\JitBackpatch.cpp"> - <Filter>PowerPC\JitCommon</Filter> - </ClCompile> <ClCompile Include="PowerPC\JitCommon\JitBase.cpp"> <Filter>PowerPC\JitCommon</Filter> </ClCompile> @@ -718,6 +715,7 @@ <ClInclude Include="CoreTiming.h" /> <ClInclude Include="ec_wii.h" /> <ClInclude Include="Host.h" /> + <ClCompile Include="MachineContext.h" /> <ClInclude Include="MemTools.h" /> <ClInclude Include="Movie.h" /> <ClInclude Include="NetPlayClient.h" /> @@ -1176,9 +1174,6 @@ <ClInclude Include="PowerPC\JitCommon\JitAsmCommon.h"> <Filter>PowerPC\JitCommon</Filter> </ClInclude> - <ClInclude Include="PowerPC\JitCommon\JitBackpatch.h"> - <Filter>PowerPC\JitCommon</Filter> - </ClInclude> <ClInclude Include="PowerPC\JitCommon\JitBase.h"> <Filter>PowerPC\JitCommon</Filter> </ClInclude> diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.h b/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 <signal.h> - #if _M_X86_64 + + #ifdef ANDROID + #include <asm/sigcontext.h> + 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 <ucontext.h> - 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 <asm/sigcontext.h> // 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 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 <string> #include "Common/ChunkFile.h" +#include "Core/MachineContext.h" #include "Core/PowerPC/CPUCoreBase.h" -#include "Core/PowerPC/JitCommon/JitBackpatch.h" namespace JitInterface { |
