Chromium Code Reviews| Index: chrome/app/chrome_crash_reporter_client_win.cc |
| diff --git a/chrome/app/chrome_crash_reporter_client_win.cc b/chrome/app/chrome_crash_reporter_client_win.cc |
| index 6cd77d62cb9bd13497d0ffc52ee761cc416d05ce..1b8b8da44af7b8264850a7089368c1997be572ad 100644 |
| --- a/chrome/app/chrome_crash_reporter_client_win.cc |
| +++ b/chrome/app/chrome_crash_reporter_client_win.cc |
| @@ -12,15 +12,201 @@ |
| #include <memory> |
| #include <string> |
| -#include "build/build_config.h" |
| +#include "base/command_line.h" |
| +#include "base/debug/crash_logging.h" |
| +#include "base/debug/leak_annotations.h" |
| +#include "base/format_macros.h" |
| #include "chrome/common/chrome_result_codes.h" |
| -#include "chrome/common/crash_keys.h" |
| #include "chrome/install_static/install_util.h" |
| +#include "components/crash/content/app/crashpad.h" |
| +#include "components/crash/core/common/crash_keys.h" |
| + |
| +namespace { |
| + |
| +// TODO(ananta) |
| +// When the new crash key map implementation lands, we should remove the |
| +// constants defined below, the RegisterCrashKeysHelper function, the |
| +// RegisterCrashKeys function in the crash_keys::CrashReporterClient interface |
| +// and the snprintf function defined here. |
| +const char kActiveURL[] = "url-chunk"; |
|
grt (UTC plus 2)
2016/06/10 14:20:01
nit: constexpr for compile-time constants
ananta
2016/06/10 18:29:57
Done.
|
| +const char kFontKeyName[] = "font_key_name"; |
| + |
| +// Installed extensions. |kExtensionID| should be formatted with an integer, |
| +// in the range [0, kExtensionIDMaxCount). |
| +const char kNumExtensionsCount[] = "num-extensions"; |
| +const size_t kExtensionIDMaxCount = 10; |
| +const char kExtensionID[] = "extension-%" PRIuS; |
| + |
| +const char kShutdownType[] = "shutdown-type"; |
| + |
| +const char kGPUVendorID[] = "gpu-venid"; |
| +const char kGPUDeviceID[] = "gpu-devid"; |
| +const char kGPUDriverVersion[] = "gpu-driver"; |
| +const char kGPUPixelShaderVersion[] = "gpu-psver"; |
| +const char kGPUVertexShaderVersion[] = "gpu-vsver"; |
| + |
| +const char kHungAudioThreadDetails[] = "hung-audio-thread-details"; |
| + |
| +const char kViewCount[] = "view-count"; |
| +const char kZeroEncodeDetails[] = "zero-encode-details"; |
| + |
| +// The user's printers, up to kPrinterInfoCount. Should be set with |
| +// ScopedPrinterInfo. |
| +const size_t kPrinterInfoCount = 4; |
| +const char kPrinterInfo[] = "prn-info-%" PRIuS; |
| + |
| +using namespace crash_keys; |
| + |
| +int snprintf(char* buffer, |
| + size_t size, |
| + _Printf_format_string_ const char* format, |
| + ...) { |
| + va_list arguments; |
| + va_start(arguments, format); |
| + int result = vsnprintf(buffer, size, format, arguments); |
| + va_end(arguments); |
| + return result; |
| +} |
| + |
| +size_t RegisterCrashKeysHelper() { |
| + // The following keys may be chunked by the underlying crash logging system, |
| + // but ultimately constitute a single key-value pair. |
| + // |
| + // If you're adding keys here, please also add them to the list in |
| + // //blimp/engine/app/blimp_engine_crash_keys.cc |
| + base::debug::CrashKey fixed_keys[] = { |
|
grt (UTC plus 2)
2016/06/10 14:20:01
can/should this be constexpr? this will avoid push
ananta
2016/06/10 18:29:57
Done. I am hoping to remove this code soon. Once s
|
| + {kMetricsClientId, kSmallSize}, |
| + {kChannel, kSmallSize}, |
| + {kActiveURL, kLargeSize}, |
| + {kNumVariations, kSmallSize}, |
| + {kVariations, kLargeSize}, |
| + {kNumExtensionsCount, kSmallSize}, |
| + {kShutdownType, kSmallSize}, |
| + {kGPUVendorID, kSmallSize}, |
| + {kGPUDeviceID, kSmallSize}, |
| + {kGPUDriverVersion, kSmallSize}, |
| + {kGPUPixelShaderVersion, kSmallSize}, |
| + {kGPUVertexShaderVersion, kSmallSize}, |
| + |
| + // content/: |
| + {"discardable-memory-allocated", kSmallSize}, |
| + {"discardable-memory-free", kSmallSize}, |
| + {kFontKeyName, kSmallSize}, |
| + {"ppapi_path", kMediumSize}, |
| + {"subresource_url", kLargeSize}, |
| + {"total-discardable-memory-allocated", kSmallSize}, |
| + {kBug464926CrashKey, kSmallSize}, |
| + {kViewCount, kSmallSize}, |
| + |
| + // media/: |
| + {kHungAudioThreadDetails, kSmallSize}, |
| + {kZeroEncodeDetails, kSmallSize}, |
| + |
| + // Temporary for http://crbug.com/575245. |
| + {"swapout_frame_id", kSmallSize}, |
| + {"swapout_proxy_id", kSmallSize}, |
| + {"swapout_view_id", kSmallSize}, |
| + {"commit_frame_id", kSmallSize}, |
| + {"commit_proxy_id", kSmallSize}, |
| + {"commit_view_id", kSmallSize}, |
| + {"commit_main_render_frame_id", kSmallSize}, |
| + {"newproxy_proxy_id", kSmallSize}, |
| + {"newproxy_view_id", kSmallSize}, |
| + {"newproxy_opener_id", kSmallSize}, |
| + {"newproxy_parent_id", kSmallSize}, |
| + {"rvinit_view_id", kSmallSize}, |
| + {"rvinit_proxy_id", kSmallSize}, |
| + {"rvinit_main_frame_id", kSmallSize}, |
| + {"initrf_frame_id", kSmallSize}, |
| + {"initrf_proxy_id", kSmallSize}, |
| + {"initrf_view_id", kSmallSize}, |
| + {"initrf_main_frame_id", kSmallSize}, |
| + {"initrf_view_is_live", kSmallSize}, |
| + |
| + // Temporary for https://crbug.com/591478. |
| + {"initrf_parent_proxy_exists", kSmallSize}, |
| + {"initrf_render_view_is_live", kSmallSize}, |
| + {"initrf_parent_is_in_same_site_instance", kSmallSize}, |
| + {"initrf_parent_process_is_live", kSmallSize}, |
| + {"initrf_root_is_in_same_site_instance", kSmallSize}, |
| + {"initrf_root_is_in_same_site_instance_as_parent", kSmallSize}, |
| + {"initrf_root_process_is_live", kSmallSize}, |
| + {"initrf_root_proxy_is_live", kSmallSize}, |
| + |
| + // Temporary for https://crbug.com/612711. |
| + {"aci_wrong_sp_extension_id", kSmallSize}, |
| + |
| + // Temporary for https://crbug.com/616149. |
| + {"existing_extension_pref_value_type", crash_keys::kSmallSize}, |
| + }; |
| + |
| + // This dynamic set of keys is used for sets of key value pairs when gathering |
| + // a collection of data, like command line switches or extension IDs. |
| + std::vector<base::debug::CrashKey> keys(fixed_keys, |
| + fixed_keys + arraysize(fixed_keys)); |
| + |
| + crash_keys::GetCrashKeysForCommandLineSwitches(&keys); |
| + |
| + // Register the extension IDs. |
| + { |
| + static char formatted_keys[kExtensionIDMaxCount] |
| + [sizeof(kExtensionID) + 1] = {{0}}; |
| + const size_t formatted_key_len = sizeof(formatted_keys[0]); |
| + for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { |
| + snprintf(formatted_keys[i], formatted_key_len, kExtensionID, i + 1); |
| + base::debug::CrashKey crash_key = {formatted_keys[i], kSmallSize}; |
| + keys.push_back(crash_key); |
| + } |
| + } |
| + |
| + // Register the printer info. |
| + { |
| + static char formatted_keys[kPrinterInfoCount] |
| + [sizeof(kPrinterInfo) + 1] = {{0}}; |
| + const size_t formatted_key_len = sizeof(formatted_keys[0]); |
| + for (size_t i = 0; i < kPrinterInfoCount; ++i) { |
| + // Key names are 1-indexed. |
| + snprintf(formatted_keys[i], formatted_key_len, kPrinterInfo, i + 1); |
| + base::debug::CrashKey crash_key = {formatted_keys[i], kSmallSize}; |
| + keys.push_back(crash_key); |
| + } |
| + } |
| + |
| + return base::debug::InitCrashKeys(&keys.at(0), keys.size(), kChunkMaxLength); |
|
grt (UTC plus 2)
2016/06/10 14:20:01
use &keys[0] since we don't handle exceptions and
ananta
2016/06/10 18:29:57
Done.
|
| +} |
| + |
| +} // namespace |
| ChromeCrashReporterClient::ChromeCrashReporterClient() {} |
| ChromeCrashReporterClient::~ChromeCrashReporterClient() {} |
| +#if !defined(NACL_WIN64) |
| +// static |
| +void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { |
| + static ChromeCrashReporterClient* instance = nullptr; |
| + if (instance) |
| + return; |
| + |
| + instance = new ChromeCrashReporterClient(); |
| + ANNOTATE_LEAKING_OBJECT_PTR(instance); |
| + |
| + base::CommandLine::Init(0, nullptr); |
|
grt (UTC plus 2)
2016/06/10 14:20:01
remove
ananta
2016/06/10 18:29:57
done.
|
| + // Initialize the CommandLine singleton from the environment. |
| + base::CommandLine::Init(0, nullptr); |
| + const base::CommandLine* command_line = |
| + base::CommandLine::ForCurrentProcess(); |
| + |
| + const std::string process_type = |
| + command_line->GetSwitchValueASCII(install_static::kProcessType); |
| + if (process_type != install_static::kCrashpadHandler) { |
| + crash_reporter::SetCrashReporterClient(instance); |
| + crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(), |
| + process_type); |
| + } |
| +} |
| +#endif // NACL_WIN64 |
| + |
| bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( |
| base::string16* crash_dir) { |
| // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
| @@ -137,8 +323,11 @@ bool ChromeCrashReporterClient::GetCrashDumpLocation( |
| return install_static::GetDefaultCrashDumpLocation(crash_dir); |
| } |
| +// TODO(ananta) |
| +// This function should be removed when the new crash key map implementation |
| +// lands. |
| size_t ChromeCrashReporterClient::RegisterCrashKeys() { |
| - return crash_keys::RegisterChromeCrashKeys(); |
| + return RegisterCrashKeysHelper(); |
| } |
| bool ChromeCrashReporterClient::IsRunningUnattended() { |