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 13 namespace crash_keys { 14 15 // A small crash key, guaranteed to never be split into multiple pieces. 16 const 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. 20 const size_t kMediumSize = kSmallSize * 4; 21 22 // A large crash key, which will be chunked on all platforms. This should be 23 // used sparingly. 24 const 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) 29 static const size_t kSingleChunkLength = 30 google_breakpad::SimpleStringDictionary::value_size - 1; 31 #elif defined(OS_WIN) 32 static const size_t kSingleChunkLength = 33 google_breakpad::CustomInfoEntry::kValueMaxLength - 1; 34 #else 35 static const size_t kSingleChunkLength = 63; 36 #endif 37 38 // Guarantees for crash key sizes. 39 COMPILE_ASSERT(kSmallSize <= kSingleChunkLength, 40 crash_key_chunk_size_too_small); 41 #if defined(OS_MACOSX) 42 COMPILE_ASSERT(kMediumSize <= kSingleChunkLength, 43 mac_has_medium_size_crash_key_chunks); 44 #endif 45 46 size_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) 76 namespace mac { 77 78 const char kFirstNSException[] = "firstexception"; 79 const char kFirstNSExceptionTrace[] = "firstexception_bt"; 80 81 const char kLastNSException[] = "lastexception"; 82 const char kLastNSExceptionTrace[] = "lastexception_bt"; 83 84 const char kNSException[] = "nsexception"; 85 const char kNSExceptionTrace[] = "nsexception_bt"; 86 87 const char kSendAction[] = "sendaction"; 88 89 const char kZombie[] = "zombie"; 90 const char kZombieTrace[] = "zombie_dealloc_bt"; 91 92 } // namespace mac 93 #endif 94 95 } // namespace crash_keys 96