summaryrefslogtreecommitdiffstats
path: root/win8
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-22 20:34:39 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-22 20:34:39 +0000
commit3a0a5f742211ecd24a5cc00ab5a2b27a662fd58d (patch)
tree65502d28932e8caeb0ada852433b2d1b01cf9518 /win8
parentc54ac00bc21404281d2eff4acf8652c3388cbfe9 (diff)
downloadchromium_src-3a0a5f742211ecd24a5cc00ab5a2b27a662fd58d.zip
chromium_src-3a0a5f742211ecd24a5cc00ab5a2b27a662fd58d.tar.gz
chromium_src-3a0a5f742211ecd24a5cc00ab5a2b27a662fd58d.tar.bz2
Add basic crash reporting to delegate_execute.exe.
BUG=160658 Review URL: https://chromiumcodereview.appspot.com/11421031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169304 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8')
-rw-r--r--win8/delegate_execute/crash_server_init.cc96
-rw-r--r--win8/delegate_execute/crash_server_init.h23
-rw-r--r--win8/delegate_execute/delegate_execute.cc6
-rw-r--r--win8/delegate_execute/delegate_execute.gyp3
4 files changed, 128 insertions, 0 deletions
diff --git a/win8/delegate_execute/crash_server_init.cc b/win8/delegate_execute/crash_server_init.cc
new file mode 100644
index 0000000..7689316
--- /dev/null
+++ b/win8/delegate_execute/crash_server_init.cc
@@ -0,0 +1,96 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "win8/delegate_execute/crash_server_init.h"
+
+#include <shlobj.h>
+#include <windows.h>
+
+#include <cwchar>
+
+#include "base/file_version_info.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/win/win_util.h"
+#include "breakpad/src/client/windows/handler/exception_handler.h"
+
+const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\";
+const wchar_t kSystemPrincipalSid[] = L"S-1-5-18";
+
+const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>(
+ MiniDumpWithProcessThreadData | // Get PEB and TEB.
+ MiniDumpWithUnloadedModules | // Get unloaded modules when available.
+ MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack.
+
+extern "C" IMAGE_DOS_HEADER __ImageBase;
+
+namespace {
+
+bool IsRunningSystemInstall() {
+ wchar_t exe_path[MAX_PATH * 2] = {0};
+ GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase),
+ exe_path,
+ _countof(exe_path));
+
+ bool is_system = false;
+
+ wchar_t program_files_path[MAX_PATH] = {0};
+ if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
+ SHGFP_TYPE_CURRENT, program_files_path))) {
+ if (wcsstr(exe_path, program_files_path) == exe_path) {
+ is_system = true;
+ }
+ }
+
+ return is_system;
+}
+
+google_breakpad::CustomClientInfo* GetCustomInfo() {
+ scoped_ptr<FileVersionInfo> version_info(
+ FileVersionInfo::CreateFileVersionInfoForCurrentModule());
+
+ static google_breakpad::CustomInfoEntry ver_entry(
+ L"ver", version_info->file_version().c_str());
+ static google_breakpad::CustomInfoEntry prod_entry(L"prod", L"Chrome");
+ static google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32");
+ static google_breakpad::CustomInfoEntry type_entry(L"ptype",
+ L"delegate_execute");
+ static google_breakpad::CustomInfoEntry entries[] = {
+ ver_entry, prod_entry, plat_entry, type_entry };
+ static google_breakpad::CustomClientInfo custom_info = {
+ entries, ARRAYSIZE(entries) };
+ return &custom_info;
+}
+
+} // namespace
+
+namespace delegate_execute {
+
+scoped_ptr<google_breakpad::ExceptionHandler> InitializeCrashReporting() {
+ wchar_t temp_path[MAX_PATH + 1] = {0};
+ DWORD path_len = ::GetTempPath(MAX_PATH, temp_path);
+
+ string16 pipe_name;
+ pipe_name = kGoogleUpdatePipeName;
+ if (IsRunningSystemInstall()) {
+ pipe_name += kSystemPrincipalSid;
+ } else {
+ string16 user_sid;
+ if (base::win::GetUserSidString(&user_sid)) {
+ pipe_name += user_sid;
+ } else {
+ // We don't think we're a system install, but we couldn't get the
+ // user SID. Try connecting to the system-level crash service as a
+ // last ditch effort.
+ pipe_name += kSystemPrincipalSid;
+ }
+ }
+
+ return scoped_ptr<google_breakpad::ExceptionHandler>(
+ new google_breakpad::ExceptionHandler(
+ temp_path, NULL, NULL, NULL,
+ google_breakpad::ExceptionHandler::HANDLER_ALL, kLargerDumpType,
+ pipe_name.c_str(), GetCustomInfo()));
+}
+
+} // namespace delegate_execute
diff --git a/win8/delegate_execute/crash_server_init.h b/win8/delegate_execute/crash_server_init.h
new file mode 100644
index 0000000..4173ef5
--- /dev/null
+++ b/win8/delegate_execute/crash_server_init.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WIN8_DELEGATE_EXECUTE_CRASH_SERVER_INIT_H_
+#define WIN8_DELEGATE_EXECUTE_CRASH_SERVER_INIT_H_
+
+#include "base/memory/scoped_ptr.h"
+
+namespace google_breakpad {
+class ExceptionHandler;
+}
+
+namespace delegate_execute {
+
+// Initializes breakpad crash reporting and returns a pointer to a newly
+// constructed ExceptionHandler object. It is the responsibility of the caller
+// to delete this object which will shut down the crash reporting machinery.
+scoped_ptr<google_breakpad::ExceptionHandler> InitializeCrashReporting();
+
+} // namespace delegate_execute
+
+#endif // WIN8_DELEGATE_EXECUTE_CRASH_SERVER_INIT_H_
diff --git a/win8/delegate_execute/delegate_execute.cc b/win8/delegate_execute/delegate_execute.cc
index 2cfe418..8742813 100644
--- a/win8/delegate_execute/delegate_execute.cc
+++ b/win8/delegate_execute/delegate_execute.cc
@@ -11,12 +11,15 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/file_util.h"
+#include "base/memory/scoped_ptr.h"
#include "base/process_util.h"
#include "base/string16.h"
#include "base/win/scoped_com_initializer.h"
#include "base/win/scoped_handle.h"
+#include "breakpad/src/client/windows/handler/exception_handler.h"
#include "chrome/common/chrome_switches.h"
#include "command_execute_impl.h"
+#include "win8/delegate_execute/crash_server_init.h"
#include "win8/delegate_execute/delegate_execute_operation.h"
#include "win8/delegate_execute/resource.h"
@@ -106,6 +109,9 @@ int RelaunchChrome(const DelegateExecuteOperation& operation) {
}
extern "C" int WINAPI _tWinMain(HINSTANCE , HINSTANCE, LPTSTR, int nShowCmd) {
+ scoped_ptr<google_breakpad::ExceptionHandler> breakpad =
+ delegate_execute::InitializeCrashReporting();
+
base::AtExitManager exit_manager;
AtlTrace("delegate_execute enter\n");
diff --git a/win8/delegate_execute/delegate_execute.gyp b/win8/delegate_execute/delegate_execute.gyp
index eead4b6..035fbfb 100644
--- a/win8/delegate_execute/delegate_execute.gyp
+++ b/win8/delegate_execute/delegate_execute.gyp
@@ -40,6 +40,7 @@
'type': 'executable',
'dependencies': [
'../../base/base.gyp:base',
+ '../../breakpad/breakpad.gyp:breakpad_handler',
'../../chrome/chrome.gyp:installer_util',
'../../google_update/google_update.gyp:google_update',
'../../ui/ui.gyp:ui',
@@ -52,6 +53,8 @@
'command_execute_impl.cc',
'command_execute_impl.h',
'command_execute_impl.rgs',
+ 'crash_server_init.cc',
+ 'crash_server_init.h',
'delegate_execute.cc',
'delegate_execute.rc',
'delegate_execute.rgs',