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/exception_ports.h" | 15 #include "util/mach/exception_ports.h" |
16 | 16 |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/mac/mach_logging.h" | 18 #include "base/mac/mach_logging.h" |
19 | 19 |
20 namespace crashpad { | 20 namespace crashpad { |
21 | 21 |
22 ExceptionPorts::ExceptionPorts(TargetType target_type, mach_port_t target_port) | 22 ExceptionPorts::ExceptionPorts(TargetType target_type, mach_port_t target_port) |
23 : target_port_(target_port), dealloc_target_port_(false) { | 23 : target_port_(target_port), dealloc_target_port_(false) { |
24 switch (target_type) { | 24 switch (target_type) { |
25 case kTargetTypeHost: | 25 case kTargetTypeHost: |
26 get_exception_ports_ = host_get_exception_ports; | 26 get_exception_ports_ = host_get_exception_ports; |
27 set_exception_ports_ = host_set_exception_ports; | 27 set_exception_ports_ = host_set_exception_ports; |
28 target_name_ = "host"; | 28 target_name_ = "host"; |
29 if (target_port_ == MACH_PORT_NULL) { | 29 if (target_port_ == HOST_NULL) { |
30 target_port_ = mach_host_self(); | 30 target_port_ = mach_host_self(); |
31 dealloc_target_port_ = true; | 31 dealloc_target_port_ = true; |
32 } | 32 } |
33 break; | 33 break; |
34 | 34 |
35 case kTargetTypeTask: | 35 case kTargetTypeTask: |
36 get_exception_ports_ = task_get_exception_ports; | 36 get_exception_ports_ = task_get_exception_ports; |
37 set_exception_ports_ = task_set_exception_ports; | 37 set_exception_ports_ = task_set_exception_ports; |
38 target_name_ = "task"; | 38 target_name_ = "task"; |
39 if (target_port_ == MACH_PORT_NULL) { | 39 if (target_port_ == TASK_NULL) { |
40 target_port_ = mach_task_self(); | 40 target_port_ = mach_task_self(); |
41 // Don’t deallocate mach_task_self(). | 41 // Don’t deallocate mach_task_self(). |
42 } | 42 } |
43 break; | 43 break; |
44 | 44 |
45 case kTargetTypeThread: | 45 case kTargetTypeThread: |
46 get_exception_ports_ = thread_get_exception_ports; | 46 get_exception_ports_ = thread_get_exception_ports; |
47 set_exception_ports_ = thread_set_exception_ports; | 47 set_exception_ports_ = thread_set_exception_ports; |
48 target_name_ = "thread"; | 48 target_name_ = "thread"; |
49 if (target_port_ == MACH_PORT_NULL) { | 49 if (target_port_ == THREAD_NULL) { |
50 target_port_ = mach_thread_self(); | 50 target_port_ = mach_thread_self(); |
51 dealloc_target_port_ = true; | 51 dealloc_target_port_ = true; |
52 } | 52 } |
53 break; | 53 break; |
54 | 54 |
55 default: | 55 default: |
56 NOTREACHED(); | 56 NOTREACHED(); |
57 get_exception_ports_ = NULL; | 57 get_exception_ports_ = NULL; |
58 set_exception_ports_ = NULL; | 58 set_exception_ports_ = NULL; |
59 target_name_ = NULL; | 59 target_name_ = NULL; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 return true; | 126 return true; |
127 } | 127 } |
128 | 128 |
129 const char* ExceptionPorts::TargetTypeName() const { | 129 const char* ExceptionPorts::TargetTypeName() const { |
130 return target_name_; | 130 return target_name_; |
131 } | 131 } |
132 | 132 |
133 } // namespace crashpad | 133 } // namespace crashpad |
OLD | NEW |