From 7a997fb25352a1c0cf99020ee82c4dfeae251eda Mon Sep 17 00:00:00 2001 From: Miriam Zimmerman Date: Tue, 21 Feb 2023 14:44:59 -0500 Subject: [PATCH] Report exception number in metadata on CrOS. In order to determine in crash_reporter whether a crash was fatal, we need the exception number (-1 is not an actual crash). BUG=b:269159625 TEST=deploy to DUT; chrome://crashdump; verify metadata present. Change-Id: I83d3c9cc839a685af2f50d143d627cf9fcfaf3ac Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4265253 Reviewed-by: Joshua Peraza Commit-Queue: Miriam Zimmerman --- handler/linux/cros_crash_report_exception_handler.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/handler/linux/cros_crash_report_exception_handler.cc b/handler/linux/cros_crash_report_exception_handler.cc index a3a68552..86142883 100644 --- a/handler/linux/cros_crash_report_exception_handler.cc +++ b/handler/linux/cros_crash_report_exception_handler.cc @@ -17,6 +17,7 @@ #include #include "base/logging.h" +#include "base/strings/stringprintf.h" #include "client/settings.h" #include "handler/linux/capture_snapshot.h" #include "handler/minidump_to_upload_parameters.h" @@ -246,6 +247,16 @@ bool CrosCrashReportExceptionHandler::HandleExceptionWithConnection( // crash_reporter needs to know the pid and uid of the crashing process. std::vector argv({"/sbin/crash_reporter"}); + // Used to distinguish between non-fatal and fatal crashes. + const ExceptionSnapshot* const exception_snapshot = snapshot->Exception(); + if (exception_snapshot) { + // convert to int32, since crashpad uses -1 as a signal for non-fatal + // crashes. + argv.push_back(base::StringPrintf( + "--chrome_signal=%d", + static_cast(exception_snapshot->Exception()))); + } + argv.push_back("--chrome_memfd=" + std::to_string(file_writer.fd())); const pid_t pid = process_snapshot->ProcessID();