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

Side by Side Diff: chrome/common/child_process_logging_win.cc

Issue 2088133002: Switch chrome_elf exception handling from breakpad to crashpad. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Register crash keys only once in the process. Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/common/child_process_logging.h" 5 #include "chrome/common/child_process_logging.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 11 matching lines...) Expand all
22 // exported in breakpad_win.cc/crashpad_win.cc: 22 // exported in breakpad_win.cc/crashpad_win.cc:
23 // void __declspec(dllexport) __cdecl SetCrashKeyValueImpl. 23 // void __declspec(dllexport) __cdecl SetCrashKeyValueImpl.
24 typedef void(__cdecl* SetCrashKeyValue)(const wchar_t*, const wchar_t*); 24 typedef void(__cdecl* SetCrashKeyValue)(const wchar_t*, const wchar_t*);
25 25
26 // exported in breakpad_win.cc/crashpad_win.cc: 26 // exported in breakpad_win.cc/crashpad_win.cc:
27 // void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl. 27 // void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl.
28 typedef void(__cdecl* ClearCrashKeyValue)(const wchar_t*); 28 typedef void(__cdecl* ClearCrashKeyValue)(const wchar_t*);
29 29
30 void SetCrashKeyValueTrampoline(const base::StringPiece& key, 30 void SetCrashKeyValueTrampoline(const base::StringPiece& key,
31 const base::StringPiece& value) { 31 const base::StringPiece& value) {
32 static SetCrashKeyValue set_crash_key = [](){ 32 static SetCrashKeyValue set_crash_key = []() {
33 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); 33 HMODULE elf_module = GetModuleHandle(L"chrome_elf.dll");
34 return reinterpret_cast<SetCrashKeyValue>( 34 return reinterpret_cast<SetCrashKeyValue>(
35 exe_module ? GetProcAddress(exe_module, "SetCrashKeyValueImpl") 35 elf_module ? GetProcAddress(elf_module, "SetCrashKeyValueImpl")
36 : nullptr); 36 : nullptr);
37 }(); 37 }();
38 if (set_crash_key) { 38 if (set_crash_key) {
39 (set_crash_key)(base::UTF8ToWide(key).data(), 39 (set_crash_key)(base::UTF8ToWide(key).data(),
40 base::UTF8ToWide(value).data()); 40 base::UTF8ToWide(value).data());
41 } 41 }
42 } 42 }
43 43
44 void ClearCrashKeyValueTrampoline(const base::StringPiece& key) { 44 void ClearCrashKeyValueTrampoline(const base::StringPiece& key) {
45 static ClearCrashKeyValue clear_crash_key = [](){ 45 static ClearCrashKeyValue clear_crash_key = []() {
46 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); 46 HMODULE elf_module = GetModuleHandle(L"chrome_elf.dll");
47 return reinterpret_cast<ClearCrashKeyValue>( 47 return reinterpret_cast<ClearCrashKeyValue>(
48 exe_module ? GetProcAddress(exe_module, "ClearCrashKeyValueImpl") 48 elf_module ? GetProcAddress(elf_module, "ClearCrashKeyValueImpl")
49 : nullptr); 49 : nullptr);
50 }(); 50 }();
51 if (clear_crash_key) 51 if (clear_crash_key)
52 (clear_crash_key)(base::UTF8ToWide(key).data()); 52 (clear_crash_key)(base::UTF8ToWide(key).data());
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 void Init() { 57 void Init() {
58 crash_keys::RegisterChromeCrashKeys();
59 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueTrampoline,
60 &ClearCrashKeyValueTrampoline);
61
62 // This would be handled by BreakpadClient::SetCrashClientIdFromGUID(), but 58 // This would be handled by BreakpadClient::SetCrashClientIdFromGUID(), but
63 // because of the aforementioned issue, crash keys aren't ready yet at the 59 // because of the aforementioned issue, crash keys aren't ready yet at the
64 // time of Breakpad initialization, load the client id backed up in Google 60 // time of Breakpad initialization, load the client id backed up in Google
65 // Update settings instead. 61 // Update settings instead.
62 // Please note if we are using CrashPad via chrome_elf then we need to call
scottmg 2016/06/27 19:37:46 nit; CrashPad -> Crashpad
ananta 2016/06/27 20:00:26 Done.
63 // into chrome_elf to pass in the client id.
66 std::unique_ptr<metrics::ClientInfo> client_info = 64 std::unique_ptr<metrics::ClientInfo> client_info =
67 GoogleUpdateSettings::LoadMetricsClientInfo(); 65 GoogleUpdateSettings::LoadMetricsClientInfo();
68 if (client_info) 66
69 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id); 67 // Register crash keys using chrome_elf if it is loaded. This is because
68 // chrome_elf and chrome and other executables have their own copies of
69 // base.
70 // TODO(ananta)
71 // Remove this when the change to not require crash key registration lands.
72 HMODULE elf_module = GetModuleHandle(L"chrome_elf.dll");
73 if (elf_module) {
74 using RegisterCrashKeysFunction = void (*)(const char* client_id);
75 RegisterCrashKeysFunction register_keys_fn =
76 reinterpret_cast<RegisterCrashKeysFunction>(
77 ::GetProcAddress(elf_module, "RegisterCrashKeysImpl"));
78 DCHECK(register_keys_fn);
79 register_keys_fn(client_info ? client_info->client_id.c_str() : nullptr);
80 } else {
81 crash_keys::RegisterChromeCrashKeys();
scottmg 2016/06/27 20:09:24 I'm confused now, when is the non-elf path going t
82 if (client_info)
scottmg 2016/06/27 19:37:46 This should be out of the if/else I think?
ananta 2016/06/27 20:00:26 No. If exception handling is being done by chrome_
scottmg 2016/06/27 20:09:24 Ah, OK. Let's call RegisterCrashKeysImpl something
ananta 2016/06/27 20:36:05 Done.
83 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id);
84 }
85
86 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueTrampoline,
87 &ClearCrashKeyValueTrampoline);
70 } 88 }
71 89
72 } // namespace child_process_logging 90 } // namespace child_process_logging
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698