From 7e77690375bc8a896a8de318d69d515e67c7aefe Mon Sep 17 00:00:00 2001 From: Ben Chan Date: Wed, 18 Jun 2014 13:19:51 -0700 Subject: [PATCH] crash-reporter: Fix coding style and cpplint issues. BUG=chromium:385849 TEST=`FEATURES=test emerge-$BOARD platform2` TEST=`cpplint.py --filter=--build/header_guard,-build/include_order *.h *.cc` Change-Id: I3c24dd9487df50cdb22fc1c7739c9e95e452afae Reviewed-on: https://chromium-review.googlesource.com/204487 Tested-by: Ben Chan Reviewed-by: Mike Frysinger Commit-Queue: Ben Chan --- crash_reporter/chrome_collector.cc | 16 +++--- crash_reporter/chrome_collector.h | 11 ++-- crash_reporter/chrome_collector_test.cc | 15 +++--- crash_reporter/crash_collector.cc | 23 +++++---- crash_reporter/crash_collector.h | 10 ++-- crash_reporter/crash_collector_test.cc | 21 ++++---- crash_reporter/crash_collector_test.h | 8 +-- crash_reporter/crash_reporter.cc | 14 ++--- crash_reporter/kernel_collector.cc | 43 ++++++++-------- crash_reporter/kernel_collector.h | 11 ++-- crash_reporter/kernel_collector_test.cc | 18 +++---- crash_reporter/kernel_warning_collector.cc | 12 ++--- crash_reporter/kernel_warning_collector.h | 9 ++-- crash_reporter/list_proxies.cc | 21 ++++---- crash_reporter/udev_collector.cc | 16 +++--- crash_reporter/udev_collector.h | 13 ++--- crash_reporter/udev_collector_test.cc | 11 ++-- crash_reporter/unclean_shutdown_collector.cc | 4 +- crash_reporter/unclean_shutdown_collector.h | 11 ++-- .../unclean_shutdown_collector_test.cc | 13 ++--- crash_reporter/user_collector.cc | 51 ++++++++++--------- crash_reporter/user_collector.h | 11 ++-- crash_reporter/user_collector_test.cc | 15 +++--- crash_reporter/warn_collector_test.c | 3 +- 24 files changed, 198 insertions(+), 182 deletions(-) diff --git a/crash_reporter/chrome_collector.cc b/crash_reporter/chrome_collector.cc index 7bf1f85df..91a926bf8 100644 --- a/crash_reporter/chrome_collector.cc +++ b/crash_reporter/chrome_collector.cc @@ -6,6 +6,7 @@ #include #include + #include #include @@ -13,10 +14,10 @@ #include #include #include -#include "chromeos/process.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/dbus/dbus.h" -#include "chromeos/dbus/service_constants.h" +#include +#include +#include +#include const char kDefaultMinidumpName[] = "upload_file_minidump"; const char kTarPath[] = "/bin/tar"; @@ -125,7 +126,8 @@ bool GetAdditionalLogs(const FilePath &log_path) { return true; } -} //namespace + +} // namespace ChromeCollector::ChromeCollector() : output_file_ptr_(stdout) {} @@ -205,13 +207,13 @@ bool ChromeCollector::ParseCrashLog(const std::string &data, LOG(ERROR) << "Can't find : after name @ offset " << at; break; } - at += name.size() + 1; // Skip the name & : delimiter. + at += name.size() + 1; // Skip the name & : delimiter. if (!GetDelimitedString(data, ':', at, &size_string)) { LOG(ERROR) << "Can't find : after size @ offset " << at; break; } - at += size_string.size() + 1; // Skip the size & : delimiter. + at += size_string.size() + 1; // Skip the size & : delimiter. size_t size; if (!base::StringToSizeT(size_string, &size)) { diff --git a/crash_reporter/chrome_collector.h b/crash_reporter/chrome_collector.h index c6dbfc944..3586d52ec 100644 --- a/crash_reporter/chrome_collector.h +++ b/crash_reporter/chrome_collector.h @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_CHROME_COLLECTOR_H_ -#define _CRASH_REPORTER_CHROME_COLLECTOR_H_ +#ifndef CRASH_REPORTER_CHROME_COLLECTOR_H_ +#define CRASH_REPORTER_CHROME_COLLECTOR_H_ #include -#include "base/files/file_path.h" +#include +#include // for FRIEND_TEST + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST class SystemLogging; @@ -49,4 +50,4 @@ class ChromeCollector : public CrashCollector { FILE *output_file_ptr_; }; -#endif +#endif // CRASH_REPORTER_CHROME_COLLECTOR_H_ diff --git a/crash_reporter/chrome_collector_test.cc b/crash_reporter/chrome_collector_test.cc index 9b97399f7..843ca8e67 100644 --- a/crash_reporter/chrome_collector_test.cc +++ b/crash_reporter/chrome_collector_test.cc @@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "crash-reporter/chrome_collector.h" + #include #include -#include "base/auto_reset.h" -#include "base/file_util.h" -#include "base/files/scoped_temp_dir.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/test_helpers.h" -#include "crash-reporter/chrome_collector.h" -#include "gtest/gtest.h" +#include +#include +#include +#include +#include +#include using base::FilePath; diff --git a/crash_reporter/crash_collector.cc b/crash_reporter/crash_collector.cc index 8e463da2c..152aec323 100644 --- a/crash_reporter/crash_collector.cc +++ b/crash_reporter/crash_collector.cc @@ -10,25 +10,26 @@ #include // for mode_t. #include // For waitpid. #include // For execv and fork. -#define __STDC_FORMAT_MACROS // PRId64 +#define __STDC_FORMAT_MACROS // PRId64 #include #include +#include #include #include #include -#include "base/file_util.h" -#include "base/logging.h" -#include "base/posix/eintr_wrapper.h" -#include "base/strings/string_split.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "chromeos/cryptohome.h" -#include "chromeos/dbus/dbus.h" -#include "chromeos/dbus/service_constants.h" -#include "chromeos/process.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include static const char kCollectChromeFile[] = "/mnt/stateful_partition/etc/collect_chrome_crashes"; diff --git a/crash_reporter/crash_collector.h b/crash_reporter/crash_collector.h index 67ff87089..0e786618d 100644 --- a/crash_reporter/crash_collector.h +++ b/crash_reporter/crash_collector.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_CRASH_COLLECTOR_H_ -#define _CRASH_REPORTER_CRASH_COLLECTOR_H_ +#ifndef CRASH_REPORTER_CRASH_COLLECTOR_H_ +#define CRASH_REPORTER_CRASH_COLLECTOR_H_ #include @@ -12,8 +12,8 @@ #include -#include "base/files/file_path.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST +#include +#include // for FRIEND_TEST // User crash collector. class CrashCollector { @@ -172,4 +172,4 @@ class CrashCollector { base::FilePath log_config_path_; }; -#endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_ +#endif // CRASH_REPORTER_CRASH_COLLECTOR_H_ diff --git a/crash_reporter/crash_collector_test.cc b/crash_reporter/crash_collector_test.cc index 81a4a7c9b..1ffb8e423 100644 --- a/crash_reporter/crash_collector_test.cc +++ b/crash_reporter/crash_collector_test.cc @@ -9,13 +9,14 @@ #include #include -#include "base/file_util.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/test_helpers.h" +#include +#include +#include +#include +#include +#include + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest.h" using base::FilePath; using base::StringPrintf; @@ -115,12 +116,12 @@ TEST_F(CrashCollectorTest, GetCrashDirectoryInfo) { EXPECT_EQ(kRootGid, directory_group); // No need to destroy the hash as GetCrashDirectoryInfo() will do it for us. - GHashTable *active_sessions = g_hash_table_new (g_str_hash, g_str_equal); + GHashTable *active_sessions = g_hash_table_new(g_str_hash, g_str_equal); char kUser[] = "chicken@butt.com"; char kHash[] = "hashcakes"; - g_hash_table_insert (active_sessions, - static_cast(kUser), - static_cast(kHash)); + g_hash_table_insert(active_sessions, + static_cast(kUser), + static_cast(kHash)); EXPECT_CALL(collector_, GetActiveUserSessions()) .WillOnce(Return(active_sessions)); diff --git a/crash_reporter/crash_collector_test.h b/crash_reporter/crash_collector_test.h index 71b42b7dd..28811b04e 100644 --- a/crash_reporter/crash_collector_test.h +++ b/crash_reporter/crash_collector_test.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ -#define _CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ +#ifndef CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ +#define CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ #include "crash-reporter/crash_collector.h" @@ -14,7 +14,7 @@ class CrashCollectorMock : public CrashCollector { public: - MOCK_METHOD0(GetActiveUserSessions, GHashTable *()); + MOCK_METHOD0(GetActiveUserSessions, GHashTable*()); }; -#endif // _CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ +#endif // CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ diff --git a/crash_reporter/crash_reporter.cc b/crash_reporter/crash_reporter.cc index be70ebcde..8aafc4677 100644 --- a/crash_reporter/crash_reporter.cc +++ b/crash_reporter/crash_reporter.cc @@ -3,27 +3,27 @@ // found in the LICENSE file. #include // for open +#include #include #include -#include - -#include #include +#include #include #include #include #include -#include "chromeos/syslog_logging.h" +#include +#include +#include + #include "crash-reporter/chrome_collector.h" #include "crash-reporter/kernel_collector.h" #include "crash-reporter/kernel_warning_collector.h" #include "crash-reporter/udev_collector.h" #include "crash-reporter/unclean_shutdown_collector.h" #include "crash-reporter/user_collector.h" -#include "gflags/gflags.h" -#include "metrics/metrics_library.h" #pragma GCC diagnostic ignored "-Wstrict-aliasing" DEFINE_bool(init, false, "Initialize crash logging"); @@ -252,7 +252,7 @@ static void OpenStandardFileDescriptors() { // invalid fd. do { new_fd = open("/dev/null", 0); - CHECK(new_fd >= 0) << "Unable to open /dev/null"; + CHECK_GE(new_fd, 0) << "Unable to open /dev/null"; } while (new_fd >= 0 && new_fd <= 2); close(new_fd); } diff --git a/crash_reporter/kernel_collector.cc b/crash_reporter/kernel_collector.cc index a57e58749..2e93f2b98 100644 --- a/crash_reporter/kernel_collector.cc +++ b/crash_reporter/kernel_collector.cc @@ -4,10 +4,12 @@ #include "crash-reporter/kernel_collector.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" +#include + +#include +#include +#include +#include static const char kDefaultKernelStackSignature[] = "kernel-UnspecifiedStackSignature"; @@ -27,17 +29,17 @@ static const int kSignatureTimestampWindow = 2; // Kernel log timestamp regular expression. static const std::string kTimestampRegex("^<.*>\\[\\s*(\\d+\\.\\d+)\\]"); -/* - * These regular expressions enable to us capture the PC in a backtrace. - * The backtrace is obtained through dmesg or the kernel's preserved/kcrashmem - * feature. - * - * For ARM we see: - * "<5>[ 39.458982] PC is at write_breakme+0xd0/0x1b4" - * For x86: - * "<0>[ 37.474699] EIP: [<790ed488>] write_breakme+0x80/0x108 \ - * SS:ESP 0068:e9dd3efc - */ +// +// These regular expressions enable to us capture the PC in a backtrace. +// The backtrace is obtained through dmesg or the kernel's preserved/kcrashmem +// feature. +// +// For ARM we see: +// "<5>[ 39.458982] PC is at write_breakme+0xd0/0x1b4" +// For x86: +// "<0>[ 37.474699] EIP: [<790ed488>] write_breakme+0x80/0x108 +// SS:ESP 0068:e9dd3efc" +// static const char *s_pc_regex[] = { 0, " PC is at ([^\\+ ]+).*", @@ -85,7 +87,7 @@ bool KernelCollector::ReadRecordToString(std::string *contents, return false; } - if (record_re.FullMatch(record, &captured)){ + 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); @@ -231,8 +233,7 @@ bool KernelCollector::Enable() { s_pc_regex[arch_] == NULL) { LOG(WARNING) << "KernelCollector does not understand this architecture"; return false; - } - else { + } else { FilePath ramoops_record; GetRamoopsRecordPath(&ramoops_record, 0); if (!base::PathExists(ramoops_record)) { @@ -349,8 +350,7 @@ void KernelCollector::ProcessStackTrace( } } -enum KernelCollector::ArchKind KernelCollector::GetCompilerArch(void) -{ +enum KernelCollector::ArchKind KernelCollector::GetCompilerArch(void) { #if defined(COMPILER_GCC) && defined(ARCH_CPU_ARM_FAMILY) return archArm; #elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_64) @@ -362,8 +362,7 @@ enum KernelCollector::ArchKind KernelCollector::GetCompilerArch(void) #endif } -void KernelCollector::SetArch(enum ArchKind arch) -{ +void KernelCollector::SetArch(enum ArchKind arch) { arch_ = arch; } diff --git a/crash_reporter/kernel_collector.h b/crash_reporter/kernel_collector.h index c965cd39d..8f52e440e 100644 --- a/crash_reporter/kernel_collector.h +++ b/crash_reporter/kernel_collector.h @@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_KERNEL_COLLECTOR_H_ -#define _CRASH_REPORTER_KERNEL_COLLECTOR_H_ +#ifndef CRASH_REPORTER_KERNEL_COLLECTOR_H_ +#define CRASH_REPORTER_KERNEL_COLLECTOR_H_ #include #include -#include "base/files/file_path.h" +#include +#include // for FRIEND_TEST + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST // Kernel crash collector. class KernelCollector : public CrashCollector { @@ -103,4 +104,4 @@ class KernelCollector : public CrashCollector { enum ArchKind arch_; }; -#endif // _CRASH_REPORTER_KERNEL_COLLECTOR_H_ +#endif // CRASH_REPORTER_KERNEL_COLLECTOR_H_ diff --git a/crash_reporter/kernel_collector_test.cc b/crash_reporter/kernel_collector_test.cc index 5e9bc15b1..2644891ef 100644 --- a/crash_reporter/kernel_collector_test.cc +++ b/crash_reporter/kernel_collector_test.cc @@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "crash-reporter/kernel_collector.h" + #include -#include "base/file_util.h" -#include "base/files/scoped_temp_dir.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/test_helpers.h" -#include "crash-reporter/kernel_collector.h" -#include "gtest/gtest.h" +#include +#include +#include +#include +#include +#include +#include static int s_crashes = 0; static bool s_metrics = false; @@ -280,7 +281,6 @@ TEST_F(KernelCollectorTest, CollectOK) { std::string contents; ASSERT_TRUE(base::ReadFileToString(FilePath(filename), &contents)); ASSERT_EQ("something", contents); - } // Perform tests which are common across architectures diff --git a/crash_reporter/kernel_warning_collector.cc b/crash_reporter/kernel_warning_collector.cc index a186e9f3a..7082569de 100644 --- a/crash_reporter/kernel_warning_collector.cc +++ b/crash_reporter/kernel_warning_collector.cc @@ -4,11 +4,11 @@ #include "crash-reporter/kernel_warning_collector.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" +#include +#include +#include +#include +#include namespace { const char kExecName[] = "kernel-warning"; @@ -34,7 +34,7 @@ bool KernelWarningCollector::LoadKernelWarning(std::string *content, LOG(ERROR) << "Could not open " << kKernelWarningPath; return false; } - /* The signature is in the first line. */ + // The signature is in the first line. std::string::size_type end_position = content->find('\n'); if (end_position == std::string::npos) { LOG(ERROR) << "unexpected kernel warning format"; diff --git a/crash_reporter/kernel_warning_collector.h b/crash_reporter/kernel_warning_collector.h index 7a5041617..2559d72f3 100644 --- a/crash_reporter/kernel_warning_collector.h +++ b/crash_reporter/kernel_warning_collector.h @@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ -#define _CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ +#ifndef CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ +#define CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ + +#include #include // for FRIEND_TEST -#include #include "crash-reporter/crash_collector.h" @@ -28,4 +29,4 @@ class KernelWarningCollector : public CrashCollector { bool LoadKernelWarning(std::string *content, std::string *signature); }; -#endif // _CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ +#endif // CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ diff --git a/crash_reporter/list_proxies.cc b/crash_reporter/list_proxies.cc index 41dd39046..2e80e4718 100644 --- a/crash_reporter/list_proxies.cc +++ b/crash_reporter/list_proxies.cc @@ -3,21 +3,20 @@ // found in the LICENSE file. #include // for isatty() +#include +#include #include #include -#include -#include - -#include "base/command_line.h" -#include "base/file_util.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_util.h" -#include "base/strings/string_tokenizer.h" -#include "base/values.h" -#include "chromeos/dbus/dbus.h" -#include "chromeos/syslog_logging.h" +#include +#include +#include +#include +#include +#include +#include +#include const char kLibCrosProxyResolveSignalInterface[] = "org.chromium.CrashReporterLibcrosProxyResolvedInterface"; diff --git a/crash_reporter/udev_collector.cc b/crash_reporter/udev_collector.cc index 504f90e11..506552772 100644 --- a/crash_reporter/udev_collector.cc +++ b/crash_reporter/udev_collector.cc @@ -4,12 +4,16 @@ #include "crash-reporter/udev_collector.h" -#include "base/basictypes.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "base/strings/string_split.h" -#include "base/strings/string_util.h" -#include "chromeos/process.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include static const char kCollectUdevSignature[] = "crash_reporter-udev-collection"; static const char kGzipPath[] = "/bin/gzip"; diff --git a/crash_reporter/udev_collector.h b/crash_reporter/udev_collector.h index 0976d3e32..e54ce5b43 100644 --- a/crash_reporter/udev_collector.h +++ b/crash_reporter/udev_collector.h @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_UDEV_COLLECTOR_H_ -#define _CRASH_REPORTER_UDEV_COLLECTOR_H_ +#ifndef CRASH_REPORTER_UDEV_COLLECTOR_H_ +#define CRASH_REPORTER_UDEV_COLLECTOR_H_ #include -#include "base/files/file_path.h" +#include +#include // for FRIEND_TEST + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST // Udev crash collector. class UdevCollector : public CrashCollector { @@ -22,7 +23,7 @@ class UdevCollector : public CrashCollector { // "ACTION=[action]:KERNEL=[name]:SUBSYSTEM=[subsystem]" // The values don't have to be in any particular order. One or more of them // could be omitted, in which case it would be treated as a wildcard (*). - bool HandleCrash(const std::string &udev_event); + bool HandleCrash(const std::string& udev_event); private: friend class UdevCollectorTest; @@ -33,4 +34,4 @@ class UdevCollector : public CrashCollector { } }; -#endif // _CRASH_REPORTER_UDEV_COLLECTOR_H_ +#endif // CRASH_REPORTER_UDEV_COLLECTOR_H_ diff --git a/crash_reporter/udev_collector_test.cc b/crash_reporter/udev_collector_test.cc index d5d6f29bd..b45fdd8e4 100644 --- a/crash_reporter/udev_collector_test.cc +++ b/crash_reporter/udev_collector_test.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/file_util.h" -#include "base/files/file_enumerator.h" -#include "base/files/scoped_temp_dir.h" -#include "chromeos/test_helpers.h" +#include +#include +#include +#include +#include + #include "crash-reporter/udev_collector.h" -#include "gtest/gtest.h" using base::FilePath; diff --git a/crash_reporter/unclean_shutdown_collector.cc b/crash_reporter/unclean_shutdown_collector.cc index 8ee83c88b..3c8af6263 100644 --- a/crash_reporter/unclean_shutdown_collector.cc +++ b/crash_reporter/unclean_shutdown_collector.cc @@ -4,8 +4,8 @@ #include "crash-reporter/unclean_shutdown_collector.h" -#include "base/file_util.h" -#include "base/logging.h" +#include +#include static const char kUncleanShutdownFile[] = "/var/lib/crash_reporter/pending_clean_shutdown"; diff --git a/crash_reporter/unclean_shutdown_collector.h b/crash_reporter/unclean_shutdown_collector.h index ec21b7cf8..6324bc397 100644 --- a/crash_reporter/unclean_shutdown_collector.h +++ b/crash_reporter/unclean_shutdown_collector.h @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ -#define _CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ +#ifndef CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ +#define CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ #include -#include "base/files/file_path.h" +#include +#include // for FRIEND_TEST + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST // Unclean shutdown collector. class UncleanShutdownCollector : public CrashCollector { @@ -43,4 +44,4 @@ class UncleanShutdownCollector : public CrashCollector { base::FilePath powerd_suspended_file_; }; -#endif // _CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ +#endif // CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ diff --git a/crash_reporter/unclean_shutdown_collector_test.cc b/crash_reporter/unclean_shutdown_collector_test.cc index a0eec1cc2..d44ec0d96 100644 --- a/crash_reporter/unclean_shutdown_collector_test.cc +++ b/crash_reporter/unclean_shutdown_collector_test.cc @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "crash-reporter/unclean_shutdown_collector.h" + #include -#include "base/file_util.h" -#include "base/strings/string_util.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/test_helpers.h" -#include "crash-reporter/unclean_shutdown_collector.h" -#include "gtest/gtest.h" +#include +#include +#include +#include +#include static int s_crashes = 0; static bool s_metrics = true; diff --git a/crash_reporter/user_collector.cc b/crash_reporter/user_collector.cc index 3355b0e04..198a43b06 100644 --- a/crash_reporter/user_collector.cc +++ b/crash_reporter/user_collector.cc @@ -12,19 +12,20 @@ #include // For struct passwd. #include // For getpwuid_r, getgrnam_r, WEXITSTATUS. +#include #include #include -#include "base/file_util.h" -#include "base/logging.h" -#include "base/posix/eintr_wrapper.h" -#include "base/stl_util.h" -#include "base/strings/string_split.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "chromeos/process.h" -#include "chromeos/syslog_logging.h" -#include "gflags/gflags.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #pragma GCC diagnostic ignored "-Wstrict-aliasing" DEFINE_bool(core2md_failure, false, "Core2md failure test"); @@ -440,7 +441,7 @@ UserCollector::ErrorType UserCollector::ConvertAndEnqueueCrash( // Directory like /tmp/crash_reporter/1234 which contains the // procfs entries and other temporary files used during conversion. - FilePath container_dir(StringPrintf("/tmp/crash_reporter/%d", (int)pid)); + FilePath container_dir(StringPrintf("/tmp/crash_reporter/%d", pid)); // Delete a pre-existing directory from crash reporter that may have // been left around for diagnostics from a failed conversion attempt. // If we don't, existing files can cause forking to fail. @@ -495,19 +496,19 @@ bool UserCollector::ParseCrashAttributes(const std::string &crash_attributes, kernel_supplied_name); } -/* Returns true if the given executable name matches that of Chrome. This - * includes checks for threads that Chrome has renamed. */ +// Returns true if the given executable name matches that of Chrome. This +// includes checks for threads that Chrome has renamed. static bool IsChromeExecName(const std::string &exec) { static const char *kChromeNames[] = { "chrome", - /* These are additional thread names seen in http://crash/ */ + // These are additional thread names seen in http://crash/ "MediaPipeline", - /* These come from the use of base::PlatformThread::SetName() directly */ + // These come from the use of base::PlatformThread::SetName() directly "CrBrowserMain", "CrRendererMain", "CrUtilityMain", "CrPPAPIMain", "CrPPAPIBrokerMain", "CrPluginMain", "CrWorkerMain", "CrGpuMain", "BrokerEvent", "CrVideoRenderer", "CrShutdownDetector", "UsbEventHandler", "CrNaClMain", "CrServiceMain", - /* These thread names come from the use of base::Thread */ + // These thread names come from the use of base::Thread "Gamepad polling thread", "Chrome_InProcGpuThread", "Chrome_DragDropThread", "Renderer::FILE", "VC manager", "VideoCaptureModuleImpl", "JavaBridge", "VideoCaptureManagerThread", @@ -536,29 +537,29 @@ static bool IsChromeExecName(const std::string &exec) { "ServiceProcess_IO", "ServiceProcess_File", "extension_crash_uploader", "gpu-process_crash_uploader", "plugin_crash_uploader", "renderer_crash_uploader", - /* These come from the use of webkit_glue::WebThreadImpl */ + // These come from the use of webkit_glue::WebThreadImpl "Compositor", "Browser Compositor", // "WorkerPool/%d", // not easy to check because of "%d" - /* These come from the use of base::Watchdog */ + // These come from the use of base::Watchdog "Startup watchdog thread Watchdog", "Shutdown watchdog thread Watchdog", - /* These come from the use of AudioDeviceThread::Start */ + // These come from the use of AudioDeviceThread::Start "AudioDevice", "AudioInputDevice", "AudioOutputDevice", - /* These come from the use of MessageLoopFactory::GetMessageLoop */ + // These come from the use of MessageLoopFactory::GetMessageLoop "GpuVideoDecoder", "RtcVideoDecoderThread", "PipelineThread", "AudioDecoderThread", "VideoDecoderThread", - /* These come from the use of MessageLoopFactory::GetMessageLoopProxy */ + // These come from the use of MessageLoopFactory::GetMessageLoopProxy "CaptureVideoDecoderThread", "CaptureVideoDecoder", - /* These come from the use of base::SimpleThread */ + // These come from the use of base::SimpleThread "LocalInputMonitor/%d", // "%d" gets lopped off for kernel-supplied - /* These come from the use of base::DelegateSimpleThread */ + // These come from the use of base::DelegateSimpleThread "ipc_channel_nacl reader thread/%d", "plugin_audio_input_thread/%d", "plugin_audio_thread/%d", - /* These come from the use of base::SequencedWorkerPool */ + // These come from the use of base::SequencedWorkerPool "BrowserBlockingWorker%d/%d", // "%d" gets lopped off for kernel-supplied }; static std::set chrome_names; - /* Initialize a set of chrome names, for efficient lookup */ + // Initialize a set of chrome names, for efficient lookup if (chrome_names.empty()) { for (size_t i = 0; i < arraysize(kChromeNames); i++) { std::string check_name(kChromeNames[i]); diff --git a/crash_reporter/user_collector.h b/crash_reporter/user_collector.h index 6c82fa8dd..3658e5114 100644 --- a/crash_reporter/user_collector.h +++ b/crash_reporter/user_collector.h @@ -2,15 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_USER_COLLECTOR_H_ -#define _CRASH_REPORTER_USER_COLLECTOR_H_ +#ifndef CRASH_REPORTER_USER_COLLECTOR_H_ +#define CRASH_REPORTER_USER_COLLECTOR_H_ #include #include -#include "base/files/file_path.h" +#include +#include // for FRIEND_TEST + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST class SystemLogging; @@ -178,4 +179,4 @@ class UserCollector : public CrashCollector { static const char *kGroupId; }; -#endif // _CRASH_REPORTER_USER_COLLECTOR_H_ +#endif // CRASH_REPORTER_USER_COLLECTOR_H_ diff --git a/crash_reporter/user_collector_test.cc b/crash_reporter/user_collector_test.cc index eeaf070b7..242c117fe 100644 --- a/crash_reporter/user_collector_test.cc +++ b/crash_reporter/user_collector_test.cc @@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "crash-reporter/user_collector.h" + #include #include #include -#include "base/file_util.h" -#include "base/files/scoped_temp_dir.h" -#include "base/strings/string_split.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/test_helpers.h" -#include "crash-reporter/user_collector.h" -#include "gtest/gtest.h" +#include +#include +#include +#include +#include +#include static int s_crashes = 0; static bool s_metrics = false; diff --git a/crash_reporter/warn_collector_test.c b/crash_reporter/warn_collector_test.c index 76707b200..7e25d01fa 100644 --- a/crash_reporter/warn_collector_test.c +++ b/crash_reporter/warn_collector_test.c @@ -8,8 +8,7 @@ */ #include -int main(int ac, char **av) -{ +int main(int ac, char **av) { int status = system("exec \"${SRC}\"/warn_collector_test.sh"); return status < 0 ? EXIT_FAILURE : WEXITSTATUS(status); }