]> khamidou — GitHub mirrors - electron.git/commitdiff
win: Make out-of-process crash dump work.
authorCheng Zhao <zcbenz@gmail.com>
Sun, 24 Nov 2013 14:22:08 +0000 (22:22 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 24 Nov 2013 14:22:08 +0000 (22:22 +0800)
common/api/lib/crash-reporter.coffee
common/crash_reporter/crash_reporter_win.cc
common/crash_reporter/win/crash_service.cc
common/crash_reporter/win/crash_service_main.cc

index ae974610585638b45ba6000e4988ec3f7f4ab421..3dd8821d1201dde6e953bd0521351957c5b25a65 100644 (file)
@@ -5,21 +5,26 @@ class CrashReporter
   start: (options={}) ->
     {productName, companyName, submitUrl, autoSubmit, ignoreSystemCrashHandler, extra} = options
 
-    productName ?= 'atom-shell'
+    productName ?= 'Atom-Shell'
     companyName ?= 'GitHub, Inc'
     submitUrl ?= 'http://54.249.141.25:1127/post'
     autoSubmit ?= true
     ignoreSystemCrashHandler ?= false
     extra ?= {}
 
-    if process.platform isnt 'darwin'
+    start = -> binding.start productName, companyName, submitUrl, autoSubmit, ignoreSystemCrashHandler, extra
+
+    if process.platform is 'darwin'
+      start()
+    else
       args = [
-        "--reporter-url=#{submitUrl}",
+        "--reporter-url=#{submitUrl}"
         "--application-name=#{productName}"
+        "--v=1"
       ]
       env = ATOM_SHELL_INTERNAL_CRASH_SERVICE: 1
-      spawn process.execPath, args, {env}
 
-    binding.start productName, companyName, submitUrl, autoSubmit, ignoreSystemCrashHandler, extra
+      spawn process.execPath, args, {env, detached: true}
+      start()
 
 module.exports = new CrashReporter
index 65d5b8d743e5e6dd1216216dc702b2959679d736..4a7f6012f45ec65fc8f18b95ce5f9c7be45cde20 100644 (file)
@@ -4,11 +4,25 @@
 
 #include "common/crash_reporter/crash_reporter_win.h"
 
+#include "base/file_util.h"
 #include "base/logging.h"
 #include "base/memory/singleton.h"
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
 
 namespace crash_reporter {
 
+namespace {
+
+// Minidump with stacks, PEB, TEB, and unloaded module list.
+const MINIDUMP_TYPE kSmallDumpType = static_cast<MINIDUMP_TYPE>(
+    MiniDumpWithProcessThreadData |  // Get PEB and TEB.
+    MiniDumpWithUnloadedModules);  // Get unloaded modules when available.
+
+const wchar_t kPipeNameFormat[] = L"\\\\.\\pipe\\$1 Crash Service";
+
+}  // namespace
+
 CrashReporterWin::CrashReporterWin() {
 }
 
@@ -23,14 +37,35 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
                                     bool skip_system_crash_handler) {
   skip_system_crash_handler_ = skip_system_crash_handler;
 
-  wchar_t temp_dir[MAX_PATH] = { 0 };
-  ::GetTempPathW(MAX_PATH, temp_dir);
+  base::FilePath temp_dir;
+  if (!file_util::GetTempDir(&temp_dir)) {
+    LOG(ERROR) << "Cannot get temp directory";
+    return;
+  }
 
-  breakpad_.reset(new google_breakpad::ExceptionHandler(temp_dir,
+  string16 pipe_name = ReplaceStringPlaceholders(kPipeNameFormat,
+                                                 UTF8ToUTF16(product_name),
+                                                 NULL);
+
+  // Wait until the crash service is started.
+  HANDLE waiting_event =
+      ::CreateEventW(NULL, TRUE, FALSE, L"g_atom_shell_crash_service");
+  if (waiting_event != INVALID_HANDLE_VALUE)
+    WaitForSingleObject(waiting_event, 1000);
+
+  google_breakpad::CustomClientInfo custom_info = { NULL, 0 };
+  breakpad_.reset(new google_breakpad::ExceptionHandler(
+      temp_dir.value(),
       FilterCallback,
       MinidumpCallback,
       this,
-      google_breakpad::ExceptionHandler::HANDLER_ALL));
+      google_breakpad::ExceptionHandler::HANDLER_ALL,
+      kSmallDumpType,
+      pipe_name.c_str(),
+      &custom_info));
+
+  if (!breakpad_->IsOutOfProcess())
+    LOG(ERROR) << "Cannot initialize out-of-process crash handler";
 }
 
 void CrashReporterWin::SetUploadParameters() {
index 202c479c276d6dfcc4236aa8bf81e5ecb6285fee..3cbbf33242fd9df78e847e3edb2c66e34f55ea64 100644 (file)
@@ -270,12 +270,10 @@ bool CrashService::Initialize(const base::FilePath& operating_dir,
   if (security_attributes.lpSecurityDescriptor)
     LocalFree(security_attributes.lpSecurityDescriptor);
 
-  // This is throwaway code. We don't need to sync with the browser process
-  // once Google Update is updated to a version supporting OOP crash handling.
   // Create or open an event to signal the browser process that the crash
   // service is initialized.
   HANDLE running_event =
-      ::CreateEventW(NULL, TRUE, TRUE, L"g_chrome_crash_svc");
+      ::CreateEventW(NULL, TRUE, TRUE, L"g_atom_shell_crash_service");
   // If the browser already had the event open, the CreateEvent call did not
   // signal it. We need to do it manually.
   ::SetEvent(running_event);
index 46f9690b89df50cab183e37713866fc9fe2eb208..649f35847480b63d9c06a9a19dcc62d1af2f9a5e 100644 (file)
@@ -7,8 +7,6 @@
 #include "base/at_exit.h"
 #include "base/command_line.h"
 #include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/path_service.h"
 #include "base/logging.h"
 #include "base/string_util.h"
 #include "common/crash_reporter/win/crash_service.h"
@@ -18,7 +16,8 @@ namespace crash_service {
 namespace {
 
 const char kApplicationName[] = "application-name";
-const wchar_t kPipeNameFormat[] = L"\\\\.\\pipe\\$1CrashService";
+
+const wchar_t kPipeNameFormat[] = L"\\\\.\\pipe\\$1 Crash Service";
 const wchar_t kStandardLogFile[] = L"operation_log.txt";
 
 bool GetCrashServiceDirectory(const std::wstring& application_name,