From 2105b49796f2b753b44ccc792fd387dd0dddf54f Mon Sep 17 00:00:00 2001 From: Ken Mixter Date: Tue, 9 Nov 2010 16:14:38 -0800 Subject: [PATCH] crash-reporter: Ignore Chrome crashes, relying on Chrome breakpad Change-Id: I08e44d2c8b6be839d18efd2fe6e8b612a61ae723 BUG=8841 TEST=bvts Review URL: http://codereview.chromium.org/4499006 --- crash_reporter/user_collector.cc | 16 ++++++++++++++-- crash_reporter/user_collector_test.cc | 27 +++++++++++++++++++-------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/crash_reporter/user_collector.cc b/crash_reporter/user_collector.cc index 6fa368d05..f15c5783d 100644 --- a/crash_reporter/user_collector.cc +++ b/crash_reporter/user_collector.cc @@ -382,9 +382,21 @@ bool UserCollector::HandleCrash(int signal, int pid, const char *force_exec) { } bool feedback = is_feedback_allowed_function_(); + const char *handling_string = "handling"; + if (!feedback) { + handling_string = "ignoring - no consent"; + } + + // Treat Chrome crashes as if the user opted-out. We stop counting Chrome + // crashes towards user crashes, so user crashes really mean non-Chrome + // user-space crashes. + if (exec == "chrome") { + feedback = false; + handling_string = "ignoring - chrome crash"; + } + logger_->LogWarning("Received crash notification for %s[%d] sig %d (%s)", - exec.c_str(), pid, signal, - feedback ? "handling" : "ignoring - no consent"); + exec.c_str(), pid, signal, handling_string); if (feedback) { count_crash_function_(); diff --git a/crash_reporter/user_collector_test.cc b/crash_reporter/user_collector_test.cc index 06ba9b8f5..faa168912 100644 --- a/crash_reporter/user_collector_test.cc +++ b/crash_reporter/user_collector_test.cc @@ -89,19 +89,30 @@ TEST_F(UserCollectorTest, DisableNoFileAccess) { TEST_F(UserCollectorTest, HandleCrashWithoutMetrics) { s_metrics = false; collector_.HandleCrash(10, 20, "foobar"); - ASSERT_NE(logging_.log().find( - "Received crash notification for foobar[20] sig 10"), - std::string::npos); + ASSERT_NE(std::string::npos, + logging_.log().find( + "Received crash notification for foobar[20] sig 10")); ASSERT_EQ(s_crashes, 0); } -TEST_F(UserCollectorTest, HandleCrashWithMetrics) { +TEST_F(UserCollectorTest, HandleNonChromeCrashWithMetrics) { + s_metrics = true; + collector_.HandleCrash(2, 5, "chromeos-wm"); + ASSERT_NE(std::string::npos, + logging_.log().find( + "Received crash notification for chromeos-wm[5] sig 2")); + ASSERT_EQ(s_crashes, 1); +} + +TEST_F(UserCollectorTest, HandleChromeCrashWithMetrics) { s_metrics = true; collector_.HandleCrash(2, 5, "chrome"); - ASSERT_NE(logging_.log().find( - "Received crash notification for chrome[5] sig 2"), - std::string::npos); - ASSERT_EQ(s_crashes, 1); + ASSERT_NE(std::string::npos, + logging_.log().find( + "Received crash notification for chrome[5] sig 2")); + ASSERT_NE(std::string::npos, + logging_.log().find("(ignoring - chrome crash)")); + ASSERT_EQ(s_crashes, 0); } TEST_F(UserCollectorTest, GetProcessPath) {