1// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/common/crash_keys.h" 6 7#if defined(OS_MACOSX) 8#include "breakpad/src/common/simple_string_dictionary.h" 9#elif defined(OS_WIN) 10#include "breakpad/src/client/windows/common/ipc_protocol.h" 11#endif 12 13namespace crash_keys { 14 15// A small crash key, guaranteed to never be split into multiple pieces. 16const size_t kSmallSize = 63; 17 18// A medium crash key, which will be chunked on certain platforms but not 19// others. Guaranteed to never be more than four chunks. 20const size_t kMediumSize = kSmallSize * 4; 21 22// A large crash key, which will be chunked on all platforms. This should be 23// used sparingly. 24const size_t kLargeSize = kSmallSize * 16; 25 26// The maximum lengths specified by breakpad include the trailing NULL, so 27// the actual length of the string is one less. 28#if defined(OS_MACOSX) 29static const size_t kSingleChunkLength = 30 google_breakpad::SimpleStringDictionary::value_size - 1; 31#elif defined(OS_WIN) 32static const size_t kSingleChunkLength = 33 google_breakpad::CustomInfoEntry::kValueMaxLength - 1; 34#else 35static const size_t kSingleChunkLength = 63; 36#endif 37 38// Guarantees for crash key sizes. 39COMPILE_ASSERT(kSmallSize <= kSingleChunkLength, 40 crash_key_chunk_size_too_small); 41#if defined(OS_MACOSX) 42COMPILE_ASSERT(kMediumSize <= kSingleChunkLength, 43 mac_has_medium_size_crash_key_chunks); 44#endif 45 46size_t RegisterChromeCrashKeys() { 47 base::debug::CrashKey keys[] = { 48 // TODO(rsesek): Remove when done testing. Needed so arraysize > 0. 49 { "rsesek_key", kSmallSize }, 50 // content/: 51 { "ppapi_path", kMediumSize }, 52 { "subresource_url", kLargeSize }, 53#if defined(OS_MACOSX) 54 { mac::kFirstNSException, kMediumSize }, 55 { mac::kFirstNSExceptionTrace, kMediumSize }, 56 { mac::kLastNSException, kMediumSize }, 57 { mac::kLastNSExceptionTrace, kMediumSize }, 58 { mac::kNSException, kMediumSize }, 59 { mac::kNSExceptionTrace, kMediumSize }, 60 { mac::kSendAction, kMediumSize }, 61 { mac::kZombie, kMediumSize }, 62 { mac::kZombieTrace, kMediumSize }, 63 // content/: 64 { "channel_error_bt", kMediumSize }, 65 { "remove_route_bt", kMediumSize }, 66 { "rwhvm_window", kMediumSize }, 67 // media/: 68 { "VideoCaptureDeviceQTKit", kSmallSize }, 69#endif 70 }; 71 72 return base::debug::InitCrashKeys(keys, arraysize(keys), kSingleChunkLength); 73} 74 75#if defined(OS_MACOSX) 76namespace mac { 77 78const char kFirstNSException[] = "firstexception"; 79const char kFirstNSExceptionTrace[] = "firstexception_bt"; 80 81const char kLastNSException[] = "lastexception"; 82const char kLastNSExceptionTrace[] = "lastexception_bt"; 83 84const char kNSException[] = "nsexception"; 85const char kNSExceptionTrace[] = "nsexception_bt"; 86 87const char kSendAction[] = "sendaction"; 88 89const char kZombie[] = "zombie"; 90const char kZombieTrace[] = "zombie_dealloc_bt"; 91 92} // namespace mac 93#endif 94 95} // namespace crash_keys 96