OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "util/mach/mach_extensions.h" | 15 #include "util/mach/mach_extensions.h" |
16 | 16 |
17 #include <AvailabilityMacros.h> | 17 #include <AvailabilityMacros.h> |
18 #include <pthread.h> | 18 #include <pthread.h> |
| 19 #include <servers/bootstrap.h> |
19 | 20 |
20 #include "base/mac/mach_logging.h" | 21 #include "base/mac/mach_logging.h" |
21 #include "util/mac/mac_util.h" | 22 #include "util/mac/mac_util.h" |
22 | 23 |
23 namespace crashpad { | 24 namespace crashpad { |
24 | 25 |
25 thread_t MachThreadSelf() { | 26 thread_t MachThreadSelf() { |
26 // The pthreads library keeps its own copy of the thread port. Using it does | 27 // The pthreads library keeps its own copy of the thread port. Using it does |
27 // not increment its reference count. | 28 // not increment its reference count. |
28 return pthread_mach_thread_np(pthread_self()); | 29 return pthread_mach_thread_np(pthread_self()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 return kExcMaskValid_10_6; | 90 return kExcMaskValid_10_6; |
90 } | 91 } |
91 #endif | 92 #endif |
92 | 93 |
93 // 10.11 added EXC_MASK_CORPSE_NOTIFY. See 10.11 <mach/exception_types.h>. | 94 // 10.11 added EXC_MASK_CORPSE_NOTIFY. See 10.11 <mach/exception_types.h>. |
94 const exception_mask_t kExcMaskValid_10_11 = | 95 const exception_mask_t kExcMaskValid_10_11 = |
95 kExcMaskValid_10_6 | EXC_MASK_CORPSE_NOTIFY; | 96 kExcMaskValid_10_6 | EXC_MASK_CORPSE_NOTIFY; |
96 return kExcMaskValid_10_11; | 97 return kExcMaskValid_10_11; |
97 } | 98 } |
98 | 99 |
| 100 base::mac::ScopedMachSendRight SystemCrashReporterHandler() { |
| 101 const char kSystemCrashReporterServiceName[] = "com.apple.ReportCrash"; |
| 102 exception_handler_t system_crash_reporter_handler; |
| 103 kern_return_t kr = bootstrap_look_up(bootstrap_port, |
| 104 kSystemCrashReporterServiceName, |
| 105 &system_crash_reporter_handler); |
| 106 if (kr != BOOTSTRAP_SUCCESS) { |
| 107 BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_look_up " |
| 108 << kSystemCrashReporterServiceName; |
| 109 system_crash_reporter_handler = MACH_PORT_NULL; |
| 110 } |
| 111 |
| 112 return base::mac::ScopedMachSendRight(system_crash_reporter_handler); |
| 113 } |
| 114 |
99 } // namespace crashpad | 115 } // namespace crashpad |
OLD | NEW |