2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This module is supposed to abstract signal handling away from the other
|
|
|
|
* platforms that do not support it.
|
|
|
|
*/
|
|
|
|
|
2009-12-17 13:56:12 -08:00
|
|
|
#include "nsSigHandlers.h"
|
|
|
|
|
|
|
|
#ifdef XP_UNIX
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include <signal.h>
|
|
|
|
#include <stdio.h>
|
2007-05-23 09:13:22 -07:00
|
|
|
#include <string.h>
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "prthread.h"
|
|
|
|
#include "plstr.h"
|
|
|
|
#include "prenv.h"
|
2007-05-23 09:13:22 -07:00
|
|
|
#include "nsDebug.h"
|
2011-04-02 19:14:00 -07:00
|
|
|
#include "nsXULAppAPI.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#if defined(LINUX)
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h> // atoi
|
2011-09-28 21:39:03 -07:00
|
|
|
#ifndef ANDROID // no Android impl
|
2011-04-01 16:47:37 -07:00
|
|
|
# include <ucontext.h>
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SOLARIS)
|
|
|
|
#include <sys/resource.h>
|
2010-01-13 01:04:52 -08:00
|
|
|
#include <ucontext.h>
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static char _progname[1024] = "huh?";
|
|
|
|
static unsigned int _gdb_sleep_duration = 300;
|
|
|
|
|
2010-01-27 20:23:16 -08:00
|
|
|
// NB: keep me up to date with the same variable in
|
|
|
|
// ipc/chromium/chrome/common/ipc_channel_posix.cc
|
|
|
|
static const int kClientChannelFd = 3;
|
|
|
|
|
2012-10-01 20:43:27 -07:00
|
|
|
#if defined(LINUX) && defined(DEBUG) && \
|
2007-03-22 10:30:00 -07:00
|
|
|
(defined(__i386) || defined(__x86_64) || defined(PPC))
|
|
|
|
#define CRAWL_STACK_ON_SIGSEGV
|
|
|
|
#endif
|
|
|
|
|
2010-05-12 11:31:24 -07:00
|
|
|
#if defined(CRAWL_STACK_ON_SIGSEGV)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "nsISupportsUtils.h"
|
2007-08-10 14:28:22 -07:00
|
|
|
#include "nsStackWalk.h"
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
2012-06-27 13:08:21 -07:00
|
|
|
static void PrintStackFrame(void *aPC, void *aSP, void *aClosure)
|
2007-08-10 14:28:22 -07:00
|
|
|
{
|
2007-08-10 14:29:37 -07:00
|
|
|
char buf[1024];
|
|
|
|
nsCodeAddressDetails details;
|
|
|
|
|
|
|
|
NS_DescribeCodeAddress(aPC, &details);
|
|
|
|
NS_FormatCodeAddressDetails(aPC, &details, buf, sizeof(buf));
|
2009-10-19 08:03:00 -07:00
|
|
|
fputs(buf, stdout);
|
2007-08-10 14:28:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
ah_crap_handler(int signum)
|
|
|
|
{
|
|
|
|
printf("\nProgram %s (pid = %d) received signal %d.\n",
|
|
|
|
_progname,
|
|
|
|
getpid(),
|
|
|
|
signum);
|
|
|
|
|
|
|
|
printf("Stack:\n");
|
2012-12-20 21:31:57 -08:00
|
|
|
NS_StackWalk(PrintStackFrame, /* skipFrames */ 2, /* maxFrames */ 0,
|
|
|
|
nullptr, 0, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
printf("Sleeping for %d seconds.\n",_gdb_sleep_duration);
|
|
|
|
printf("Type 'gdb %s %d' to attach your debugger to this thread.\n",
|
|
|
|
_progname,
|
|
|
|
getpid());
|
|
|
|
|
|
|
|
sleep(_gdb_sleep_duration);
|
|
|
|
|
|
|
|
printf("Done sleeping...\n");
|
2009-02-25 22:56:10 -08:00
|
|
|
|
|
|
|
_exit(signum);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-01-27 20:23:16 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
child_ah_crap_handler(int signum)
|
|
|
|
{
|
|
|
|
if (!getenv("MOZ_DONT_UNBLOCK_PARENT_ON_CHILD_CRASH"))
|
|
|
|
close(kClientChannelFd);
|
|
|
|
ah_crap_handler(signum);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // CRAWL_STACK_ON_SIGSEGV
|
|
|
|
|
2012-06-15 23:06:10 -07:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2007-06-12 11:24:32 -07:00
|
|
|
// Need this include for version test below.
|
2007-05-23 08:55:36 -07:00
|
|
|
#include <glib.h>
|
2007-06-12 11:24:32 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-15 23:06:10 -07:00
|
|
|
#if defined(MOZ_WIDGET_GTK) && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
|
2007-05-23 08:55:36 -07:00
|
|
|
|
2013-10-10 13:36:42 -07:00
|
|
|
static GLogFunc orig_log_func = nullptr;
|
2007-05-23 08:55:36 -07:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
static void
|
|
|
|
my_glib_log_func(const gchar *log_domain, GLogLevelFlags log_level,
|
|
|
|
const gchar *message, gpointer user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
my_glib_log_func(const gchar *log_domain, GLogLevelFlags log_level,
|
|
|
|
const gchar *message, gpointer user_data)
|
|
|
|
{
|
2008-01-07 01:57:28 -08:00
|
|
|
if (log_level & (G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION)) {
|
2007-05-23 08:55:36 -07:00
|
|
|
NS_DebugBreak(NS_DEBUG_ASSERTION, message, "glib assertion", __FILE__, __LINE__);
|
2008-01-07 01:57:28 -08:00
|
|
|
} else if (log_level & (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING)) {
|
|
|
|
NS_DebugBreak(NS_DEBUG_WARNING, message, "glib warning", __FILE__, __LINE__);
|
2007-05-23 08:55:36 -07:00
|
|
|
}
|
2008-01-07 01:57:28 -08:00
|
|
|
|
2013-10-10 13:36:42 -07:00
|
|
|
orig_log_func(log_domain, log_level, message, nullptr);
|
2007-05-23 08:55:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-11-07 01:20:50 -07:00
|
|
|
#ifdef SA_SIGINFO
|
2009-12-17 13:56:12 -08:00
|
|
|
static void fpehandler(int signum, siginfo_t *si, void *context)
|
|
|
|
{
|
2010-01-13 01:04:04 -08:00
|
|
|
/* Integer divide by zero or integer overflow. */
|
|
|
|
/* Note: FPE_INTOVF is ignored on Intel, PowerPC and SPARC systems. */
|
|
|
|
if (si->si_code == FPE_INTDIV || si->si_code == FPE_INTOVF) {
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_DebugBreak(NS_DEBUG_ABORT, "Divide by zero", nullptr, __FILE__, __LINE__);
|
2010-01-13 01:04:04 -08:00
|
|
|
}
|
|
|
|
|
2009-12-17 13:56:12 -08:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
ucontext_t *uc = (ucontext_t *)context;
|
|
|
|
|
|
|
|
#if defined(__i386__) || defined(__amd64__)
|
|
|
|
_STRUCT_FP_CONTROL *ctrl = &uc->uc_mcontext->__fs.__fpu_fcw;
|
|
|
|
ctrl->__invalid = ctrl->__denorm = ctrl->__zdiv = ctrl->__ovrfl = ctrl->__undfl = ctrl->__precis = 1;
|
|
|
|
|
|
|
|
_STRUCT_FP_STATUS *status = &uc->uc_mcontext->__fs.__fpu_fsw;
|
|
|
|
status->__invalid = status->__denorm = status->__zdiv = status->__ovrfl = status->__undfl =
|
|
|
|
status->__precis = status->__stkflt = status->__errsumm = 0;
|
|
|
|
|
|
|
|
__uint32_t *mxcsr = &uc->uc_mcontext->__fs.__fpu_mxcsr;
|
|
|
|
*mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
|
|
|
|
*mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
|
|
|
|
#endif
|
|
|
|
#endif
|
2011-09-28 21:39:03 -07:00
|
|
|
#if defined(LINUX) && !defined(ANDROID)
|
2009-12-17 13:56:12 -08:00
|
|
|
ucontext_t *uc = (ucontext_t *)context;
|
|
|
|
|
|
|
|
#if defined(__i386__)
|
|
|
|
/*
|
|
|
|
* It seems that we have no access to mxcsr on Linux. libc
|
|
|
|
* seems to be translating cw/sw to mxcsr.
|
|
|
|
*/
|
|
|
|
unsigned long int *cw = &uc->uc_mcontext.fpregs->cw;
|
|
|
|
*cw |= FPU_EXCEPTION_MASK;
|
|
|
|
|
|
|
|
unsigned long int *sw = &uc->uc_mcontext.fpregs->sw;
|
|
|
|
*sw &= ~FPU_STATUS_FLAGS;
|
|
|
|
#endif
|
|
|
|
#if defined(__amd64__)
|
2009-12-18 19:29:13 -08:00
|
|
|
__uint16_t *cw = &uc->uc_mcontext.fpregs->cwd;
|
2009-12-18 18:28:19 -08:00
|
|
|
*cw |= FPU_EXCEPTION_MASK;
|
2009-12-17 13:56:12 -08:00
|
|
|
|
2009-12-18 19:29:13 -08:00
|
|
|
__uint16_t *sw = &uc->uc_mcontext.fpregs->swd;
|
2009-12-18 18:28:19 -08:00
|
|
|
*sw &= ~FPU_STATUS_FLAGS;
|
2009-12-17 13:56:12 -08:00
|
|
|
|
2009-12-18 18:28:19 -08:00
|
|
|
__uint32_t *mxcsr = &uc->uc_mcontext.fpregs->mxcsr;
|
2009-12-17 13:56:12 -08:00
|
|
|
*mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
|
|
|
|
*mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
|
|
|
|
#endif
|
|
|
|
#endif
|
2010-01-13 01:04:52 -08:00
|
|
|
#ifdef SOLARIS
|
|
|
|
ucontext_t *uc = (ucontext_t *)context;
|
|
|
|
|
|
|
|
#if defined(__i386)
|
|
|
|
uint32_t *cw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[0];
|
|
|
|
*cw |= FPU_EXCEPTION_MASK;
|
|
|
|
|
|
|
|
uint32_t *sw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[1];
|
|
|
|
*sw &= ~FPU_STATUS_FLAGS;
|
|
|
|
|
|
|
|
/* address of the instruction that caused the exception */
|
|
|
|
uint32_t *ip = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[3];
|
|
|
|
uc->uc_mcontext.gregs[REG_PC] = *ip;
|
|
|
|
#endif
|
|
|
|
#if defined(__amd64__)
|
|
|
|
uint16_t *cw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.cw;
|
|
|
|
*cw |= FPU_EXCEPTION_MASK;
|
|
|
|
|
|
|
|
uint16_t *sw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.sw;
|
|
|
|
*sw &= ~FPU_STATUS_FLAGS;
|
|
|
|
|
|
|
|
uint32_t *mxcsr = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.mxcsr;
|
|
|
|
*mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
|
|
|
|
*mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
|
|
|
|
#endif
|
|
|
|
#endif
|
2009-12-17 13:56:12 -08:00
|
|
|
}
|
2010-11-07 01:20:50 -07:00
|
|
|
#endif
|
2009-12-17 13:56:12 -08:00
|
|
|
|
|
|
|
void InstallSignalHandlers(const char *ProgramName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
PL_strncpy(_progname,ProgramName, (sizeof(_progname)-1) );
|
|
|
|
|
|
|
|
const char *gdbSleep = PR_GetEnv("MOZ_GDB_SLEEP");
|
|
|
|
if (gdbSleep && *gdbSleep)
|
|
|
|
{
|
|
|
|
unsigned int s;
|
|
|
|
if (1 == sscanf(gdbSleep, "%u", &s)) {
|
|
|
|
_gdb_sleep_duration = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-12 11:31:24 -07:00
|
|
|
#if defined(CRAWL_STACK_ON_SIGSEGV)
|
2012-10-01 20:43:27 -07:00
|
|
|
if (!getenv("XRE_NO_WINDOWS_CRASH_DIALOG")) {
|
2010-01-27 20:23:16 -08:00
|
|
|
void (*crap_handler)(int) =
|
|
|
|
GeckoProcessType_Default != XRE_GetProcessType() ?
|
|
|
|
child_ah_crap_handler :
|
|
|
|
ah_crap_handler;
|
|
|
|
signal(SIGSEGV, crap_handler);
|
|
|
|
signal(SIGILL, crap_handler);
|
|
|
|
signal(SIGABRT, crap_handler);
|
2009-12-18 14:14:53 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // CRAWL_STACK_ON_SIGSEGV
|
|
|
|
|
2010-11-07 01:20:50 -07:00
|
|
|
#ifdef SA_SIGINFO
|
2009-12-17 13:56:12 -08:00
|
|
|
/* Install a handler for floating point exceptions and disable them if they occur. */
|
|
|
|
struct sigaction sa, osa;
|
|
|
|
sa.sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
|
|
|
|
sa.sa_sigaction = fpehandler;
|
2010-01-07 05:51:16 -08:00
|
|
|
sigemptyset(&sa.sa_mask);
|
2009-12-17 13:56:12 -08:00
|
|
|
sigaction(SIGFPE, &sa, &osa);
|
2010-11-07 01:20:50 -07:00
|
|
|
#endif
|
2009-12-17 13:56:12 -08:00
|
|
|
|
2013-08-14 14:48:32 -07:00
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
|
|
|
/*
|
|
|
|
* If the user is debugging a Gecko parent process in gdb and hits ^C to
|
|
|
|
* suspend, a SIGINT signal will be sent to the child. We ignore this signal
|
|
|
|
* so the child isn't killed.
|
|
|
|
*/
|
|
|
|
signal(SIGINT, SIG_IGN);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#if defined(DEBUG) && defined(LINUX)
|
|
|
|
const char *memLimit = PR_GetEnv("MOZ_MEM_LIMIT");
|
|
|
|
if (memLimit && *memLimit)
|
|
|
|
{
|
|
|
|
long m = atoi(memLimit);
|
|
|
|
m *= (1024*1024);
|
|
|
|
struct rlimit r;
|
|
|
|
r.rlim_cur = m;
|
|
|
|
r.rlim_max = m;
|
|
|
|
setrlimit(RLIMIT_AS, &r);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SOLARIS)
|
|
|
|
#define NOFILES 512
|
|
|
|
|
|
|
|
// Boost Solaris file descriptors
|
|
|
|
{
|
|
|
|
struct rlimit rl;
|
|
|
|
|
|
|
|
if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
|
|
|
|
|
|
|
|
if (rl.rlim_cur < NOFILES) {
|
|
|
|
rl.rlim_cur = NOFILES;
|
|
|
|
|
|
|
|
if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
|
|
|
|
perror("setrlimit(RLIMIT_NOFILE)");
|
|
|
|
fprintf(stderr, "Cannot exceed hard limit for open files");
|
|
|
|
}
|
|
|
|
#if defined(DEBUG)
|
|
|
|
if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
|
|
|
|
printf("File descriptors set to %d\n", rl.rlim_cur);
|
|
|
|
#endif //DEBUG
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif //SOLARIS
|
|
|
|
|
2012-06-15 23:06:10 -07:00
|
|
|
#if defined(MOZ_WIDGET_GTK) && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
|
2007-05-23 08:55:36 -07:00
|
|
|
const char *assertString = PR_GetEnv("XPCOM_DEBUG_BREAK");
|
|
|
|
if (assertString &&
|
|
|
|
(!strcmp(assertString, "suspend") ||
|
|
|
|
!strcmp(assertString, "stack") ||
|
|
|
|
!strcmp(assertString, "abort") ||
|
|
|
|
!strcmp(assertString, "trap") ||
|
|
|
|
!strcmp(assertString, "break"))) {
|
|
|
|
// Override the default glib logging function so we get stacks for it too.
|
2013-10-10 13:36:42 -07:00
|
|
|
orig_log_func = g_log_set_default_handler(my_glib_log_func, nullptr);
|
2007-05-23 08:55:36 -07:00
|
|
|
}
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-12-17 13:56:12 -08:00
|
|
|
|
|
|
|
#elif XP_WIN
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#ifdef _M_IX86
|
|
|
|
/*
|
|
|
|
* WinNT.h prior to SDK7 does not expose the structure of the ExtendedRegisters for ia86.
|
|
|
|
* We known that MxCsr is at offset 0x18 and is a DWORD.
|
|
|
|
*/
|
|
|
|
#define MXCSR(ctx) (*(DWORD *)(((BYTE *)(ctx)->ExtendedRegisters) + 0x18))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _M_X64
|
|
|
|
#define MXCSR(ctx) (ctx)->MxCsr
|
|
|
|
#endif
|
|
|
|
|
2010-01-05 11:11:51 -08:00
|
|
|
#if defined(_M_IX86) || defined(_M_X64)
|
2009-12-17 13:56:12 -08:00
|
|
|
|
2009-12-29 01:48:02 -08:00
|
|
|
#ifdef _M_X64
|
|
|
|
#define X87CW(ctx) (ctx)->FltSave.ControlWord
|
|
|
|
#define X87SW(ctx) (ctx)->FltSave.StatusWord
|
|
|
|
#else
|
2009-12-17 13:56:12 -08:00
|
|
|
#define X87CW(ctx) (ctx)->FloatSave.ControlWord
|
|
|
|
#define X87SW(ctx) (ctx)->FloatSave.StatusWord
|
2009-12-29 01:48:02 -08:00
|
|
|
#endif
|
2009-12-17 13:56:12 -08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* SSE traps raise these exception codes, which are defined in internal NT headers
|
|
|
|
* but not winbase.h
|
|
|
|
*/
|
|
|
|
#define STATUS_FLOAT_MULTIPLE_FAULTS 0xC00002B4
|
|
|
|
#define STATUS_FLOAT_MULTIPLE_TRAPS 0xC00002B5
|
|
|
|
|
2010-01-11 10:16:20 -08:00
|
|
|
static LPTOP_LEVEL_EXCEPTION_FILTER gFPEPreviousFilter;
|
|
|
|
|
2009-12-17 13:56:12 -08:00
|
|
|
LONG __stdcall FpeHandler(PEXCEPTION_POINTERS pe)
|
|
|
|
{
|
|
|
|
PEXCEPTION_RECORD e = (PEXCEPTION_RECORD)pe->ExceptionRecord;
|
|
|
|
CONTEXT *c = (CONTEXT*)pe->ContextRecord;
|
|
|
|
|
|
|
|
switch (e->ExceptionCode) {
|
|
|
|
case STATUS_FLOAT_DENORMAL_OPERAND:
|
|
|
|
case STATUS_FLOAT_DIVIDE_BY_ZERO:
|
|
|
|
case STATUS_FLOAT_INEXACT_RESULT:
|
|
|
|
case STATUS_FLOAT_INVALID_OPERATION:
|
|
|
|
case STATUS_FLOAT_OVERFLOW:
|
|
|
|
case STATUS_FLOAT_STACK_CHECK:
|
|
|
|
case STATUS_FLOAT_UNDERFLOW:
|
|
|
|
case STATUS_FLOAT_MULTIPLE_FAULTS:
|
|
|
|
case STATUS_FLOAT_MULTIPLE_TRAPS:
|
|
|
|
X87CW(c) |= FPU_EXCEPTION_MASK; /* disable all FPU exceptions */
|
2010-01-05 11:11:51 -08:00
|
|
|
X87SW(c) &= ~FPU_STATUS_FLAGS; /* clear all pending FPU exceptions */
|
|
|
|
#ifdef _M_IX86
|
2009-12-17 13:56:12 -08:00
|
|
|
if (c->ContextFlags & CONTEXT_EXTENDED_REGISTERS) {
|
|
|
|
#endif
|
|
|
|
MXCSR(c) |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
|
|
|
|
MXCSR(c) &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
|
2010-01-05 11:11:51 -08:00
|
|
|
#ifdef _M_IX86
|
2009-12-17 13:56:12 -08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return EXCEPTION_CONTINUE_EXECUTION;
|
|
|
|
}
|
2010-01-11 10:16:20 -08:00
|
|
|
LONG action = EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
if (gFPEPreviousFilter)
|
|
|
|
action = gFPEPreviousFilter(pe);
|
|
|
|
|
|
|
|
return action;
|
2009-12-17 13:56:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstallSignalHandlers(const char *ProgramName)
|
|
|
|
{
|
2010-01-11 10:16:20 -08:00
|
|
|
gFPEPreviousFilter = SetUnhandledExceptionFilter(FpeHandler);
|
2009-12-17 13:56:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
void InstallSignalHandlers(const char *ProgramName)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-01-30 04:48:32 -08:00
|
|
|
#elif defined(XP_OS2)
|
|
|
|
/* OS/2's FPE handler is implemented in NSPR */
|
|
|
|
|
2009-12-17 13:56:12 -08:00
|
|
|
#else
|
|
|
|
#error No signal handling implementation for this platform.
|
|
|
|
#endif
|