Home | History | Annotate | Download | only in process
      1 // Copyright (c) 2012 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/process/launch.h"
      6 
      7 #include <mach/mach.h>
      8 
      9 namespace base {
     10 
     11 void RestoreDefaultExceptionHandler() {
     12   // This function is tailored to remove the Breakpad exception handler.
     13   // exception_mask matches s_exception_mask in
     14   // breakpad/src/client/mac/handler/exception_handler.cc
     15   const exception_mask_t exception_mask = EXC_MASK_BAD_ACCESS |
     16                                           EXC_MASK_BAD_INSTRUCTION |
     17                                           EXC_MASK_ARITHMETIC |
     18                                           EXC_MASK_BREAKPOINT;
     19 
     20   // Setting the exception port to MACH_PORT_NULL may not be entirely
     21   // kosher to restore the default exception handler, but in practice,
     22   // it results in the exception port being set to Apple Crash Reporter,
     23   // the desired behavior.
     24   task_set_exception_ports(mach_task_self(), exception_mask, MACH_PORT_NULL,
     25                            EXCEPTION_DEFAULT, THREAD_STATE_NONE);
     26 }
     27 
     28 }  // namespace base
     29