diff --git a/crash_reporter/kernel_collector.cc b/crash_reporter/kernel_collector.cc index cd684ff49..98b3e8f26 100644 --- a/crash_reporter/kernel_collector.cc +++ b/crash_reporter/kernel_collector.cc @@ -96,14 +96,18 @@ bool KernelCollector::ReadRecordToString(std::string *contents, return false; } + *record_found = true; if (record_re.FullMatch(record, &captured)) { // Found a match, append it to the content, and remove from pstore. contents->append(captured); - base::DeleteFile(ramoops_record, false); - *record_found = true; } else { - *record_found = false; + // pstore compression has been added since kernel 3.12. In order to + // decompress dmesg correctly, ramoops driver has to strip the header + // before handing over the record to the pstore driver, so we don't + // need to do it here anymore. + contents->append(record); } + base::DeleteFile(ramoops_record, false); return true; } diff --git a/crash_reporter/kernel_collector_test.cc b/crash_reporter/kernel_collector_test.cc index d920fc651..6284f49ef 100644 --- a/crash_reporter/kernel_collector_test.cc +++ b/crash_reporter/kernel_collector_test.cc @@ -78,10 +78,10 @@ TEST_F(KernelCollectorTest, LoadPreservedDump) { std::string dump; dump.clear(); - WriteStringToFile(kcrash_file(), "emptydata"); + WriteStringToFile(kcrash_file(), "CrashRecordWithoutRamoopsHeader"); ASSERT_TRUE(collector_.LoadParameters()); - ASSERT_FALSE(collector_.LoadPreservedDump(&dump)); - ASSERT_EQ("", dump); + ASSERT_TRUE(collector_.LoadPreservedDump(&dump)); + ASSERT_EQ("CrashRecordWithoutRamoopsHeader", dump); WriteStringToFile(kcrash_file(), "====1.1\nsomething"); ASSERT_TRUE(collector_.LoadParameters()); @@ -229,14 +229,6 @@ TEST_F(KernelCollectorTest, CollectPreservedFileMissing) { ASSERT_EQ(0, s_crashes); } -TEST_F(KernelCollectorTest, CollectNoCrash) { - WriteStringToFile(kcrash_file(), ""); - ASSERT_FALSE(collector_.Collect()); - ASSERT_TRUE(FindLog("No valid records found")); - ASSERT_FALSE(FindLog("Stored kcrash to ")); - ASSERT_EQ(0, s_crashes); -} - TEST_F(KernelCollectorTest, CollectBadDirectory) { WriteStringToFile(kcrash_file(), "====1.1\nsomething"); ASSERT_TRUE(collector_.Collect());