OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This module contains the necessary code to register the Breakpad exception | 5 // This module contains the necessary code to register the Breakpad exception |
6 // handler. This implementation is based on Chrome's crash reporting code. | 6 // handler. This implementation is based on Chrome's crash reporting code. |
7 | 7 |
8 #include "chrome_elf/breakpad.h" | 8 #include "chrome_elf/breakpad.h" |
9 | 9 |
10 #include <sddl.h> | 10 #include <sddl.h> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/strings/string16.h" | |
13 #include "breakpad/src/client/windows/handler/exception_handler.h" | 14 #include "breakpad/src/client/windows/handler/exception_handler.h" |
14 #include "chrome/common/chrome_version.h" | 15 #include "chrome/common/chrome_version.h" |
15 #include "chrome/install_static/install_util.h" | 16 #include "chrome/install_static/install_util.h" |
16 | 17 |
17 google_breakpad::ExceptionHandler* g_elf_breakpad = NULL; | 18 google_breakpad::ExceptionHandler* g_elf_breakpad = NULL; |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 const wchar_t kBreakpadProductName[] = L"Chrome"; | 22 const wchar_t kBreakpadProductName[] = L"Chrome"; |
22 const wchar_t kBreakpadVersionEntry[] = L"ver"; | 23 const wchar_t kBreakpadVersionEntry[] = L"ver"; |
23 const wchar_t kBreakpadProdEntry[] = L"prod"; | 24 const wchar_t kBreakpadProdEntry[] = L"prod"; |
24 const wchar_t kBreakpadPlatformEntry[] = L"plat"; | 25 const wchar_t kBreakpadPlatformEntry[] = L"plat"; |
25 const wchar_t kBreakpadPlatformWin32[] = L"Win32"; | 26 const wchar_t kBreakpadPlatformWin32[] = L"Win32"; |
26 const wchar_t kBreakpadProcessEntry[] = L"ptype"; | 27 const wchar_t kBreakpadProcessEntry[] = L"ptype"; |
27 const wchar_t kBreakpadChannelEntry[] = L"channel"; | 28 const wchar_t kBreakpadChannelEntry[] = L"channel"; |
28 | 29 |
29 // The protocol for connecting to the out-of-process Breakpad crash | 30 // The protocol for connecting to the out-of-process Breakpad crash |
30 // reporter is different for x86-32 and x86-64: the message sizes | 31 // reporter is different for x86-32 and x86-64: the message sizes |
31 // are different because the message struct contains a pointer. As | 32 // are different because the message struct contains a pointer. As |
32 // a result, there are two different named pipes to connect to. The | 33 // a result, there are two different named pipes to connect to. The |
33 // 64-bit one is distinguished with an "-x64" suffix. | 34 // 64-bit one is distinguished with an "-x64" suffix. |
34 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices\\"; | 35 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices\\"; |
35 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; | 36 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; |
36 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; | 37 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; |
37 | 38 |
38 const wchar_t kNoErrorDialogs[] = L"noerrdialogs"; | 39 const wchar_t kNoErrorDialogs[] = L"noerrdialogs"; |
39 | 40 |
40 google_breakpad::CustomClientInfo* GetCustomInfo() { | 41 google_breakpad::CustomClientInfo* GetCustomInfo() { |
41 base::string16 process = IsNonBrowserProcess() ? L"renderer" : L"browser"; | 42 base::string16 process = |
43 install_static::IsNonBrowserProcess() ? L"renderer" : L"browser"; | |
42 | 44 |
43 wchar_t exe_path[MAX_PATH] = {}; | 45 wchar_t exe_path[MAX_PATH] = {}; |
44 base::string16 channel; | 46 base::string16 channel; |
45 if (GetModuleFileName(NULL, exe_path, arraysize(exe_path)) && | 47 if (GetModuleFileName(NULL, exe_path, arraysize(exe_path)) && |
46 IsCanary(exe_path)) { | 48 install_static::IsSxSChrome(exe_path)) { |
47 channel = L"canary"; | 49 channel = L"canary"; |
48 } | 50 } |
49 | 51 |
50 static google_breakpad::CustomInfoEntry ver_entry( | 52 static google_breakpad::CustomInfoEntry ver_entry( |
51 kBreakpadVersionEntry, TEXT(CHROME_VERSION_STRING)); | 53 kBreakpadVersionEntry, TEXT(CHROME_VERSION_STRING)); |
52 static google_breakpad::CustomInfoEntry prod_entry( | 54 static google_breakpad::CustomInfoEntry prod_entry( |
53 kBreakpadProdEntry, kBreakpadProductName); | 55 kBreakpadProdEntry, kBreakpadProductName); |
54 static google_breakpad::CustomInfoEntry plat_entry( | 56 static google_breakpad::CustomInfoEntry plat_entry( |
55 kBreakpadPlatformEntry, kBreakpadPlatformWin32); | 57 kBreakpadPlatformEntry, kBreakpadPlatformWin32); |
56 static google_breakpad::CustomInfoEntry proc_entry( | 58 static google_breakpad::CustomInfoEntry proc_entry( |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 | 141 |
140 #if defined(GOOGLE_CHROME_BUILD) && defined(OFFICIAL_BUILD) | 142 #if defined(GOOGLE_CHROME_BUILD) && defined(OFFICIAL_BUILD) |
141 bool is_official_chrome_build = true; | 143 bool is_official_chrome_build = true; |
142 #else | 144 #else |
143 bool is_official_chrome_build = false; | 145 bool is_official_chrome_build = false; |
144 #endif | 146 #endif |
145 | 147 |
146 base::string16 pipe_name; | 148 base::string16 pipe_name; |
147 | 149 |
148 bool enabled_by_policy = false; | 150 bool enabled_by_policy = false; |
149 bool use_policy = ReportingIsEnforcedByPolicy(&enabled_by_policy); | 151 bool use_policy = |
grt (UTC plus 2)
2016/05/02 22:22:06
since install_static::GetCollectStatsConsent calls
ananta
2016/05/02 22:43:27
Once chrome_elf is changed to use crashpad, we don
| |
152 install_static::ReportingIsEnforcedByPolicy(&enabled_by_policy); | |
150 | 153 |
151 if (!use_policy && IsHeadless()) { | 154 if (!use_policy && IsHeadless()) { |
152 pipe_name = kChromePipeName; | 155 pipe_name = kChromePipeName; |
153 } else if (use_policy ? | 156 } else if (use_policy ? enabled_by_policy |
154 enabled_by_policy : | 157 : (is_official_chrome_build && |
155 (is_official_chrome_build && AreUsageStatsEnabled(exe_path))) { | 158 install_static::GetCollectStatsConsent())) { |
156 // Build the pipe name. It can be one of: | 159 // Build the pipe name. It can be one of: |
157 // 32-bit system: \\.\pipe\GoogleCrashServices\S-1-5-18 | 160 // 32-bit system: \\.\pipe\GoogleCrashServices\S-1-5-18 |
158 // 32-bit user: \\.\pipe\GoogleCrashServices\<user SID> | 161 // 32-bit user: \\.\pipe\GoogleCrashServices\<user SID> |
159 // 64-bit system: \\.\pipe\GoogleCrashServices\S-1-5-18-x64 | 162 // 64-bit system: \\.\pipe\GoogleCrashServices\S-1-5-18-x64 |
160 // 64-bit user: \\.\pipe\GoogleCrashServices\<user SID>-x64 | 163 // 64-bit user: \\.\pipe\GoogleCrashServices\<user SID>-x64 |
161 base::string16 user_sid = IsSystemInstall(exe_path) ? kSystemPrincipalSid : | 164 base::string16 user_sid = install_static::IsSystemInstall(exe_path) |
162 GetUserSidString(); | 165 ? kSystemPrincipalSid |
166 : GetUserSidString(); | |
163 if (user_sid.empty()) | 167 if (user_sid.empty()) |
164 return; | 168 return; |
165 | 169 |
166 pipe_name = kGoogleUpdatePipeName; | 170 pipe_name = kGoogleUpdatePipeName; |
167 pipe_name += user_sid; | 171 pipe_name += user_sid; |
168 | 172 |
169 #if defined(_WIN64) | 173 #if defined(_WIN64) |
170 pipe_name += L"-x64"; | 174 pipe_name += L"-x64"; |
171 #endif | 175 #endif |
172 } else { | 176 } else { |
(...skipping 10 matching lines...) Expand all Loading... | |
183 google_breakpad::ExceptionHandler::HANDLER_ALL, | 187 google_breakpad::ExceptionHandler::HANDLER_ALL, |
184 dump_type, | 188 dump_type, |
185 pipe_name.c_str(), | 189 pipe_name.c_str(), |
186 GetCustomInfo()); | 190 GetCustomInfo()); |
187 | 191 |
188 if (g_elf_breakpad->IsOutOfProcess()) { | 192 if (g_elf_breakpad->IsOutOfProcess()) { |
189 // Tells breakpad to handle breakpoint and single step exceptions. | 193 // Tells breakpad to handle breakpoint and single step exceptions. |
190 g_elf_breakpad->set_handle_debug_exceptions(true); | 194 g_elf_breakpad->set_handle_debug_exceptions(true); |
191 } | 195 } |
192 } | 196 } |
OLD | NEW |