Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: util/mach/mach_extensions.cc

Issue 563383002: Add SymbolicConstantsMach and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698