OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/crash_keys.h" | 5 #include "chrome/common/crash_keys.h" |
6 | 6 |
| 7 #include "base/format_macros.h" |
| 8 #include "base/logging.h" |
| 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" |
| 11 |
7 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
8 #include "breakpad/src/common/simple_string_dictionary.h" | 13 #include "breakpad/src/common/simple_string_dictionary.h" |
9 #elif defined(OS_WIN) | 14 #elif defined(OS_WIN) |
10 #include "breakpad/src/client/windows/common/ipc_protocol.h" | 15 #include "breakpad/src/client/windows/common/ipc_protocol.h" |
11 #endif | 16 #endif |
12 | 17 |
13 namespace crash_keys { | 18 namespace crash_keys { |
14 | 19 |
15 // A small crash key, guaranteed to never be split into multiple pieces. | 20 // A small crash key, guaranteed to never be split into multiple pieces. |
16 const size_t kSmallSize = 63; | 21 const size_t kSmallSize = 63; |
(...skipping 19 matching lines...) Expand all Loading... |
36 #endif | 41 #endif |
37 | 42 |
38 // Guarantees for crash key sizes. | 43 // Guarantees for crash key sizes. |
39 COMPILE_ASSERT(kSmallSize <= kSingleChunkLength, | 44 COMPILE_ASSERT(kSmallSize <= kSingleChunkLength, |
40 crash_key_chunk_size_too_small); | 45 crash_key_chunk_size_too_small); |
41 #if defined(OS_MACOSX) | 46 #if defined(OS_MACOSX) |
42 COMPILE_ASSERT(kMediumSize <= kSingleChunkLength, | 47 COMPILE_ASSERT(kMediumSize <= kSingleChunkLength, |
43 mac_has_medium_size_crash_key_chunks); | 48 mac_has_medium_size_crash_key_chunks); |
44 #endif | 49 #endif |
45 | 50 |
| 51 const char kActiveURL[] = "url-chunk"; |
| 52 |
| 53 const char kExtensionID[] = "extension-%" PRIuS; |
| 54 const char kNumExtensionsCount[] = "num-extensions"; |
| 55 |
| 56 #if !defined(OS_ANDROID) |
| 57 const char kGPUVendorID[] = "gpu-venid"; |
| 58 const char kGPUDeviceID[] = "gpu-devid"; |
| 59 #endif |
| 60 const char kGPUDriverVersion[] = "gpu-driver"; |
| 61 const char kGPUPixelShaderVersion[] = "gpu-psver"; |
| 62 const char kGPUVertexShaderVersion[] = "gpu-vsver"; |
| 63 #if defined(OS_LINUX) |
| 64 const char kGPUVendor[] = "gpu-gl-vendor"; |
| 65 const char kGPURenderer[] = "gpu-gl-renderer"; |
| 66 #elif defined(OS_MACOSX) |
| 67 const char kGPUGLVersion[] = "gpu-glver"; |
| 68 #endif |
| 69 |
| 70 #if defined(OS_MACOSX) |
| 71 namespace mac { |
| 72 |
| 73 const char kFirstNSException[] = "firstexception"; |
| 74 const char kFirstNSExceptionTrace[] = "firstexception_bt"; |
| 75 |
| 76 const char kLastNSException[] = "lastexception"; |
| 77 const char kLastNSExceptionTrace[] = "lastexception_bt"; |
| 78 |
| 79 const char kNSException[] = "nsexception"; |
| 80 const char kNSExceptionTrace[] = "nsexception_bt"; |
| 81 |
| 82 const char kSendAction[] = "sendaction"; |
| 83 |
| 84 const char kZombie[] = "zombie"; |
| 85 const char kZombieTrace[] = "zombie_dealloc_bt"; |
| 86 |
| 87 } // namespace mac |
| 88 #endif |
| 89 |
46 size_t RegisterChromeCrashKeys() { | 90 size_t RegisterChromeCrashKeys() { |
47 base::debug::CrashKey keys[] = { | 91 // The following keys may be chunked by the underlying crash logging system, |
| 92 // but ultimately constitute a single key-value pair. |
| 93 base::debug::CrashKey fixed_keys[] = { |
48 { kActiveURL, kLargeSize }, | 94 { kActiveURL, kLargeSize }, |
| 95 { kNumExtensionsCount, kSmallSize }, |
49 #if !defined(OS_ANDROID) | 96 #if !defined(OS_ANDROID) |
50 { kGPUVendorID, kSmallSize }, | 97 { kGPUVendorID, kSmallSize }, |
51 { kGPUDeviceID, kSmallSize }, | 98 { kGPUDeviceID, kSmallSize }, |
52 #endif | 99 #endif |
53 { kGPUDriverVersion, kSmallSize }, | 100 { kGPUDriverVersion, kSmallSize }, |
54 { kGPUPixelShaderVersion, kSmallSize }, | 101 { kGPUPixelShaderVersion, kSmallSize }, |
55 { kGPUVertexShaderVersion, kSmallSize }, | 102 { kGPUVertexShaderVersion, kSmallSize }, |
56 #if defined(OS_LINUX) | 103 #if defined(OS_LINUX) |
57 { kGPUVendor, kSmallSize }, | 104 { kGPUVendor, kSmallSize }, |
58 { kGPURenderer, kSmallSize }, | 105 { kGPURenderer, kSmallSize }, |
(...skipping 16 matching lines...) Expand all Loading... |
75 { mac::kZombieTrace, kMediumSize }, | 122 { mac::kZombieTrace, kMediumSize }, |
76 // content/: | 123 // content/: |
77 { "channel_error_bt", kMediumSize }, | 124 { "channel_error_bt", kMediumSize }, |
78 { "remove_route_bt", kMediumSize }, | 125 { "remove_route_bt", kMediumSize }, |
79 { "rwhvm_window", kMediumSize }, | 126 { "rwhvm_window", kMediumSize }, |
80 // media/: | 127 // media/: |
81 { "VideoCaptureDeviceQTKit", kSmallSize }, | 128 { "VideoCaptureDeviceQTKit", kSmallSize }, |
82 #endif | 129 #endif |
83 }; | 130 }; |
84 | 131 |
85 return base::debug::InitCrashKeys(keys, arraysize(keys), kSingleChunkLength); | 132 // This dynamic set of keys is used for sets of key value pairs when gathering |
| 133 // a collection of data, like command line switches or extension IDs. |
| 134 std::vector<base::debug::CrashKey> keys( |
| 135 fixed_keys, fixed_keys + arraysize(fixed_keys)); |
| 136 |
| 137 // Register the extension IDs. |
| 138 { |
| 139 // The fixed_keys names are string constants. Use static storage for |
| 140 // formatted key names as well, since they will persist for the duration of |
| 141 // the program. |
| 142 static char formatted_keys[kExtensionIDMaxCount][sizeof(kExtensionID) + 1] = |
| 143 {{ 0 }}; |
| 144 const size_t formatted_key_len = sizeof(formatted_keys[0]); |
| 145 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { |
| 146 int n = base::snprintf( |
| 147 formatted_keys[i], formatted_key_len, kExtensionID, i); |
| 148 DCHECK_GT(n, 0); |
| 149 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; |
| 150 keys.push_back(crash_key); |
| 151 } |
| 152 } |
| 153 |
| 154 return base::debug::InitCrashKeys(&keys.at(0), keys.size(), |
| 155 kSingleChunkLength); |
86 } | 156 } |
87 | 157 |
88 const char kActiveURL[] = "url-chunk"; | 158 void SetActiveExtensions(const std::set<std::string>& extensions) { |
| 159 base::debug::SetCrashKeyValue(kNumExtensionsCount, |
| 160 base::StringPrintf("%" PRIuS, extensions.size())); |
89 | 161 |
90 #if !defined(OS_ANDROID) | 162 std::set<std::string>::const_iterator it = extensions.begin(); |
91 const char kGPUVendorID[] = "gpu-venid"; | 163 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { |
92 const char kGPUDeviceID[] = "gpu-devid"; | 164 std::string key = base::StringPrintf(kExtensionID, i); |
93 #endif | 165 if (it == extensions.end()) { |
94 const char kGPUDriverVersion[] = "gpu-driver"; | 166 base::debug::ClearCrashKey(key); |
95 const char kGPUPixelShaderVersion[] = "gpu-psver"; | 167 } else { |
96 const char kGPUVertexShaderVersion[] = "gpu-vsver"; | 168 base::debug::SetCrashKeyValue(key, *it); |
97 #if defined(OS_LINUX) | 169 ++it; |
98 const char kGPUVendor[] = "gpu-gl-vendor"; | 170 } |
99 const char kGPURenderer[] = "gpu-gl-renderer"; | 171 } |
100 #elif defined(OS_MACOSX) | 172 } |
101 const char kGPUGLVersion[] = "gpu-glver"; | |
102 #endif | |
103 | |
104 #if defined(OS_MACOSX) | |
105 namespace mac { | |
106 | |
107 const char kFirstNSException[] = "firstexception"; | |
108 const char kFirstNSExceptionTrace[] = "firstexception_bt"; | |
109 | |
110 const char kLastNSException[] = "lastexception"; | |
111 const char kLastNSExceptionTrace[] = "lastexception_bt"; | |
112 | |
113 const char kNSException[] = "nsexception"; | |
114 const char kNSExceptionTrace[] = "nsexception_bt"; | |
115 | |
116 const char kSendAction[] = "sendaction"; | |
117 | |
118 const char kZombie[] = "zombie"; | |
119 const char kZombieTrace[] = "zombie_dealloc_bt"; | |
120 | |
121 } // namespace mac | |
122 #endif | |
123 | 173 |
124 } // namespace crash_keys | 174 } // namespace crash_keys |
OLD | NEW |