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 "client/simulate_crash_mac.h" | 15 #include "client/simulate_crash_mac.h" |
16 | 16 |
17 #include <string.h> | 17 #include <string.h> |
18 | 18 |
19 #include <vector> | |
20 | |
21 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
22 #include "base/logging.h" | 20 #include "base/logging.h" |
23 #include "base/mac/mach_logging.h" | 21 #include "base/mac/mach_logging.h" |
24 #include "base/mac/scoped_mach_port.h" | 22 #include "base/mac/scoped_mach_port.h" |
25 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
26 #include "build/build_config.h" | 24 #include "build/build_config.h" |
27 #include "util/mach/exc_client_variants.h" | 25 #include "util/mach/exc_client_variants.h" |
28 #include "util/mach/exception_behaviors.h" | 26 #include "util/mach/exception_behaviors.h" |
29 #include "util/mach/exception_ports.h" | 27 #include "util/mach/exception_ports.h" |
30 #include "util/mach/mach_extensions.h" | 28 #include "util/mach/mach_extensions.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // xnu-2422.115.4/osfmk/kern/task.c host_security_set_task_token(), and | 207 // xnu-2422.115.4/osfmk/kern/task.c host_security_set_task_token(), and |
210 // xnu-2422.115.4/osfmk/kern/ipc_host.c host_get_exception_ports(). | 208 // xnu-2422.115.4/osfmk/kern/ipc_host.c host_get_exception_ports(). |
211 ExceptionPorts::kTargetTypeHost, | 209 ExceptionPorts::kTargetTypeHost, |
212 }; | 210 }; |
213 | 211 |
214 bool success = false; | 212 bool success = false; |
215 | 213 |
216 for (size_t target_type_index = 0; | 214 for (size_t target_type_index = 0; |
217 !success && target_type_index < arraysize(kTargetTypes); | 215 !success && target_type_index < arraysize(kTargetTypes); |
218 ++target_type_index) { | 216 ++target_type_index) { |
219 std::vector<ExceptionPorts::ExceptionHandler> handlers; | 217 ExceptionPorts::ExceptionHandlerVector handlers; |
220 ExceptionPorts exception_ports(kTargetTypes[target_type_index], | 218 ExceptionPorts exception_ports(kTargetTypes[target_type_index], |
221 MACH_PORT_NULL); | 219 MACH_PORT_NULL); |
222 if (exception_ports.GetExceptionPorts(EXC_MASK_CRASH, &handlers)) { | 220 if (exception_ports.GetExceptionPorts(EXC_MASK_CRASH, &handlers)) { |
223 DCHECK_LE(handlers.size(), 1u); | 221 DCHECK_LE(handlers.size(), 1u); |
224 if (handlers.size() == 1) { | 222 if (handlers.size() == 1) { |
225 DCHECK(handlers[0].mask & EXC_MASK_CRASH); | 223 DCHECK(handlers[0].mask & EXC_MASK_CRASH); |
226 success = DeliverException(thread, | 224 success = DeliverException(thread, |
227 mach_task_self(), | 225 mach_task_self(), |
228 exception, | 226 exception, |
229 codes, | 227 codes, |
230 code_count, | 228 code_count, |
231 cpu_context, | 229 cpu_context, |
232 handlers[0], | 230 handlers[0], |
233 false); | 231 false); |
234 } | 232 } |
235 } | 233 } |
236 } | 234 } |
237 | 235 |
238 LOG_IF(WARNING, !success) | 236 LOG_IF(WARNING, !success) |
239 << "SimulateCrash did not find an appropriate exception handler"; | 237 << "SimulateCrash did not find an appropriate exception handler"; |
240 } | 238 } |
241 | 239 |
242 } // namespace crashpad | 240 } // namespace crashpad |
OLD | NEW |