OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (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 |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "util/mach/mach_extensions.h" |
| 16 |
| 17 #include <AvailabilityMacros.h> |
| 18 |
| 19 #include "util/mac/mac_util.h" |
| 20 |
| 21 namespace crashpad { |
| 22 |
| 23 exception_mask_t ExcMaskAll() { |
| 24 // This is necessary because of the way that the kernel validates |
| 25 // exception_mask_t arguments to |
| 26 // {host,task,thread}_{get,set,swap}_exception_ports(). It is strict, |
| 27 // rejecting attempts to operate on any bits that it does not recognize. See |
| 28 // 10.9.4 xnu-2422.110.17/osfmk/mach/ipc_host.c and |
| 29 // xnu-2422.110.17/osfmk/mach/ipc_tt.c. |
| 30 |
| 31 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 |
| 32 int mac_os_x_minor_version = MacOSXMinorVersion(); |
| 33 #endif |
| 34 |
| 35 // See 10.6.8 xnu-1504.15.3/osfmk/mach/exception_types.h. 10.7 uses the same |
| 36 // definition as 10.6. See 10.7.5 xnu-1699.32.7/osfmk/mach/exception_types.h |
| 37 // |
| 38 // The 10.5 SDK actually defined EXC_MASK_ALL as including EXC_MASK_CRASH. |
| 39 // Later SDKs removed EXC_MASK_CRASH from EXC_MASK_ALL, but placed it into a |
| 40 // new constant, EXC_MASK_VALID. For consistent behavior, don’t include |
| 41 // EXC_MASK_CRASH in the 10.5 EXC_MASK_ALL. Consumers that want EXC_MASK_ALL |
| 42 // along with EXC_MASK_CRASH must use ExcMaskAll() | EXC_MASK_CRASH |
| 43 // explicitly. 10.5 otherwise behaves identically to 10.6. See 10.5.8 |
| 44 // xnu-1228.15.4/osfmk/mach/exception_types.h. |
| 45 const exception_mask_t kExcMaskAll_10_6 = |
| 46 EXC_MASK_BAD_ACCESS | EXC_MASK_BAD_INSTRUCTION | EXC_MASK_ARITHMETIC | |
| 47 EXC_MASK_EMULATION | EXC_MASK_SOFTWARE | EXC_MASK_BREAKPOINT | |
| 48 EXC_MASK_SYSCALL | EXC_MASK_MACH_SYSCALL | EXC_MASK_RPC_ALERT | |
| 49 EXC_MASK_MACHINE; |
| 50 #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_7 |
| 51 if (mac_os_x_minor_version <= 7) { |
| 52 return kExcMaskAll_10_6; |
| 53 } |
| 54 #endif |
| 55 |
| 56 // 10.8 added EXC_MASK_RESOURCE. See 10.8.5 |
| 57 // xnu-2050.48.11/osfmk/mach/exception_types.h. |
| 58 const exception_mask_t kExcMaskAll_10_8 = |
| 59 kExcMaskAll_10_6 | EXC_MASK_RESOURCE; |
| 60 #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_8 |
| 61 if (mac_os_x_minor_version <= 8) { |
| 62 return kExcMaskAll_10_8; |
| 63 } |
| 64 #endif |
| 65 |
| 66 // 10.9 added EXC_MASK_GUARD. See 10.9.4 |
| 67 // xnu-2422.110.17/osfmk/mach/exception_types.h. |
| 68 const exception_mask_t kExcMaskAll_10_9 = kExcMaskAll_10_8 | EXC_MASK_GUARD; |
| 69 return kExcMaskAll_10_9; |
| 70 } |
| 71 |
| 72 } // namespace crashpad |
OLD | NEW |