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" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_split.h" | |
10 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
11 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
12 | 11 |
13 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
14 #include "breakpad/src/common/simple_string_dictionary.h" | 13 #include "breakpad/src/common/simple_string_dictionary.h" |
15 #elif defined(OS_WIN) | 14 #elif defined(OS_WIN) |
16 #include "breakpad/src/client/windows/common/ipc_protocol.h" | 15 #include "breakpad/src/client/windows/common/ipc_protocol.h" |
17 #endif | 16 #endif |
18 | 17 |
19 namespace crash_keys { | 18 namespace crash_keys { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 const char kGPUDriverVersion[] = "gpu-driver"; | 64 const char kGPUDriverVersion[] = "gpu-driver"; |
66 const char kGPUPixelShaderVersion[] = "gpu-psver"; | 65 const char kGPUPixelShaderVersion[] = "gpu-psver"; |
67 const char kGPUVertexShaderVersion[] = "gpu-vsver"; | 66 const char kGPUVertexShaderVersion[] = "gpu-vsver"; |
68 #if defined(OS_LINUX) | 67 #if defined(OS_LINUX) |
69 const char kGPUVendor[] = "gpu-gl-vendor"; | 68 const char kGPUVendor[] = "gpu-gl-vendor"; |
70 const char kGPURenderer[] = "gpu-gl-renderer"; | 69 const char kGPURenderer[] = "gpu-gl-renderer"; |
71 #elif defined(OS_MACOSX) | 70 #elif defined(OS_MACOSX) |
72 const char kGPUGLVersion[] = "gpu-glver"; | 71 const char kGPUGLVersion[] = "gpu-glver"; |
73 #endif | 72 #endif |
74 | 73 |
75 const char kPrinterInfo[] = "prn-info-%" PRIuS; | |
76 | |
77 #if defined(OS_MACOSX) | 74 #if defined(OS_MACOSX) |
78 namespace mac { | 75 namespace mac { |
79 | 76 |
80 const char kFirstNSException[] = "firstexception"; | 77 const char kFirstNSException[] = "firstexception"; |
81 const char kFirstNSExceptionTrace[] = "firstexception_bt"; | 78 const char kFirstNSExceptionTrace[] = "firstexception_bt"; |
82 | 79 |
83 const char kLastNSException[] = "lastexception"; | 80 const char kLastNSException[] = "lastexception"; |
84 const char kLastNSExceptionTrace[] = "lastexception_bt"; | 81 const char kLastNSExceptionTrace[] = "lastexception_bt"; |
85 | 82 |
86 const char kNSException[] = "nsexception"; | 83 const char kNSException[] = "nsexception"; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 const size_t formatted_key_len = sizeof(formatted_keys[0]); | 153 const size_t formatted_key_len = sizeof(formatted_keys[0]); |
157 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { | 154 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { |
158 int n = base::snprintf( | 155 int n = base::snprintf( |
159 formatted_keys[i], formatted_key_len, kExtensionID, i); | 156 formatted_keys[i], formatted_key_len, kExtensionID, i); |
160 DCHECK_GT(n, 0); | 157 DCHECK_GT(n, 0); |
161 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; | 158 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; |
162 keys.push_back(crash_key); | 159 keys.push_back(crash_key); |
163 } | 160 } |
164 } | 161 } |
165 | 162 |
166 // Register the printer info. | |
167 { | |
168 static char formatted_keys[kPrinterInfoCount][sizeof(kPrinterInfo) + 1] = | |
169 {{ 0 }}; | |
170 const size_t formatted_key_len = sizeof(formatted_keys[0]); | |
171 for (size_t i = 1; i <= kPrinterInfoCount; ++i) { | |
172 int n = base::snprintf( | |
173 formatted_keys[i], formatted_key_len, kPrinterInfo, i); | |
174 DCHECK_GT(n, 0); | |
175 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; | |
176 keys.push_back(crash_key); | |
177 } | |
178 } | |
179 | |
180 return base::debug::InitCrashKeys(&keys.at(0), keys.size(), | 163 return base::debug::InitCrashKeys(&keys.at(0), keys.size(), |
181 kSingleChunkLength); | 164 kSingleChunkLength); |
182 } | 165 } |
183 | 166 |
184 void SetActiveExtensions(const std::set<std::string>& extensions) { | 167 void SetActiveExtensions(const std::set<std::string>& extensions) { |
185 base::debug::SetCrashKeyValue(kNumExtensionsCount, | 168 base::debug::SetCrashKeyValue(kNumExtensionsCount, |
186 base::StringPrintf("%" PRIuS, extensions.size())); | 169 base::StringPrintf("%" PRIuS, extensions.size())); |
187 | 170 |
188 std::set<std::string>::const_iterator it = extensions.begin(); | 171 std::set<std::string>::const_iterator it = extensions.begin(); |
189 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { | 172 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { |
190 std::string key = base::StringPrintf(kExtensionID, i); | 173 std::string key = base::StringPrintf(kExtensionID, i); |
191 if (it == extensions.end()) { | 174 if (it == extensions.end()) { |
192 base::debug::ClearCrashKey(key); | 175 base::debug::ClearCrashKey(key); |
193 } else { | 176 } else { |
194 base::debug::SetCrashKeyValue(key, *it); | 177 base::debug::SetCrashKeyValue(key, *it); |
195 ++it; | 178 ++it; |
196 } | 179 } |
197 } | 180 } |
198 } | 181 } |
199 | 182 |
200 ScopedPrinterInfo::ScopedPrinterInfo(const base::StringPiece& data) { | |
201 std::vector<std::string> info; | |
202 base::SplitString(data.as_string(), ';', &info); | |
203 for (size_t i = 1; i <= kPrinterInfoCount; ++i) { | |
204 std::string key = base::StringPrintf(kPrinterInfo, i); | |
205 std::string value; | |
206 if (i < info.size()) | |
207 value = info[i]; | |
208 base::debug::SetCrashKeyValue(key, value); | |
209 } | |
210 } | |
211 | |
212 ScopedPrinterInfo::~ScopedPrinterInfo() { | |
213 for (size_t i = 1; i <= kPrinterInfoCount; ++i) { | |
214 std::string key = base::StringPrintf(kPrinterInfo, i); | |
215 base::debug::ClearCrashKey(key); | |
216 } | |
217 } | |
218 | |
219 } // namespace crash_keys | 183 } // namespace crash_keys |
OLD | NEW |