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 18 matching lines...) Expand all Loading... |
29 #include "util/mach/exc_client_variants.h" | 29 #include "util/mach/exc_client_variants.h" |
30 #include "util/mach/exception_behaviors.h" | 30 #include "util/mach/exception_behaviors.h" |
31 #include "util/mach/mach_extensions.h" | 31 #include "util/mach/mach_extensions.h" |
32 #include "util/mach/mach_message.h" | 32 #include "util/mach/mach_message.h" |
33 #include "util/mach/scoped_task_suspend.h" | 33 #include "util/mach/scoped_task_suspend.h" |
34 #include "util/misc/tri_state.h" | 34 #include "util/misc/tri_state.h" |
35 #include "util/misc/uuid.h" | 35 #include "util/misc/uuid.h" |
36 | 36 |
37 namespace crashpad { | 37 namespace crashpad { |
38 | 38 |
39 namespace { | |
40 | |
41 // Calls CrashReportDatabase::ErrorWritingCrashReport() upon destruction unless | |
42 // disarmed by calling Disarm(). Armed upon construction. | |
43 class CallErrorWritingCrashReport { | |
44 public: | |
45 CallErrorWritingCrashReport(CrashReportDatabase* database, | |
46 CrashReportDatabase::NewReport* new_report) | |
47 : database_(database), | |
48 new_report_(new_report) { | |
49 } | |
50 | |
51 ~CallErrorWritingCrashReport() { | |
52 if (new_report_) { | |
53 database_->ErrorWritingCrashReport(new_report_); | |
54 } | |
55 } | |
56 | |
57 void Disarm() { | |
58 new_report_ = nullptr; | |
59 } | |
60 | |
61 private: | |
62 CrashReportDatabase* database_; // weak | |
63 CrashReportDatabase::NewReport* new_report_; // weak | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(CallErrorWritingCrashReport); | |
66 }; | |
67 | |
68 } // namespace | |
69 | |
70 CrashReportExceptionHandler::CrashReportExceptionHandler( | 39 CrashReportExceptionHandler::CrashReportExceptionHandler( |
71 CrashReportDatabase* database, | 40 CrashReportDatabase* database, |
72 CrashReportUploadThread* upload_thread, | 41 CrashReportUploadThread* upload_thread, |
73 const std::map<std::string, std::string>* process_annotations) | 42 const std::map<std::string, std::string>* process_annotations) |
74 : database_(database), | 43 : database_(database), |
75 upload_thread_(upload_thread), | 44 upload_thread_(upload_thread), |
76 process_annotations_(process_annotations) { | 45 process_annotations_(process_annotations) { |
77 } | 46 } |
78 | 47 |
79 CrashReportExceptionHandler::~CrashReportExceptionHandler() { | 48 CrashReportExceptionHandler::~CrashReportExceptionHandler() { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 133 |
165 CrashReportDatabase::NewReport* new_report; | 134 CrashReportDatabase::NewReport* new_report; |
166 CrashReportDatabase::OperationStatus database_status = | 135 CrashReportDatabase::OperationStatus database_status = |
167 database_->PrepareNewCrashReport(&new_report); | 136 database_->PrepareNewCrashReport(&new_report); |
168 if (database_status != CrashReportDatabase::kNoError) { | 137 if (database_status != CrashReportDatabase::kNoError) { |
169 return KERN_FAILURE; | 138 return KERN_FAILURE; |
170 } | 139 } |
171 | 140 |
172 process_snapshot.SetReportID(new_report->uuid); | 141 process_snapshot.SetReportID(new_report->uuid); |
173 | 142 |
174 CallErrorWritingCrashReport call_error_writing_crash_report(database_, | 143 CrashReportDatabase::CallErrorWritingCrashReport |
175 new_report); | 144 call_error_writing_crash_report(database_, new_report); |
176 | 145 |
177 WeakFileHandleFileWriter file_writer(new_report->handle); | 146 WeakFileHandleFileWriter file_writer(new_report->handle); |
178 | 147 |
179 MinidumpFileWriter minidump; | 148 MinidumpFileWriter minidump; |
180 minidump.InitializeFromSnapshot(&process_snapshot); | 149 minidump.InitializeFromSnapshot(&process_snapshot); |
181 if (!minidump.WriteEverything(&file_writer)) { | 150 if (!minidump.WriteEverything(&file_writer)) { |
182 return KERN_FAILURE; | 151 return KERN_FAILURE; |
183 } | 152 } |
184 | 153 |
185 call_error_writing_crash_report.Disarm(); | 154 call_error_writing_crash_report.Disarm(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 &new_state_forward_count); | 214 &new_state_forward_count); |
246 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) | 215 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) |
247 << "UniversalExceptionRaise " << kSystemCrashReporterServiceName; | 216 << "UniversalExceptionRaise " << kSystemCrashReporterServiceName; |
248 } | 217 } |
249 } | 218 } |
250 | 219 |
251 return ExcServerSuccessfulReturnValue(behavior, false); | 220 return ExcServerSuccessfulReturnValue(behavior, false); |
252 } | 221 } |
253 | 222 |
254 } // namespace crashpad | 223 } // namespace crashpad |
OLD | NEW |