mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #1449 from comex/memtools-merge
Reorganize faulting stuff. Differentiate between arch- and OS-specific defines.
This commit is contained in:
commit
aa2fc1f66b
@ -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
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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" />
|
||||
|
@ -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>
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
namespace EMM
|
||||
{
|
||||
typedef u32 EAddr;
|
||||
extern const bool g_exception_handlers_supported;
|
||||
void InstallExceptionHandler();
|
||||
void UninstallExceptionHandler();
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "Core/HW/Memmap.h"
|
||||
#include "Core/PowerPC/JitArm32/Jit.h"
|
||||
#include "Core/PowerPC/JitCommon/JitBackpatch.h"
|
||||
|
||||
using namespace ArmGen;
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "disasm.h"
|
||||
|
||||
#include "Core/PowerPC/JitCommon/JitBackpatch.h"
|
||||
#include "Core/PowerPC/JitCommon/JitBase.h"
|
||||
|
||||
using namespace Gen;
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user