mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
Add a define to use sigaction on OS X instead of OS-specific page fault handling.
The latter was introduced last year in order to allow debugging without turning off Fastmem; I wanted to see if the old way was faster. In fact, it is not, but may as well keep the define around in case future testing is necessary.
This commit is contained in:
parent
4d610cc30e
commit
c5c4dd49e6
@ -36,7 +36,7 @@
|
||||
#else
|
||||
#error No context definition for OS
|
||||
#endif
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) && !defined(USE_SIGACTION_ON_APPLE)
|
||||
#include <mach/mach.h>
|
||||
#include <mach/message.h>
|
||||
#if _M_X86_64
|
||||
@ -61,6 +61,26 @@
|
||||
#else
|
||||
#error No context definition for OS
|
||||
#endif
|
||||
#elif defined(__APPLE__)
|
||||
#include <signal.h>
|
||||
typedef _STRUCT_MCONTEXT64 SContext;
|
||||
#define CTX_RAX __ss.__rax
|
||||
#define CTX_RBX __ss.__rbx
|
||||
#define CTX_RCX __ss.__rcx
|
||||
#define CTX_RDX __ss.__rdx
|
||||
#define CTX_RDI __ss.__rdi
|
||||
#define CTX_RSI __ss.__rsi
|
||||
#define CTX_RBP __ss.__rbp
|
||||
#define CTX_RSP __ss.__rsp
|
||||
#define CTX_R8 __ss.__r8
|
||||
#define CTX_R9 __ss.__r9
|
||||
#define CTX_R10 __ss.__r10
|
||||
#define CTX_R11 __ss.__r11
|
||||
#define CTX_R12 __ss.__r12
|
||||
#define CTX_R13 __ss.__r13
|
||||
#define CTX_R14 __ss.__r14
|
||||
#define CTX_R15 __ss.__r15
|
||||
#define CTX_RIP __ss.__rip
|
||||
#elif defined(__linux__)
|
||||
#include <signal.h>
|
||||
#if _M_X86_64
|
||||
|
@ -5,12 +5,9 @@
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "Common/Thread.h"
|
||||
#endif
|
||||
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Thread.h"
|
||||
#include "Common/x64Analyzer.h"
|
||||
|
||||
#include "Core/MemTools.h"
|
||||
@ -92,7 +89,7 @@ void InstallExceptionHandler()
|
||||
|
||||
void UninstallExceptionHandler() {}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) && !defined(USE_SIGACTION_ON_APPLE)
|
||||
|
||||
void CheckKR(const char* name, kern_return_t kr)
|
||||
{
|
||||
@ -216,7 +213,7 @@ void UninstallExceptionHandler() {}
|
||||
|
||||
static void sigsegv_handler(int sig, siginfo_t *info, void *raw_context)
|
||||
{
|
||||
if (sig != SIGSEGV)
|
||||
if (sig != SIGSEGV && sig != SIGBUS)
|
||||
{
|
||||
// We are not interested in other signals - handle it as usual.
|
||||
return;
|
||||
@ -233,10 +230,19 @@ static void sigsegv_handler(int sig, siginfo_t *info, void *raw_context)
|
||||
// Get all the information we can out of the context.
|
||||
mcontext_t *ctx = &context->uc_mcontext;
|
||||
// assume it's not a write
|
||||
if (!JitInterface::HandleFault(bad_address, ctx))
|
||||
if (!JitInterface::HandleFault(bad_address,
|
||||
#ifdef __APPLE__
|
||||
*ctx
|
||||
#else
|
||||
ctx
|
||||
#endif
|
||||
))
|
||||
{
|
||||
// retry and crash
|
||||
signal(SIGSEGV, SIG_DFL);
|
||||
#ifdef __APPLE__
|
||||
signal(SIGBUS, SIG_DFL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,6 +260,9 @@ void InstallExceptionHandler()
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sigaction(SIGSEGV, &sa, nullptr);
|
||||
#ifdef __APPLE__
|
||||
sigaction(SIGBUS, &sa, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void UninstallExceptionHandler()
|
||||
|
Loading…
Reference in New Issue
Block a user