win: Make out-of-process crash dump work.

This commit is contained in:
Cheng Zhao 2013-11-24 22:22:08 +08:00
parent 75e1fb63c8
commit 717b664802
4 changed files with 52 additions and 15 deletions

View file

@ -5,21 +5,26 @@ class CrashReporter
start: (options={}) -> start: (options={}) ->
{productName, companyName, submitUrl, autoSubmit, ignoreSystemCrashHandler, extra} = options {productName, companyName, submitUrl, autoSubmit, ignoreSystemCrashHandler, extra} = options
productName ?= 'atom-shell' productName ?= 'Atom-Shell'
companyName ?= 'GitHub, Inc' companyName ?= 'GitHub, Inc'
submitUrl ?= 'http://54.249.141.25:1127/post' submitUrl ?= 'http://54.249.141.25:1127/post'
autoSubmit ?= true autoSubmit ?= true
ignoreSystemCrashHandler ?= false ignoreSystemCrashHandler ?= false
extra ?= {} extra ?= {}
if process.platform isnt 'darwin' start = -> binding.start productName, companyName, submitUrl, autoSubmit, ignoreSystemCrashHandler, extra
if process.platform is 'darwin'
start()
else
args = [ args = [
"--reporter-url=#{submitUrl}", "--reporter-url=#{submitUrl}"
"--application-name=#{productName}" "--application-name=#{productName}"
"--v=1"
] ]
env = ATOM_SHELL_INTERNAL_CRASH_SERVICE: 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 module.exports = new CrashReporter

View file

@ -4,11 +4,25 @@
#include "common/crash_reporter/crash_reporter_win.h" #include "common/crash_reporter/crash_reporter_win.h"
#include "base/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
namespace crash_reporter { 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() { CrashReporterWin::CrashReporterWin() {
} }
@ -23,14 +37,35 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
bool skip_system_crash_handler) { bool skip_system_crash_handler) {
skip_system_crash_handler_ = skip_system_crash_handler; skip_system_crash_handler_ = skip_system_crash_handler;
wchar_t temp_dir[MAX_PATH] = { 0 }; base::FilePath temp_dir;
::GetTempPathW(MAX_PATH, 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, FilterCallback,
MinidumpCallback, MinidumpCallback,
this, 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() { void CrashReporterWin::SetUploadParameters() {

View file

@ -270,12 +270,10 @@ bool CrashService::Initialize(const base::FilePath& operating_dir,
if (security_attributes.lpSecurityDescriptor) if (security_attributes.lpSecurityDescriptor)
LocalFree(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 // Create or open an event to signal the browser process that the crash
// service is initialized. // service is initialized.
HANDLE running_event = 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 // If the browser already had the event open, the CreateEvent call did not
// signal it. We need to do it manually. // signal it. We need to do it manually.
::SetEvent(running_event); ::SetEvent(running_event);

View file

@ -7,8 +7,6 @@
#include "base/at_exit.h" #include "base/at_exit.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "common/crash_reporter/win/crash_service.h" #include "common/crash_reporter/win/crash_service.h"
@ -18,7 +16,8 @@ namespace crash_service {
namespace { namespace {
const char kApplicationName[] = "application-name"; 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"; const wchar_t kStandardLogFile[] = L"operation_log.txt";
bool GetCrashServiceDirectory(const std::wstring& application_name, bool GetCrashServiceDirectory(const std::wstring& application_name,