OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006-2009 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. | |
4 | |
5 #include "base/debug_util.h" | |
6 | |
7 #include <signal.h> | |
8 #include <unistd.h> | |
9 | |
10 #include "base/basictypes.h" | |
11 | |
12 static void ExitSignalHandler(int sig) { | |
13 // A call to exit() can call atexit() handlers. If we SIGSEGV due | |
14 // to a corrupt heap, and if we have an atexit handler that | |
15 // allocates or frees memory, we are in trouble if we do not _exit. | |
16 _exit(128 + sig); | |
17 } | |
18 | |
19 // static | |
20 void DebugUtil::DisableOSCrashDumps() { | |
21 // These are the POSIX signals corresponding to the Mach exceptions that | |
22 // Apple Crash Reporter handles. See ux_exception() in xnu's | |
23 // bsd/uxkern/ux_exception.c and machine_exception() in xnu's | |
24 // bsd/dev/*/unix_signal.c. | |
25 const int signals_to_intercept[] = { | |
26 SIGILL, // EXC_BAD_INSTRUCTION | |
27 SIGTRAP, // EXC_BREAKPOINT | |
28 SIGFPE, // EXC_ARITHMETIC | |
29 SIGBUS, // EXC_BAD_ACCESS | |
30 SIGSEGV // EXC_BAD_ACCESS | |
31 }; | |
32 | |
33 // For all these signals, just wire things up so we exit immediately. | |
34 for (size_t i = 0; i < arraysize(signals_to_intercept); ++i) { | |
35 signal(signals_to_intercept[i], ExitSignalHandler); | |
36 } | |
37 } | |
OLD | NEW |