From f13d8407ee78407eb57a3dcccccc42687c830635 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 11 Nov 2014 12:51:16 +0800 Subject: [PATCH] linux: Put crash dumps under "/tmp/ProductName Crashes/" --- atom/common/crash_reporter/crash_reporter_linux.cc | 12 ++++++------ atom/common/crash_reporter/crash_reporter_linux.h | 2 +- .../crash_reporter/linux/crash_dump_handler.cc | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/atom/common/crash_reporter/crash_reporter_linux.cc b/atom/common/crash_reporter/crash_reporter_linux.cc index ab12869ba740..dd7b6b41ba9a 100644 --- a/atom/common/crash_reporter/crash_reporter_linux.cc +++ b/atom/common/crash_reporter/crash_reporter_linux.cc @@ -12,9 +12,9 @@ #include "base/debug/crash_logging.h" #include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/linux_util.h" #include "base/logging.h" -#include "base/path_service.h" #include "base/process/memory.h" #include "base/memory/singleton.h" #include "vendor/breakpad/src/client/linux/handler/exception_handler.h" @@ -61,7 +61,7 @@ void CrashReporterLinux::InitBreakpad(const std::string& product_name, const std::string& submit_url, bool auto_submit, bool skip_system_crash_handler) { - EnableCrashDumping(); + EnableCrashDumping(product_name); crash_keys_.SetKeyValue("prod", "Atom-Shell"); crash_keys_.SetKeyValue("ver", version.c_str()); @@ -76,11 +76,11 @@ void CrashReporterLinux::SetUploadParameters() { upload_parameters_["platform"] = "linux"; } -void CrashReporterLinux::EnableCrashDumping() { - base::FilePath tmp_path("/tmp"); - PathService::Get(base::DIR_TEMP, &tmp_path); +void CrashReporterLinux::EnableCrashDumping(const std::string& product_name) { + std::string dump_dir = "/tmp/" + product_name + " Crashes"; + base::FilePath dumps_path(dump_dir); + base::CreateDirectory(dumps_path); - base::FilePath dumps_path(tmp_path); MinidumpDescriptor minidump_descriptor(dumps_path.value()); minidump_descriptor.set_size_limit(kMaxMinidumpFileSize); diff --git a/atom/common/crash_reporter/crash_reporter_linux.h b/atom/common/crash_reporter/crash_reporter_linux.h index 660c471d2a02..c1055aded110 100644 --- a/atom/common/crash_reporter/crash_reporter_linux.h +++ b/atom/common/crash_reporter/crash_reporter_linux.h @@ -39,7 +39,7 @@ class CrashReporterLinux : public CrashReporter { CrashReporterLinux(); virtual ~CrashReporterLinux(); - void EnableCrashDumping(); + void EnableCrashDumping(const std::string& product_name); static bool CrashDone(const google_breakpad::MinidumpDescriptor& minidump, void* context, diff --git a/atom/common/crash_reporter/linux/crash_dump_handler.cc b/atom/common/crash_reporter/linux/crash_dump_handler.cc index 2e7de5bf51ea..4403d1d803fa 100644 --- a/atom/common/crash_reporter/linux/crash_dump_handler.cc +++ b/atom/common/crash_reporter/linux/crash_dump_handler.cc @@ -414,7 +414,6 @@ bool IsValidCrashReportId(const char* buf, size_t bytes_read, // |buf| should be |expected_len| + 1 characters in size and NULL terminated. void HandleCrashReportId(const char* buf, size_t bytes_read, size_t expected_len) { - WriteNewline(); if (!IsValidCrashReportId(buf, bytes_read, expected_len)) { static const char msg[] = "Failed to get crash dump id."; WriteLog(msg, sizeof(msg) - 1);