roll skia 1111->1115
[chromium-blink-merge.git] / base / mac / os_crash_dumps.cc
blobe82fd73df5c08a5090dd9ac36f26fa7023be1062
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/mac/os_crash_dumps.h"
7 #include <signal.h>
8 #include <unistd.h>
10 #include "base/basictypes.h"
12 namespace base {
13 namespace mac {
15 namespace {
17 void ExitSignalHandler(int sig) {
18 // A call to exit() can call atexit() handlers. If we SIGSEGV due
19 // to a corrupt heap, and if we have an atexit handler that
20 // allocates or frees memory, we are in trouble if we do not _exit.
21 _exit(128 + sig);
24 } // namespace
26 void DisableOSCrashDumps() {
27 // These are the POSIX signals corresponding to the Mach exceptions that
28 // Apple Crash Reporter handles. See ux_exception() in xnu's
29 // bsd/uxkern/ux_exception.c and machine_exception() in xnu's
30 // bsd/dev/*/unix_signal.c.
31 const int signals_to_intercept[] = {
32 SIGILL, // EXC_BAD_INSTRUCTION
33 SIGTRAP, // EXC_BREAKPOINT
34 SIGFPE, // EXC_ARITHMETIC
35 SIGBUS, // EXC_BAD_ACCESS
36 SIGSEGV // EXC_BAD_ACCESS
39 // For all these signals, just wire things up so we exit immediately.
40 for (size_t i = 0; i < arraysize(signals_to_intercept); ++i)
41 signal(signals_to_intercept[i], ExitSignalHandler);
44 } // namespace mac
45 } // namespace base