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

Side by Side Diff: handler/mac/crash_report_exception_handler.cc

Issue 1375573005: mac: Add CrashpadClient::UseSystemDefaultHandler() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 5 years, 2 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
« no previous file with comments | « client/crashpad_client_mac.cc ('k') | util/mach/mach_extensions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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,
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 "handler/mac/crash_report_exception_handler.h" 15 #include "handler/mac/crash_report_exception_handler.h"
16 16
17 #include <servers/bootstrap.h>
18
19 #include <vector> 17 #include <vector>
20 18
21 #include "base/logging.h" 19 #include "base/logging.h"
22 #include "base/mac/mach_logging.h" 20 #include "base/mac/mach_logging.h"
21 #include "base/mac/scoped_mach_port.h"
23 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
24 #include "client/settings.h" 23 #include "client/settings.h"
25 #include "minidump/minidump_file_writer.h" 24 #include "minidump/minidump_file_writer.h"
26 #include "snapshot/crashpad_info_client_options.h" 25 #include "snapshot/crashpad_info_client_options.h"
27 #include "snapshot/mac/process_snapshot_mac.h" 26 #include "snapshot/mac/process_snapshot_mac.h"
28 #include "util/file/file_writer.h" 27 #include "util/file/file_writer.h"
29 #include "util/mach/exc_client_variants.h" 28 #include "util/mach/exc_client_variants.h"
30 #include "util/mach/exception_behaviors.h" 29 #include "util/mach/exception_behaviors.h"
31 #include "util/mach/exception_types.h" 30 #include "util/mach/exception_types.h"
32 #include "util/mach/mach_extensions.h" 31 #include "util/mach/mach_extensions.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // receive under normal conditions. Although the system crash reporter is 194 // receive under normal conditions. Although the system crash reporter is
196 // able to deal with other exceptions including simulated ones, forwarding 195 // able to deal with other exceptions including simulated ones, forwarding
197 // them to the system crash reporter could present the system’s crash UI for 196 // them to the system crash reporter could present the system’s crash UI for
198 // processes that haven’t actually crashed, and could result in reports not 197 // processes that haven’t actually crashed, and could result in reports not
199 // actually associated with crashes being sent to the operating system 198 // actually associated with crashes being sent to the operating system
200 // vendor. 199 // vendor.
201 // 200 //
202 // Note that normally, EXC_RESOURCE and EXC_GUARD exceptions are sent to the 201 // Note that normally, EXC_RESOURCE and EXC_GUARD exceptions are sent to the
203 // system-level com.apple.ReportCrash.Root job, and not to the user-level 202 // system-level com.apple.ReportCrash.Root job, and not to the user-level
204 // job that they are forwarded to here. 203 // job that they are forwarded to here.
205 mach_port_t system_crash_reporter_port; 204 base::mac::ScopedMachSendRight
206 const char kSystemCrashReporterServiceName[] = "com.apple.ReportCrash"; 205 system_crash_reporter_handler(SystemCrashReporterHandler());
207 kern_return_t kr = bootstrap_look_up(bootstrap_port, 206 if (system_crash_reporter_handler) {
208 kSystemCrashReporterServiceName,
209 &system_crash_reporter_port);
210 if (kr != BOOTSTRAP_SUCCESS) {
211 BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_look_up "
212 << kSystemCrashReporterServiceName;
213 } else {
214 // Make copies of mutable out parameters so that the system crash reporter 207 // Make copies of mutable out parameters so that the system crash reporter
215 // can’t influence the state returned by this method. 208 // can’t influence the state returned by this method.
216 thread_state_flavor_t flavor_forward = *flavor; 209 thread_state_flavor_t flavor_forward = *flavor;
217 mach_msg_type_number_t new_state_forward_count = *new_state_count; 210 mach_msg_type_number_t new_state_forward_count = *new_state_count;
218 std::vector<natural_t> new_state_forward( 211 std::vector<natural_t> new_state_forward(
219 new_state, new_state + new_state_forward_count); 212 new_state, new_state + new_state_forward_count);
220 213
221 // The system crash reporter requires the behavior to be 214 // The system crash reporter requires the behavior to be
222 // EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES. It uses the identity 215 // EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES. It uses the identity
223 // parameters but doesn’t appear to use the state parameters, including 216 // parameters but doesn’t appear to use the state parameters, including
224 // |flavor|, and doesn’t care if they are 0 or invalid. As long as an 217 // |flavor|, and doesn’t care if they are 0 or invalid. As long as an
225 // identity is available (checked above), any other exception behavior is 218 // identity is available (checked above), any other exception behavior is
226 // converted to what the system crash reporter wants, with the caveat that 219 // converted to what the system crash reporter wants, with the caveat that
227 // problems may arise if the state wasn’t available and the system crash 220 // problems may arise if the state wasn’t available and the system crash
228 // reporter changes in the future to use it. However, normally, the state 221 // reporter changes in the future to use it. However, normally, the state
229 // will be available. 222 // will be available.
230 kr = UniversalExceptionRaise( 223 kern_return_t kr = UniversalExceptionRaise(
231 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, 224 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES,
232 system_crash_reporter_port, 225 system_crash_reporter_handler,
233 thread, 226 thread,
234 task, 227 task,
235 exception, 228 exception,
236 code, 229 code,
237 code_count, 230 code_count,
238 &flavor_forward, 231 &flavor_forward,
239 old_state, 232 old_state,
240 old_state_count, 233 old_state_count,
241 new_state_forward_count ? &new_state_forward[0] : nullptr, 234 new_state_forward_count ? &new_state_forward[0] : nullptr,
242 &new_state_forward_count); 235 &new_state_forward_count);
243 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) 236 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) << "UniversalExceptionRaise";
244 << "UniversalExceptionRaise " << kSystemCrashReporterServiceName;
245 } 237 }
246 } 238 }
247 239
248 ExcServerCopyState( 240 ExcServerCopyState(
249 behavior, old_state, old_state_count, new_state, new_state_count); 241 behavior, old_state, old_state_count, new_state, new_state_count);
250 242
251 return ExcServerSuccessfulReturnValue(exception, behavior, false); 243 return ExcServerSuccessfulReturnValue(exception, behavior, false);
252 } 244 }
253 245
254 } // namespace crashpad 246 } // namespace crashpad
OLDNEW
« no previous file with comments | « client/crashpad_client_mac.cc ('k') | util/mach/mach_extensions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698