mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
[fuchsia] early return in handler on disable
Tested:CQ Change-Id: Ifd742a7bfb213e4286bad582c81963e2fb383551 Reviewed-on: https://chromium-review.googlesource.com/c/1309156 Reviewed-by: Scott Graham <scottmg@chromium.org> Commit-Queue: Francois Rousseau <frousseau@google.com>
This commit is contained in:
parent
5dd094381c
commit
96391cb80f
@ -109,85 +109,87 @@ bool CrashReportExceptionHandler::HandleExceptionHandles(
|
||||
CrashpadInfoClientOptions client_options;
|
||||
process_snapshot.GetCrashpadOptions(&client_options);
|
||||
|
||||
if (client_options.crashpad_handler_behavior != TriState::kDisabled) {
|
||||
zx_exception_report_t report;
|
||||
zx_status_t status = thread.get_info(ZX_INFO_THREAD_EXCEPTION_REPORT,
|
||||
&report,
|
||||
sizeof(report),
|
||||
nullptr,
|
||||
nullptr);
|
||||
if (status != ZX_OK) {
|
||||
ZX_LOG(ERROR, status)
|
||||
<< "zx_object_get_info ZX_INFO_THREAD_EXCEPTION_REPORT";
|
||||
return false;
|
||||
}
|
||||
if (client_options.crashpad_handler_behavior == TriState::kDisabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
zx_koid_t thread_id = GetKoidForHandle(thread);
|
||||
if (!process_snapshot.InitializeException(thread_id, report)) {
|
||||
return false;
|
||||
}
|
||||
zx_exception_report_t report;
|
||||
zx_status_t status = thread.get_info(ZX_INFO_THREAD_EXCEPTION_REPORT,
|
||||
&report,
|
||||
sizeof(report),
|
||||
nullptr,
|
||||
nullptr);
|
||||
if (status != ZX_OK) {
|
||||
ZX_LOG(ERROR, status)
|
||||
<< "zx_object_get_info ZX_INFO_THREAD_EXCEPTION_REPORT";
|
||||
return false;
|
||||
}
|
||||
|
||||
UUID client_id;
|
||||
Settings* const settings = database_->GetSettings();
|
||||
if (settings) {
|
||||
// If GetSettings() or GetClientID() fails, something else will log a
|
||||
// message and client_id will be left at its default value, all zeroes,
|
||||
// which is appropriate.
|
||||
settings->GetClientID(&client_id);
|
||||
}
|
||||
zx_koid_t thread_id = GetKoidForHandle(thread);
|
||||
if (!process_snapshot.InitializeException(thread_id, report)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
process_snapshot.SetClientID(client_id);
|
||||
process_snapshot.SetAnnotationsSimpleMap(*process_annotations_);
|
||||
UUID client_id;
|
||||
Settings* const settings = database_->GetSettings();
|
||||
if (settings) {
|
||||
// If GetSettings() or GetClientID() fails, something else will log a
|
||||
// message and client_id will be left at its default value, all zeroes,
|
||||
// which is appropriate.
|
||||
settings->GetClientID(&client_id);
|
||||
}
|
||||
|
||||
std::unique_ptr<CrashReportDatabase::NewReport> new_report;
|
||||
CrashReportDatabase::OperationStatus database_status =
|
||||
database_->PrepareNewCrashReport(&new_report);
|
||||
if (database_status != CrashReportDatabase::kNoError) {
|
||||
return false;
|
||||
}
|
||||
process_snapshot.SetClientID(client_id);
|
||||
process_snapshot.SetAnnotationsSimpleMap(*process_annotations_);
|
||||
|
||||
process_snapshot.SetReportID(new_report->ReportID());
|
||||
std::unique_ptr<CrashReportDatabase::NewReport> new_report;
|
||||
CrashReportDatabase::OperationStatus database_status =
|
||||
database_->PrepareNewCrashReport(&new_report);
|
||||
if (database_status != CrashReportDatabase::kNoError) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MinidumpFileWriter minidump;
|
||||
minidump.InitializeFromSnapshot(&process_snapshot);
|
||||
AddUserExtensionStreams(
|
||||
user_stream_data_sources_, &process_snapshot, &minidump);
|
||||
process_snapshot.SetReportID(new_report->ReportID());
|
||||
|
||||
if (!minidump.WriteEverything(new_report->Writer())) {
|
||||
return false;
|
||||
}
|
||||
MinidumpFileWriter minidump;
|
||||
minidump.InitializeFromSnapshot(&process_snapshot);
|
||||
AddUserExtensionStreams(
|
||||
user_stream_data_sources_, &process_snapshot, &minidump);
|
||||
|
||||
if (process_attachments_) {
|
||||
// Note that attachments are read at this point each time rather than once
|
||||
// so that if the contents of the file has changed it will be re-read for
|
||||
// each upload (e.g. in the case of a log file).
|
||||
for (const auto& it : *process_attachments_) {
|
||||
FileWriter* writer = new_report->AddAttachment(it.first);
|
||||
if (writer) {
|
||||
std::string contents;
|
||||
if (!LoggingReadEntireFile(it.second, &contents)) {
|
||||
// Not being able to read the file isn't considered fatal, and
|
||||
// should not prevent the report from being processed.
|
||||
continue;
|
||||
}
|
||||
writer->Write(contents.data(), contents.size());
|
||||
if (!minidump.WriteEverything(new_report->Writer())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (process_attachments_) {
|
||||
// Note that attachments are read at this point each time rather than once
|
||||
// so that if the contents of the file has changed it will be re-read for
|
||||
// each upload (e.g. in the case of a log file).
|
||||
for (const auto& it : *process_attachments_) {
|
||||
FileWriter* writer = new_report->AddAttachment(it.first);
|
||||
if (writer) {
|
||||
std::string contents;
|
||||
if (!LoggingReadEntireFile(it.second, &contents)) {
|
||||
// Not being able to read the file isn't considered fatal, and
|
||||
// should not prevent the report from being processed.
|
||||
continue;
|
||||
}
|
||||
writer->Write(contents.data(), contents.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UUID uuid;
|
||||
database_status =
|
||||
database_->FinishedWritingCrashReport(std::move(new_report), &uuid);
|
||||
if (database_status != CrashReportDatabase::kNoError) {
|
||||
return false;
|
||||
}
|
||||
if (local_report_id != nullptr) {
|
||||
*local_report_id = uuid;
|
||||
}
|
||||
UUID uuid;
|
||||
database_status =
|
||||
database_->FinishedWritingCrashReport(std::move(new_report), &uuid);
|
||||
if (database_status != CrashReportDatabase::kNoError) {
|
||||
return false;
|
||||
}
|
||||
if (local_report_id != nullptr) {
|
||||
*local_report_id = uuid;
|
||||
}
|
||||
|
||||
if (upload_thread_) {
|
||||
upload_thread_->ReportPending(uuid);
|
||||
}
|
||||
if (upload_thread_) {
|
||||
upload_thread_->ReportPending(uuid);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user