OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // TODO(ananta/scottmg) | 5 // TODO(ananta/scottmg) |
6 // Add test coverage for Crashpad. | 6 // Add test coverage for Crashpad. |
7 #include "chrome/app/chrome_crash_reporter_client_win.h" | 7 #include "chrome/app/chrome_crash_reporter_client_win.h" |
8 | 8 |
9 #include <assert.h> | 9 #include <assert.h> |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 _Printf_format_string_ const char* format, | 62 _Printf_format_string_ const char* format, |
63 ...) { | 63 ...) { |
64 va_list arguments; | 64 va_list arguments; |
65 va_start(arguments, format); | 65 va_start(arguments, format); |
66 int result = vsnprintf(buffer, size, format, arguments); | 66 int result = vsnprintf(buffer, size, format, arguments); |
67 va_end(arguments); | 67 va_end(arguments); |
68 return result; | 68 return result; |
69 } | 69 } |
70 | 70 |
71 size_t RegisterCrashKeysHelper() { | 71 size_t RegisterCrashKeysHelper() { |
72 // Crash keys should be registered only once for the duration of the | |
scottmg
2016/06/27 19:37:46
Why is this getting called multiple times now?
ananta
2016/06/27 20:00:26
Can get called from child_process_logging_win.cc w
| |
73 // process. | |
74 static size_t registered_keys_size = 0; | |
75 if (registered_keys_size) | |
76 return registered_keys_size; | |
77 | |
72 // The following keys may be chunked by the underlying crash logging system, | 78 // The following keys may be chunked by the underlying crash logging system, |
73 // but ultimately constitute a single key-value pair. | 79 // but ultimately constitute a single key-value pair. |
74 // | 80 // |
75 // If you're adding keys here, please also add them to the list in | 81 // If you're adding keys here, please also add them to the list in |
76 // //blimp/engine/app/blimp_engine_crash_keys.cc | 82 // //blimp/engine/app/blimp_engine_crash_keys.cc |
77 constexpr base::debug::CrashKey fixed_keys[] = { | 83 constexpr base::debug::CrashKey fixed_keys[] = { |
78 {kMetricsClientId, kSmallSize}, | 84 {kMetricsClientId, kSmallSize}, |
79 {kChannel, kSmallSize}, | 85 {kChannel, kSmallSize}, |
80 {kActiveURL, kLargeSize}, | 86 {kActiveURL, kLargeSize}, |
81 {kNumVariations, kSmallSize}, | 87 {kNumVariations, kSmallSize}, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 [sizeof(kPrinterInfo) + 1] = {{0}}; | 171 [sizeof(kPrinterInfo) + 1] = {{0}}; |
166 const size_t formatted_key_len = sizeof(formatted_keys[0]); | 172 const size_t formatted_key_len = sizeof(formatted_keys[0]); |
167 for (size_t i = 0; i < kPrinterInfoCount; ++i) { | 173 for (size_t i = 0; i < kPrinterInfoCount; ++i) { |
168 // Key names are 1-indexed. | 174 // Key names are 1-indexed. |
169 snprintf(formatted_keys[i], formatted_key_len, kPrinterInfo, i + 1); | 175 snprintf(formatted_keys[i], formatted_key_len, kPrinterInfo, i + 1); |
170 base::debug::CrashKey crash_key = {formatted_keys[i], kSmallSize}; | 176 base::debug::CrashKey crash_key = {formatted_keys[i], kSmallSize}; |
171 keys.push_back(crash_key); | 177 keys.push_back(crash_key); |
172 } | 178 } |
173 } | 179 } |
174 | 180 |
175 return base::debug::InitCrashKeys(&keys[0], keys.size(), kChunkMaxLength); | 181 registered_keys_size = |
182 base::debug::InitCrashKeys(&keys[0], keys.size(), kChunkMaxLength); | |
183 return registered_keys_size; | |
176 } | 184 } |
177 | 185 |
178 } // namespace | 186 } // namespace |
179 | 187 |
180 ChromeCrashReporterClient::ChromeCrashReporterClient() {} | 188 ChromeCrashReporterClient::ChromeCrashReporterClient() {} |
181 | 189 |
182 ChromeCrashReporterClient::~ChromeCrashReporterClient() {} | 190 ChromeCrashReporterClient::~ChromeCrashReporterClient() {} |
183 | 191 |
184 #if !defined(NACL_WIN64) | 192 #if !defined(NACL_WIN64) |
185 // static | 193 // static |
186 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { | 194 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { |
187 static ChromeCrashReporterClient* instance = nullptr; | 195 static ChromeCrashReporterClient* instance = nullptr; |
188 if (instance) | 196 if (instance) |
189 return; | 197 return; |
190 | 198 |
191 instance = new ChromeCrashReporterClient(); | 199 instance = new ChromeCrashReporterClient(); |
192 ANNOTATE_LEAKING_OBJECT_PTR(instance); | 200 ANNOTATE_LEAKING_OBJECT_PTR(instance); |
193 | 201 |
194 std::string process_type = install_static::GetSwitchValueFromCommandLine( | 202 std::string process_type = install_static::GetSwitchValueFromCommandLine( |
195 ::GetCommandLineA(), install_static::kProcessType); | 203 ::GetCommandLineA(), install_static::kProcessType); |
196 if (process_type != install_static::kCrashpadHandler) { | 204 if (process_type != install_static::kCrashpadHandler) { |
197 crash_reporter::SetCrashReporterClient(instance); | 205 crash_reporter::SetCrashReporterClient(instance); |
198 crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(), | 206 crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(), |
199 process_type); | 207 process_type); |
200 } | 208 } |
201 } | 209 } |
202 #endif // NACL_WIN64 | 210 #endif // NACL_WIN64 |
203 | 211 |
212 // static | |
213 void ChromeCrashReporterClient::RegisterCrashKeysForDebugging() { | |
214 RegisterCrashKeysHelper(); | |
215 } | |
216 | |
204 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( | 217 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( |
205 base::string16* crash_dir) { | 218 base::string16* crash_dir) { |
206 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 219 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
207 // location to write breakpad crash dumps can be set. | 220 // location to write breakpad crash dumps can be set. |
208 *crash_dir = | 221 *crash_dir = |
209 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); | 222 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); |
210 return !crash_dir->empty(); | 223 return !crash_dir->empty(); |
211 } | 224 } |
212 | 225 |
213 void ChromeCrashReporterClient::GetProductNameAndVersion( | 226 void ChromeCrashReporterClient::GetProductNameAndVersion( |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 bool ChromeCrashReporterClient::GetCollectStatsConsent() { | 344 bool ChromeCrashReporterClient::GetCollectStatsConsent() { |
332 return install_static::GetCollectStatsConsent(); | 345 return install_static::GetCollectStatsConsent(); |
333 } | 346 } |
334 | 347 |
335 bool ChromeCrashReporterClient::EnableBreakpadForProcess( | 348 bool ChromeCrashReporterClient::EnableBreakpadForProcess( |
336 const std::string& process_type) { | 349 const std::string& process_type) { |
337 return process_type == install_static::kRendererProcess || | 350 return process_type == install_static::kRendererProcess || |
338 process_type == install_static::kPpapiPluginProcess || | 351 process_type == install_static::kPpapiPluginProcess || |
339 process_type == install_static::kGpuProcess; | 352 process_type == install_static::kGpuProcess; |
340 } | 353 } |
OLD | NEW |