From 604f5c0d3dfdb60302d68f1c08c86728f82aae46 Mon Sep 17 00:00:00 2001 From: Thieu Le Date: Mon, 28 Feb 2011 10:51:18 -0800 Subject: [PATCH] Modify crash-reporter to collect crash information for unofficial builds. BUG=chromium-os:12207 TESTS=logging_UserCrash, logging_CrashSender, manual test which involves purposely crashing a test to determine if minidump information is properly collected Change-Id: Id2195125289a695515b1722442116d6a6d9c4895 Review URL: http://codereview.chromium.org/6559003 --- crash_reporter/crash_collector.cc | 5 +++++ crash_reporter/crash_collector.h | 3 +++ crash_reporter/user_collector.cc | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/crash_reporter/crash_collector.cc b/crash_reporter/crash_collector.cc index afd72d1e1..bdad63f55 100644 --- a/crash_reporter/crash_collector.cc +++ b/crash_reporter/crash_collector.cc @@ -24,6 +24,7 @@ static const char kLsbRelease[] = "/etc/lsb-release"; static const char kShellPath[] = "/bin/sh"; static const char kSystemCrashPath[] = "/var/spool/crash"; static const char kUserCrashPath[] = "/home/chronos/user/crash"; +static const char kCrashTestInProgressPath[] = "/tmp/crash-test-in-progress"; // Directory mode of the user crash spool directory. static const mode_t kUserCrashPathMode = 0755; @@ -410,3 +411,7 @@ void CrashCollector::WriteCrashMetaData(const FilePath &meta_path, logger_->LogError("Unable to write %s", meta_path.value().c_str()); } } + +bool CrashCollector::IsCrashTestInProgress() { + return file_util::PathExists(FilePath(kCrashTestInProgressPath)); +} diff --git a/crash_reporter/crash_collector.h b/crash_reporter/crash_collector.h index f3fcbe596..668039991 100644 --- a/crash_reporter/crash_collector.h +++ b/crash_reporter/crash_collector.h @@ -138,6 +138,9 @@ class CrashCollector { const std::string &exec_name, const std::string &payload_path); + // Returns true if the a crash test is currently running. + bool IsCrashTestInProgress(); + CountCrashFunction count_crash_function_; IsFeedbackAllowedFunction is_feedback_allowed_function_; SystemLogging *logger_; diff --git a/crash_reporter/user_collector.cc b/crash_reporter/user_collector.cc index 6e6c76596..13df5ce91 100644 --- a/crash_reporter/user_collector.cc +++ b/crash_reporter/user_collector.cc @@ -472,6 +472,13 @@ bool UserCollector::HandleCrash(const std::string &crash_attributes, logger_->LogWarning("Received crash notification for %s[%d] sig %d (%s)", exec.c_str(), pid, signal, handling_string); + // For developer builds, we always want to keep the crash reports unless + // we're testing the crash facilities themselves. + if (file_util::PathExists(FilePath(kLeaveCoreFile)) && + !IsCrashTestInProgress()) { + feedback = true; + } + if (feedback) { count_crash_function_();