| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 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, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // Don’t forward simulated exceptions such as kMachExceptionSimulated to the | 179 // Don’t forward simulated exceptions such as kMachExceptionSimulated to the |
| 180 // system crash reporter. Only forward the types of exceptions that it would | 180 // system crash reporter. Only forward the types of exceptions that it would |
| 181 // receive under normal conditions. Although the system crash reporter is | 181 // receive under normal conditions. Although the system crash reporter is |
| 182 // able to deal with other exceptions including simulated ones, forwarding | 182 // able to deal with other exceptions including simulated ones, forwarding |
| 183 // them to the system crash reporter could present the system’s crash UI for | 183 // them to the system crash reporter could present the system’s crash UI for |
| 184 // processes that haven’t actually crashed, and could result in reports not | 184 // processes that haven’t actually crashed, and could result in reports not |
| 185 // actually associated with crashes being sent to the operating system | 185 // actually associated with crashes being sent to the operating system |
| 186 // vendor. | 186 // vendor. |
| 187 base::mac::ScopedMachSendRight | 187 base::mac::ScopedMachSendRight |
| 188 system_crash_reporter_handler(SystemCrashReporterHandler()); | 188 system_crash_reporter_handler(SystemCrashReporterHandler()); |
| 189 if (system_crash_reporter_handler) { | 189 if (system_crash_reporter_handler.get()) { |
| 190 // Make copies of mutable out parameters so that the system crash reporter | 190 // Make copies of mutable out parameters so that the system crash reporter |
| 191 // can’t influence the state returned by this method. | 191 // can’t influence the state returned by this method. |
| 192 thread_state_flavor_t flavor_forward = *flavor; | 192 thread_state_flavor_t flavor_forward = *flavor; |
| 193 mach_msg_type_number_t new_state_forward_count = *new_state_count; | 193 mach_msg_type_number_t new_state_forward_count = *new_state_count; |
| 194 std::vector<natural_t> new_state_forward( | 194 std::vector<natural_t> new_state_forward( |
| 195 new_state, new_state + new_state_forward_count); | 195 new_state, new_state + new_state_forward_count); |
| 196 | 196 |
| 197 // The system crash reporter requires the behavior to be | 197 // The system crash reporter requires the behavior to be |
| 198 // EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES. It uses the identity | 198 // EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES. It uses the identity |
| 199 // parameters but doesn’t appear to use the state parameters, including | 199 // parameters but doesn’t appear to use the state parameters, including |
| 200 // |flavor|, and doesn’t care if they are 0 or invalid. As long as an | 200 // |flavor|, and doesn’t care if they are 0 or invalid. As long as an |
| 201 // identity is available (checked above), any other exception behavior is | 201 // identity is available (checked above), any other exception behavior is |
| 202 // converted to what the system crash reporter wants, with the caveat that | 202 // converted to what the system crash reporter wants, with the caveat that |
| 203 // problems may arise if the state wasn’t available and the system crash | 203 // problems may arise if the state wasn’t available and the system crash |
| 204 // reporter changes in the future to use it. However, normally, the state | 204 // reporter changes in the future to use it. However, normally, the state |
| 205 // will be available. | 205 // will be available. |
| 206 kern_return_t kr = UniversalExceptionRaise( | 206 kern_return_t kr = UniversalExceptionRaise( |
| 207 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, | 207 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, |
| 208 system_crash_reporter_handler, | 208 system_crash_reporter_handler.get(), |
| 209 thread, | 209 thread, |
| 210 task, | 210 task, |
| 211 exception, | 211 exception, |
| 212 code, | 212 code, |
| 213 code_count, | 213 code_count, |
| 214 &flavor_forward, | 214 &flavor_forward, |
| 215 old_state, | 215 old_state, |
| 216 old_state_count, | 216 old_state_count, |
| 217 new_state_forward_count ? &new_state_forward[0] : nullptr, | 217 new_state_forward_count ? &new_state_forward[0] : nullptr, |
| 218 &new_state_forward_count); | 218 &new_state_forward_count); |
| 219 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) << "UniversalExceptionRaise"; | 219 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) << "UniversalExceptionRaise"; |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 ExcServerCopyState( | 223 ExcServerCopyState( |
| 224 behavior, old_state, old_state_count, new_state, new_state_count); | 224 behavior, old_state, old_state_count, new_state, new_state_count); |
| 225 | 225 |
| 226 return ExcServerSuccessfulReturnValue(exception, behavior, false); | 226 return ExcServerSuccessfulReturnValue(exception, behavior, false); |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace crashpad | 229 } // namespace crashpad |
| OLD | NEW |