Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(701)

Side by Side Diff: chrome_elf/breakpad.cc

Issue 154653002: Breakpad coverage for chrome_elf start up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests and Greg's comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This module contains the necessary code to register the Breakpad exception
6 // handler. This implementation is based on Chrome's crash reporting code.
7
8 #include "chrome_elf/breakpad.h"
9
10 #include <string>
grt (UTC plus 2) 2014/02/14 16:37:33 not needed?
Cait (Slow) 2014/02/14 23:12:04 Done.
11
12 #include "base/macros.h"
13 #include "breakpad/src/client/windows/handler/exception_handler.h"
14 #include "chrome_elf/chrome_elf_util.h"
15 #include "version.h" // NOLINT
16
17 google_breakpad::ExceptionHandler* g_elf_breakpad = NULL;
18
19 namespace {
20
21 const wchar_t kBreakpadProductName[] = L"ChromeElf";
22 const wchar_t kBreakpadVersionEntry[] = L"ver";
23 const wchar_t kBreakpadVersionDefault[] = L"0.1.0.0";
grt (UTC plus 2) 2014/02/14 16:37:33 unused
Cait (Slow) 2014/02/14 23:12:04 Done.
24 const wchar_t kBreakpadProdEntry[] = L"prod";
25 const wchar_t kBreakpadPlatformEntry[] = L"plat";
26 const wchar_t kBreakpadPlatformWin32[] = L"Win32";
27
28 // The protocol for connecting to the out-of-process Breakpad crash
29 // reporter is different for x86-32 and x86-64: the message sizes
30 // are different because the message struct contains a pointer. As
31 // a result, there are two different named pipes to connect to. The
32 // 64-bit one is distinguished with an "-x64" suffix.
33 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\";
34 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18";
35
36 google_breakpad::CustomClientInfo* GetCustomInfo() {
37 static google_breakpad::CustomInfoEntry ver_entry(
38 kBreakpadVersionEntry, TEXT(CHROME_VERSION_STRING));
39 static google_breakpad::CustomInfoEntry prod_entry(
40 kBreakpadProdEntry, kBreakpadProductName);
41 static google_breakpad::CustomInfoEntry plat_entry(
42 kBreakpadPlatformEntry, kBreakpadPlatformWin32);
43 static google_breakpad::CustomInfoEntry entries[] = {
44 ver_entry, prod_entry, plat_entry };
45 static google_breakpad::CustomClientInfo custom_info = {
46 entries, arraysize(entries) };
47 return &custom_info;
48 }
49
50 } // namespace
51
52 int GenerateCrashDump(EXCEPTION_POINTERS* exinfo) {
53 DWORD code = exinfo->ExceptionRecord->ExceptionCode;
54 if (code == EXCEPTION_BREAKPOINT || code == EXCEPTION_SINGLE_STEP)
55 return EXCEPTION_CONTINUE_SEARCH;
56
57 if (g_elf_breakpad != NULL)
58 g_elf_breakpad->WriteMinidumpForException(exinfo);
59 return EXCEPTION_CONTINUE_SEARCH;
60 }
61
62 void InitializeCrashReporting() {
63 wchar_t exe_path[MAX_PATH] = {};
64 if(!::GetModuleFileName(NULL, exe_path, arraysize(exe_path)))
65 return;
66
67 // Do not set up crash reporting if the user has not consented to it.
68 if (!AreUsageStatsEnabled(exe_path))
69 return;
70
71 // Disable the message box for assertions.
72 _CrtSetReportMode(_CRT_ASSERT, 0);
73
74 // Get the alternate dump directory. We use the temp path.
75 // N.B. We don't use base::GetTempDir() here to avoid running more code then
76 // necessary before crashes can be properly reported.
77 wchar_t temp_directory[MAX_PATH + 1] = {};
78 DWORD length = GetTempPath(MAX_PATH, temp_directory);
79 if (length == 0)
80 return;
81
82 // Minidump with stacks, PEB, TEBs and unloaded module list.
83 MINIDUMP_TYPE dump_type = static_cast<MINIDUMP_TYPE>(
84 MiniDumpWithProcessThreadData | // Get PEB and TEB.
85 MiniDumpWithUnloadedModules | // Get unloaded modules when available.
86 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by
87 // stack.
88
89 // Build the pipe name. It can be either:
grt (UTC plus 2) 2014/02/14 16:37:33 either -> one of
Cait (Slow) 2014/02/14 23:12:04 Done.
90 // 32-bit system: \\.\pipe\GoogleCrashServices\S-1-5-18
91 // 32-bit user: \\.\pipe\GoogleCrashServices\<user SID>
92 // 64-bit system: \\.\pipe\GoogleCrashServices\S-1-5-18-x64
93 // 64-bit user: \\.\pipe\GoogleCrashServices\<user SID>-x64
94 base::string16 user_sid = kSystemPrincipalSid;
grt (UTC plus 2) 2014/02/14 16:37:33 shouldn't this connect to the crash_service on the
Cait (Slow) 2014/02/14 23:12:04 Done -- if breakpad is enabled by policy, do we st
95
96 if (!IsSystemInstall(exe_path)) {
grt (UTC plus 2) 2014/02/14 16:37:33 if (!A && !B) return;
Cait (Slow) 2014/02/14 23:12:04 Done.
97 if (!GetUserSidString(&user_sid)) {
98 return;
99 }
100 }
101
102 base::string16 pipe_name = kGoogleUpdatePipeName;
103 pipe_name += user_sid;
104
105 #if defined(_WIN64)
106 pipe_name += L"-x64";
107 #endif
108
109 g_elf_breakpad = new google_breakpad::ExceptionHandler(
110 temp_directory,
111 NULL,
112 NULL,
113 NULL,
114 google_breakpad::ExceptionHandler::HANDLER_ALL,
115 dump_type,
116 pipe_name.c_str(),
117 GetCustomInfo());
118
119 if (g_elf_breakpad->IsOutOfProcess()) {
120 // Tells breakpad to handle breakpoint and single step exceptions.
121 g_elf_breakpad->set_handle_debug_exceptions(true);
122 }
123 }
OLDNEW
« no previous file with comments | « chrome_elf/breakpad.h ('k') | chrome_elf/chrome_elf.gyp » ('j') | chrome_elf/chrome_elf_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698