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 | 19 |
20 #include "base/mac/mach_logging.h" | |
20 #include "util/mac/mac_util.h" | 21 #include "util/mac/mac_util.h" |
21 | 22 |
22 namespace crashpad { | 23 namespace crashpad { |
23 | 24 |
24 thread_t MachThreadSelf() { | 25 thread_t MachThreadSelf() { |
25 // The pthreads library keeps its own copy of the thread port. Using it does | 26 // The pthreads library keeps its own copy of the thread port. Using it does |
26 // not increment its reference count. | 27 // not increment its reference count. |
27 return pthread_mach_thread_np(pthread_self()); | 28 return pthread_mach_thread_np(pthread_self()); |
28 } | 29 } |
29 | 30 |
31 mach_port_t NewMachPort(mach_port_right_t right) { | |
32 mach_port_t port; | |
Robert Sesek
2014/12/17 20:06:47
= MACH_PORT_NULL, and then you can just do MACH_LO
| |
33 kern_return_t kr = mach_port_allocate(mach_task_self(), right, &port); | |
34 if (kr != KERN_SUCCESS) { | |
35 MACH_LOG(ERROR, kr) << "mach_port_allocate"; | |
36 return MACH_PORT_NULL; | |
37 } | |
38 | |
39 return port; | |
40 } | |
41 | |
30 exception_mask_t ExcMaskAll() { | 42 exception_mask_t ExcMaskAll() { |
31 // This is necessary because of the way that the kernel validates | 43 // This is necessary because of the way that the kernel validates |
32 // exception_mask_t arguments to | 44 // exception_mask_t arguments to |
33 // {host,task,thread}_{get,set,swap}_exception_ports(). It is strict, | 45 // {host,task,thread}_{get,set,swap}_exception_ports(). It is strict, |
34 // rejecting attempts to operate on any bits that it does not recognize. See | 46 // rejecting attempts to operate on any bits that it does not recognize. See |
35 // 10.9.4 xnu-2422.110.17/osfmk/mach/ipc_host.c and | 47 // 10.9.4 xnu-2422.110.17/osfmk/mach/ipc_host.c and |
36 // xnu-2422.110.17/osfmk/mach/ipc_tt.c. | 48 // xnu-2422.110.17/osfmk/mach/ipc_tt.c. |
37 | 49 |
38 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 | 50 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 |
39 int mac_os_x_minor_version = MacOSXMinorVersion(); | 51 int mac_os_x_minor_version = MacOSXMinorVersion(); |
(...skipping 22 matching lines...) Expand all Loading... | |
62 } | 74 } |
63 #endif | 75 #endif |
64 | 76 |
65 // 10.9 added EXC_MASK_GUARD. See 10.9.4 | 77 // 10.9 added EXC_MASK_GUARD. See 10.9.4 |
66 // xnu-2422.110.17/osfmk/mach/exception_types.h. | 78 // xnu-2422.110.17/osfmk/mach/exception_types.h. |
67 const exception_mask_t kExcMaskAll_10_9 = kExcMaskAll_10_8 | EXC_MASK_GUARD; | 79 const exception_mask_t kExcMaskAll_10_9 = kExcMaskAll_10_8 | EXC_MASK_GUARD; |
68 return kExcMaskAll_10_9; | 80 return kExcMaskAll_10_9; |
69 } | 81 } |
70 | 82 |
71 } // namespace crashpad | 83 } // namespace crashpad |
OLD | NEW |