diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-24 14:45:05 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-24 14:45:05 +0000 |
commit | 00322d5155d2a6a1abd5506bcb8231335525c1c8 (patch) | |
tree | 6fbfc36d41110e49300b819567ec6f77e3f91fc8 | |
parent | bb581081ed4dc804357fd6a2414af1ce44a78237 (diff) | |
download | chromium_src-00322d5155d2a6a1abd5506bcb8231335525c1c8.zip chromium_src-00322d5155d2a6a1abd5506bcb8231335525c1c8.tar.gz chromium_src-00322d5155d2a6a1abd5506bcb8231335525c1c8.tar.bz2 |
Add Windows implementation for base/debug/crash_logging.h.
BUG=77656,137062
TEST=Official build still reports crash keys.
TBR=thakis@chromium.org
Review URL: https://codereview.chromium.org/11776040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178572 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/breakpad_win.cc | 47 | ||||
-rw-r--r-- | chrome/chrome_exe.gypi | 3 |
2 files changed, 49 insertions, 1 deletions
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc index d141b7c..4366cd3 100644 --- a/chrome/app/breakpad_win.cc +++ b/chrome/app/breakpad_win.cc @@ -14,6 +14,7 @@ #include "base/base_switches.h" #include "base/command_line.h" +#include "base/debug/crash_logging.h" #include "base/environment.h" #include "base/file_util.h" #include "base/file_version_info.h" @@ -32,6 +33,7 @@ #include "chrome/common/child_process_logging.h" #include "chrome/common/chrome_result_codes.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/crash_keys.h" #include "chrome/common/env_vars.h" #include "chrome/installer/util/google_chrome_sxs_distribution.h" #include "chrome/installer/util/google_update_settings.h" @@ -103,6 +105,11 @@ static size_t g_printer_info_offset = 0; static size_t g_num_of_views_offset = 0; static size_t g_num_switches_offset = 0; static size_t g_switches_offset = 0; +static size_t g_dynamic_keys_offset = 0; +typedef std::map<std::string, google_breakpad::CustomInfoEntry*> + DynamicEntriesMap; +DynamicEntriesMap* g_dynamic_entries = NULL; +static size_t g_dynamic_entries_count = 0; // Maximum length for plugin path to include in plugin crash reports. const size_t kMaxPluginPathLength = 256; @@ -464,6 +471,15 @@ google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path, base::StringPrintf(L"experiment-chunk-%i", i).c_str(), L"")); } + // Create space for dynamic ad-hoc keys. The names and values are set using + // the API defined in base/debug/crash_logging.h. + g_dynamic_entries_count = crash_keys::RegisterChromeCrashKeys(); + g_dynamic_keys_offset = g_custom_entries->size(); + for (size_t i = 0; i < g_dynamic_entries_count; ++i) { + g_custom_entries->push_back(google_breakpad::CustomInfoEntry()); + } + g_dynamic_entries = new DynamicEntriesMap; + static google_breakpad::CustomClientInfo custom_client_info; custom_client_info.entries = &g_custom_entries->front(); custom_client_info.count = g_custom_entries->size(); @@ -665,6 +681,32 @@ extern "C" void __declspec(dllexport) __cdecl SetNumberOfViews( SetIntegerValue(g_num_of_views_offset, number_of_views); } +void SetCrashKeyValue(const base::StringPiece& key, + const base::StringPiece& value) { + std::string key_string = key.as_string(); + + DynamicEntriesMap::iterator it = g_dynamic_entries->find(key_string); + google_breakpad::CustomInfoEntry* entry = NULL; + if (it == g_dynamic_entries->end()) { + if (g_dynamic_keys_offset >= g_dynamic_entries_count) + return; + entry = &(*g_custom_entries)[g_dynamic_keys_offset++]; + g_dynamic_entries->insert(std::make_pair(key_string, entry)); + } else { + entry = it->second; + } + + entry->set(UTF8ToWide(key).data(), UTF8ToWide(value).data()); +} + +void ClearCrashKeyValue(const base::StringPiece& key) { + DynamicEntriesMap::iterator it = g_dynamic_entries->find(key.as_string()); + if (it == g_dynamic_entries->end()) + return; + + it->second->set(NULL, NULL); +} + } // namespace namespace testing { @@ -866,8 +908,11 @@ void InitCrashReporter() { GoogleUpdateSettings::GetChromeChannelAndModifiers(!is_per_user_install, &channel_string); + base::debug::SetCrashKeyReportingFunctions( + &SetCrashKeyValue, &ClearCrashKeyValue); + google_breakpad::CustomClientInfo* custom_info = - GetCustomInfo(exe_path, process_type, channel_string); + GetCustomInfo(exe_path, process_type, channel_string); google_breakpad::ExceptionHandler::MinidumpCallback callback = NULL; LPTOP_LEVEL_EXCEPTION_FILTER default_filter = NULL; diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index 4d56ec2..2c8824b 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -474,6 +474,8 @@ ], 'sources': [ 'app/chrome_exe.rc', + 'common/crash_keys.cc', + 'common/crash_keys.h', '<(SHARED_INTERMEDIATE_DIR)/chrome_version/chrome_exe_version.rc', ], 'msvs_settings': { @@ -550,6 +552,7 @@ 'app/breakpad_win.cc', 'app/crash_analysis_win.cc', 'app/hard_error_handler_win.cc', + 'common/crash_keys.cc', 'nacl/nacl_exe_win_64.cc', '../content/app/startup_helper_win.cc', '../content/common/debug_flags.cc', # Needed for sandbox_policy.cc |