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

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

Issue 997713002: Allow exception forwarding to the system’s native crash reporter to be disabled (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 9 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
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,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return KERN_FAILURE; 109 return KERN_FAILURE;
110 } 110 }
111 111
112 ScopedTaskSuspend suspend(task); 112 ScopedTaskSuspend suspend(task);
113 113
114 ProcessSnapshotMac process_snapshot; 114 ProcessSnapshotMac process_snapshot;
115 if (!process_snapshot.Initialize(task)) { 115 if (!process_snapshot.Initialize(task)) {
116 return KERN_FAILURE; 116 return KERN_FAILURE;
117 } 117 }
118 118
119 if (!process_snapshot.InitializeException(thread, 119 CrashpadInfo::TriState enable_crashpad_handler;
120 exception, 120 CrashpadInfo::TriState enable_native_crash_reporter_forwarding;
121 code, 121 process_snapshot.GetCrashpadOptions(&enable_crashpad_handler,
122 code_count, 122 &enable_native_crash_reporter_forwarding);
123 *flavor, 123
124 old_state, 124 if (enable_crashpad_handler != CrashpadInfo::kDisabled) {
125 old_state_count)) { 125 if (!process_snapshot.InitializeException(thread,
126 return KERN_FAILURE; 126 exception,
127 code,
128 code_count,
129 *flavor,
130 old_state,
131 old_state_count)) {
132 return KERN_FAILURE;
133 }
134
135 process_snapshot.SetAnnotationsSimpleMap(*process_annotations_);
136
137 CrashReportDatabase::NewReport* new_report;
138 CrashReportDatabase::OperationStatus database_status =
139 database_->PrepareNewCrashReport(&new_report);
140 if (database_status != CrashReportDatabase::kNoError) {
141 return KERN_FAILURE;
142 }
143
144 CallErrorWritingCrashReport call_error_writing_crash_report(database_,
145 new_report);
146
147 WeakFileHandleFileWriter file_writer(new_report->handle);
148
149 MinidumpFileWriter minidump;
150 minidump.InitializeFromSnapshot(&process_snapshot);
151 if (!minidump.WriteEverything(&file_writer)) {
152 return KERN_FAILURE;
153 }
154
155 call_error_writing_crash_report.Disarm();
156
157 UUID uuid;
158 database_status = database_->FinishedWritingCrashReport(new_report, &uuid);
159 if (database_status != CrashReportDatabase::kNoError) {
160 return KERN_FAILURE;
161 }
162
163 upload_thread_->ReportPending();
127 } 164 }
128 165
129 process_snapshot.SetAnnotationsSimpleMap(*process_annotations_); 166 if (enable_native_crash_reporter_forwarding != CrashpadInfo::kDisabled &&
130 167 (exception == EXC_CRASH ||
131 CrashReportDatabase::NewReport* new_report; 168 exception == EXC_RESOURCE ||
132 CrashReportDatabase::OperationStatus database_status = 169 exception == EXC_GUARD)) {
133 database_->PrepareNewCrashReport(&new_report);
134 if (database_status != CrashReportDatabase::kNoError) {
135 return KERN_FAILURE;
136 }
137
138 CallErrorWritingCrashReport call_error_writing_crash_report(database_,
139 new_report);
140
141 WeakFileHandleFileWriter file_writer(new_report->handle);
142
143 MinidumpFileWriter minidump;
144 minidump.InitializeFromSnapshot(&process_snapshot);
145 if (!minidump.WriteEverything(&file_writer)) {
146 return KERN_FAILURE;
147 }
148
149 call_error_writing_crash_report.Disarm();
150
151 UUID uuid;
152 database_status = database_->FinishedWritingCrashReport(new_report, &uuid);
153 if (database_status != CrashReportDatabase::kNoError) {
154 return KERN_FAILURE;
155 }
156
157 upload_thread_->ReportPending();
158
159 if (exception == EXC_CRASH ||
160 exception == EXC_RESOURCE ||
161 exception == EXC_GUARD) {
162 // Don’t forward simulated exceptions such as kMachExceptionSimulated to the 170 // Don’t forward simulated exceptions such as kMachExceptionSimulated to the
163 // system crash reporter. Only forward the types of exceptions that it would 171 // system crash reporter. Only forward the types of exceptions that it would
164 // receive under normal conditions. Although the system crash reporter is 172 // receive under normal conditions. Although the system crash reporter is
165 // able to deal with other exceptions including simulated ones, forwarding 173 // able to deal with other exceptions including simulated ones, forwarding
166 // them to the system crash reporter could present the system’s crash UI for 174 // them to the system crash reporter could present the system’s crash UI for
167 // processes that haven’t actually crashed, and could result in reports not 175 // processes that haven’t actually crashed, and could result in reports not
168 // actually associated with crashes being sent to the operating system 176 // actually associated with crashes being sent to the operating system
169 // vendor. 177 // vendor.
170 mach_port_t system_crash_reporter_port; 178 mach_port_t system_crash_reporter_port;
171 const char kSystemCrashReporterServiceName[] = "com.apple.ReportCrash"; 179 const char kSystemCrashReporterServiceName[] = "com.apple.ReportCrash";
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 &new_state_forward_count); 215 &new_state_forward_count);
208 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) 216 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr)
209 << "UniversalExceptionRaise " << kSystemCrashReporterServiceName; 217 << "UniversalExceptionRaise " << kSystemCrashReporterServiceName;
210 } 218 }
211 } 219 }
212 220
213 return ExcServerSuccessfulReturnValue(behavior, false); 221 return ExcServerSuccessfulReturnValue(behavior, false);
214 } 222 }
215 223
216 } // namespace crashpad 224 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698