Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Side by Side Diff: crash_collector.cc

Issue 4018008: crash-reporter: Generate kernel crash signatures for server-side grouping of similar crashes (Closed) Base URL: http://git.chromium.org/git/crash-reporter.git
Patch Set: Respond to petkov review Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « crash_collector.h ('k') | crash_collector_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 "crash-reporter/crash_collector.h" 5 #include "crash-reporter/crash_collector.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <pwd.h> // For struct passwd. 8 #include <pwd.h> // For struct passwd.
9 #include <sys/types.h> // for mode_t. 9 #include <sys/types.h> // for mode_t.
10 10
(...skipping 21 matching lines...) Expand all
32 // Maximum crash reports per crash spool directory. Note that this is 32 // Maximum crash reports per crash spool directory. Note that this is
33 // a separate maximum from the maximum rate at which we upload these 33 // a separate maximum from the maximum rate at which we upload these
34 // diagnostics. The higher this rate is, the more space we allow for 34 // diagnostics. The higher this rate is, the more space we allow for
35 // core files, minidumps, and kcrash logs, and equivalently the more 35 // core files, minidumps, and kcrash logs, and equivalently the more
36 // processor and I/O bandwidth we dedicate to handling these crashes when 36 // processor and I/O bandwidth we dedicate to handling these crashes when
37 // many occur at once. Also note that if core files are configured to 37 // many occur at once. Also note that if core files are configured to
38 // be left on the file system, we stop adding crashes when either the 38 // be left on the file system, we stop adding crashes when either the
39 // number of core files or minidumps reaches this number. 39 // number of core files or minidumps reaches this number.
40 const int CrashCollector::kMaxCrashDirectorySize = 32; 40 const int CrashCollector::kMaxCrashDirectorySize = 32;
41 41
42 CrashCollector::CrashCollector() : forced_crash_directory_(NULL) { 42 CrashCollector::CrashCollector()
43 : forced_crash_directory_(NULL),
44 lsb_release_(kLsbRelease) {
43 } 45 }
44 46
45 CrashCollector::~CrashCollector() { 47 CrashCollector::~CrashCollector() {
46 } 48 }
47 49
48 void CrashCollector::Initialize( 50 void CrashCollector::Initialize(
49 CrashCollector::CountCrashFunction count_crash_function, 51 CrashCollector::CountCrashFunction count_crash_function,
50 CrashCollector::IsFeedbackAllowedFunction is_feedback_allowed_function, 52 CrashCollector::IsFeedbackAllowedFunction is_feedback_allowed_function,
51 SystemLogging *logger) { 53 SystemLogging *logger) {
52 CHECK(count_crash_function != NULL); 54 CHECK(count_crash_function != NULL);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 SplitString(*line, separator, &sides); 242 SplitString(*line, separator, &sides);
241 if (sides.size() != 2) { 243 if (sides.size() != 2) {
242 any_errors = true; 244 any_errors = true;
243 continue; 245 continue;
244 } 246 }
245 dictionary->insert(std::pair<std::string, std::string>(sides[0], sides[1])); 247 dictionary->insert(std::pair<std::string, std::string>(sides[0], sides[1]));
246 } 248 }
247 return !any_errors; 249 return !any_errors;
248 } 250 }
249 251
252 void CrashCollector::AddCrashMetaData(const std::string &key,
253 const std::string &value) {
254 extra_metadata_.append(StringPrintf("%s=%s\n", key.c_str(), value.c_str()));
255 }
256
250 void CrashCollector::WriteCrashMetaData(const FilePath &meta_path, 257 void CrashCollector::WriteCrashMetaData(const FilePath &meta_path,
251 const std::string &exec_name, 258 const std::string &exec_name,
252 const std::string &payload_path) { 259 const std::string &payload_path) {
253 std::map<std::string, std::string> contents; 260 std::map<std::string, std::string> contents;
254 if (!ReadKeyValueFile(FilePath(std::string(kLsbRelease)), '=', &contents)) { 261 if (!ReadKeyValueFile(FilePath(std::string(lsb_release_)), '=', &contents)) {
255 logger_->LogError("Problem parsing %s", kLsbRelease); 262 logger_->LogError("Problem parsing %s", lsb_release_);
256 // Even though there was some failure, take as much as we could read. 263 // Even though there was some failure, take as much as we could read.
257 } 264 }
258 std::string version("unknown"); 265 std::string version("unknown");
259 std::map<std::string, std::string>::iterator i; 266 std::map<std::string, std::string>::iterator i;
260 if ((i = contents.find("CHROMEOS_RELEASE_VERSION")) != contents.end()) { 267 if ((i = contents.find("CHROMEOS_RELEASE_VERSION")) != contents.end()) {
261 version = i->second; 268 version = i->second;
262 } 269 }
263 int64 payload_size = -1; 270 int64 payload_size = -1;
264 file_util::GetFileSize(FilePath(payload_path), &payload_size); 271 file_util::GetFileSize(FilePath(payload_path), &payload_size);
265 std::string meta_data = StringPrintf("exec_name=%s\n" 272 std::string meta_data = StringPrintf("%sexec_name=%s\n"
266 "ver=%s\n" 273 "ver=%s\n"
267 "payload_size=%lld\n" 274 "payload_size=%lld\n"
268 "done=1\n", 275 "done=1\n",
276 extra_metadata_.c_str(),
269 exec_name.c_str(), 277 exec_name.c_str(),
270 version.c_str(), 278 version.c_str(),
271 payload_size); 279 payload_size);
272 if (!file_util::WriteFile(meta_path, meta_data.c_str(), meta_data.size())) { 280 if (!file_util::WriteFile(meta_path, meta_data.c_str(), meta_data.size())) {
273 logger_->LogError("Unable to write %s", meta_path.value().c_str()); 281 logger_->LogError("Unable to write %s", meta_path.value().c_str());
274 } 282 }
275 } 283 }
OLDNEW
« no previous file with comments | « crash_collector.h ('k') | crash_collector_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698