diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-14 18:12:11 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-14 18:12:11 +0000 |
commit | 27b38d600b48ed9e648754507029e3f71913fcc5 (patch) | |
tree | bee57f49f5844f178e5b045bf910275c72589e94 /chrome/app | |
parent | bea4c8759ca4a09460e1a64655431badfc772105 (diff) | |
download | chromium_src-27b38d600b48ed9e648754507029e3f71913fcc5.zip chromium_src-27b38d600b48ed9e648754507029e3f71913fcc5.tar.gz chromium_src-27b38d600b48ed9e648754507029e3f71913fcc5.tar.bz2 |
[Win] Fix base::debug::SetCrashKeyValue for child processes.
BUG=77656
R=eroman@chromium.org
Review URL: https://codereview.chromium.org/14989007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app')
-rw-r--r-- | chrome/app/breakpad_win.cc | 43 | ||||
-rw-r--r-- | chrome/app/chrome_breakpad_client.cc | 3 | ||||
-rw-r--r-- | chrome/app/chrome_main_delegate.cc | 5 |
3 files changed, 26 insertions, 25 deletions
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc index 6923194..0cb2813 100644 --- a/chrome/app/breakpad_win.cc +++ b/chrome/app/breakpad_win.cc @@ -110,10 +110,13 @@ 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*> +typedef std::map<std::wstring, google_breakpad::CustomInfoEntry*> DynamicEntriesMap; DynamicEntriesMap* g_dynamic_entries = NULL; -static size_t g_dynamic_entries_count = 0; +// Allow for 128 entries. POSIX uses 64 entries of 256 bytes, so Windows needs +// 256 entries of 64 bytes to match. See CustomInfoEntry::kValueMaxLength in +// Breakpad. +const size_t kMaxDynamicEntries = 256; // Maximum length for plugin path to include in plugin crash reports. const size_t kMaxPluginPathLength = 256; @@ -508,9 +511,8 @@ google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path, // 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 = breakpad::GetBreakpadClient()->RegisterCrashKeys(); g_dynamic_keys_offset = g_custom_entries->size(); - for (size_t i = 0; i < g_dynamic_entries_count; ++i) { + for (size_t i = 0; i < kMaxDynamicEntries; ++i) { // The names will be mutated as they are set. Un-numbered since these are // merely placeholders. The name cannot be empty because Breakpad's // HTTPUpload will interpret that as an invalid parameter. @@ -718,43 +720,37 @@ 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) { +extern "C" void __declspec(dllexport) __cdecl SetCrashKeyValueImpl( + const wchar_t* key, const wchar_t* value) { // CustomInfoEntry limits the length of key and value. If they exceed // their maximum length the underlying string handling functions raise // an exception and prematurely trigger a crash. Truncate here. - base::StringPiece safe_key(key.substr( + std::wstring safe_key(std::wstring(key).substr( 0, google_breakpad::CustomInfoEntry::kNameMaxLength - 1)); - base::StringPiece safe_value(value.substr( + std::wstring safe_value(std::wstring(value).substr( 0, google_breakpad::CustomInfoEntry::kValueMaxLength - 1)); - // Keep a copy of the safe key as a std::string, we'll reuse it later. - std::string key_string(safe_key.begin(), safe_key.end()); - // If we already have a value for this key, update it; otherwise, insert // the new value if we have not exhausted the pre-allocated slots for dynamic // entries. - DynamicEntriesMap::iterator it = g_dynamic_entries->find(key_string); + DynamicEntriesMap::iterator it = g_dynamic_entries->find(safe_key); google_breakpad::CustomInfoEntry* entry = NULL; if (it == g_dynamic_entries->end()) { - if (g_dynamic_entries->size() >= g_dynamic_entries_count) + if (g_dynamic_entries->size() >= kMaxDynamicEntries) return; entry = &(*g_custom_entries)[g_dynamic_keys_offset++]; - g_dynamic_entries->insert(std::make_pair(key_string, entry)); + g_dynamic_entries->insert(std::make_pair(safe_key, entry)); } else { entry = it->second; } - entry->set(UTF8ToWide(safe_key).data(), UTF8ToWide(safe_value).data()); -} - -extern "C" void __declspec(dllexport) __cdecl SetCrashKeyValuePair( - const char* key, const char* value) { - SetCrashKeyValue(base::StringPiece(key), base::StringPiece(value)); + entry->set(safe_key.data(), safe_value.data()); } -void ClearCrashKeyValue(const base::StringPiece& key) { - DynamicEntriesMap::iterator it = g_dynamic_entries->find(key.as_string()); +extern "C" void __declspec(dllexport) __cdecl ClearCrashKeyValueImpl( + const wchar_t* key) { + std::wstring key_string(key); + DynamicEntriesMap::iterator it = g_dynamic_entries->find(key_string); if (it == g_dynamic_entries->end()) return; @@ -991,9 +987,6 @@ void InitCrashReporter() { bool is_per_user_install = breakpad::GetBreakpadClient()->GetIsPerUserInstall( base::FilePath(exe_path)); - base::debug::SetCrashKeyReportingFunctions( - &SetCrashKeyValue, &ClearCrashKeyValue); - google_breakpad::CustomClientInfo* custom_info = GetCustomInfo(exe_path, process_type); diff --git a/chrome/app/chrome_breakpad_client.cc b/chrome/app/chrome_breakpad_client.cc index 967d609..2c0936e 100644 --- a/chrome/app/chrome_breakpad_client.cc +++ b/chrome/app/chrome_breakpad_client.cc @@ -234,6 +234,9 @@ void ChromeBreakpadClient::SetDumpWithoutCrashingFunction(void (*function)()) { #endif size_t ChromeBreakpadClient::RegisterCrashKeys() { + // Note: This is not called on Windows because Breakpad is initialized in the + // EXE module, but code that uses crash keys is in the DLL module. + // RegisterChromeCrashKeys() will be called after the DLL is loaded. return crash_keys::RegisterChromeCrashKeys(); } diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc index e5dafb5..452818a 100644 --- a/chrome/app/chrome_main_delegate.cc +++ b/chrome/app/chrome_main_delegate.cc @@ -41,6 +41,7 @@ #include <atlbase.h> #include <malloc.h> #include "base/strings/string_util.h" +#include "chrome/common/child_process_logging.h" #include "sandbox/win/src/sandbox.h" #include "tools/memory_watcher/memory_watcher.h" #include "ui/base/resource/resource_bundle_win.h" @@ -587,6 +588,10 @@ void ChromeMainDelegate::PreSandboxStartup() { InitMacCrashReporter(command_line, process_type); #endif +#if defined(OS_WIN) + child_process_logging::Init(); +#endif + // Notice a user data directory override if any base::FilePath user_data_dir = command_line.GetSwitchValuePath(switches::kUserDataDir); |