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

Unified Diff: chrome/app/breakpad_linux.cc

Issue 16019015: [Linux] Implement the crash key logging mechanism. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/app/breakpad_linux.cc
diff --git a/chrome/app/breakpad_linux.cc b/chrome/app/breakpad_linux.cc
index 15d89bbec8a4e146c0b04f954e60001f392e2fe6..efab223f0a75ce6161bb7c79ad534de1a45de7e5 100644
--- a/chrome/app/breakpad_linux.cc
+++ b/chrome/app/breakpad_linux.cc
@@ -5,7 +5,7 @@
// For linux_syscall_support.h. This makes it safe to call embedded system
// calls when in seccomp mode.
-#include "chrome/app/breakpad_linux.h"
+#include "chrome/app/breakpad_linux_impl.h"
#include <fcntl.h>
#include <poll.h>
@@ -23,6 +23,7 @@
#include <string>
#include "base/command_line.h"
+#include "base/debug/crash_logging.h"
#include "base/files/file_path.h"
#include "base/linux_util.h"
#include "base/path_service.h"
@@ -40,6 +41,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info_posix.h"
+#include "chrome/common/crash_keys.h"
#include "chrome/common/dump_without_crashing.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/logging_chrome.h"
@@ -84,6 +86,7 @@ bool g_is_crash_reporter_enabled = false;
uint64_t g_process_start_time = 0;
char* g_crash_log_path = NULL;
ExceptionHandler* g_breakpad = NULL;
+
#if defined(ADDRESS_SANITIZER)
const char* g_asan_report_str = NULL;
#endif
@@ -91,6 +94,8 @@ const char* g_asan_report_str = NULL;
char* g_process_type = NULL;
#endif
+CrashKeyStorage* g_crash_keys = NULL;
+
// Writes the value |v| as 16 hex characters to the memory pointed at by
// |output|.
void write_uint64_hex(char* output, uint64_t v) {
@@ -483,6 +488,7 @@ bool CrashDone(const MinidumpDescriptor& minidump,
info.process_start_time = g_process_start_time;
info.oom_size = base::g_oom_size;
info.pid = 0;
+ info.crash_keys = g_crash_keys;
HandleCrashDump(info);
#if defined(OS_ANDROID)
return FinalizeCrashDoneAndroid();
@@ -663,15 +669,9 @@ bool NonBrowserCrashHandler(const void* crash_context,
static const unsigned kControlMsgSpaceSize = CMSG_SPACE(kControlMsgSize);
static const unsigned kControlMsgLenSize = CMSG_LEN(kControlMsgSize);
-#if !defined(ADDRESS_SANITIZER)
- const size_t kIovSize = 8;
-#else
- // Additional field to pass the AddressSanitizer log to the crash handler.
- const size_t kIovSize = 9;
-#endif
struct kernel_msghdr msg;
my_memset(&msg, 0, sizeof(struct kernel_msghdr));
- struct kernel_iovec iov[kIovSize];
+ struct kernel_iovec iov[kCrashIovSize];
iov[0].iov_base = const_cast<void*>(crash_context);
iov[0].iov_len = crash_context_size;
iov[1].iov_base = guid;
@@ -688,13 +688,18 @@ bool NonBrowserCrashHandler(const void* crash_context,
iov[6].iov_len = sizeof(g_process_start_time);
iov[7].iov_base = &base::g_oom_size;
iov[7].iov_len = sizeof(base::g_oom_size);
+ google_breakpad::SerializedNonAllocatingMap* serialized_map;
+ iov[8].iov_len = g_crash_keys->Serialize(
+ const_cast<const google_breakpad::SerializedNonAllocatingMap**>(
+ &serialized_map));
+ iov[8].iov_base = serialized_map;
#if defined(ADDRESS_SANITIZER)
- iov[8].iov_base = const_cast<char*>(g_asan_report_str);
- iov[8].iov_len = kMaxAsanReportSize + 1;
+ iov[9].iov_base = const_cast<char*>(g_asan_report_str);
+ iov[9].iov_len = kMaxAsanReportSize + 1;
#endif
msg.msg_iov = iov;
- msg.msg_iovlen = kIovSize;
+ msg.msg_iovlen = kCrashIovSize;
char cmsg[kControlMsgSpaceSize];
my_memset(cmsg, 0, kControlMsgSpaceSize);
msg.msg_control = cmsg;
@@ -740,6 +745,15 @@ void EnableNonBrowserCrashDumping() {
}
#endif // defined(OS_ANDROID)
+void SetCrashKeyValue(const base::StringPiece& key,
+ const base::StringPiece& value) {
+ g_crash_keys->SetKeyValue(key.data(), value.data());
+}
+
+void ClearCrashKey(const base::StringPiece& key) {
+ g_crash_keys->RemoveKey(key.data());
+}
+
} // namespace
void LoadDataFromFD(google_breakpad::PageAllocator& allocator,
@@ -1211,6 +1225,16 @@ void HandleCrashDump(const BreakpadInfo& info) {
writer.Flush();
}
+ if (info.crash_keys) {
+ CrashKeyStorage::Iterator crash_key_iterator(*info.crash_keys);
Lei Zhang 2013/05/28 22:02:24 Can you update the comment around line 989?
Robert Sesek 2013/05/29 18:39:45 Done.
+ const CrashKeyStorage::Entry* entry;
+ while ((entry = crash_key_iterator.Next())) {
+ writer.AddPairString(entry->key, entry->value);
+ writer.AddBoundary();
+ writer.Flush();
+ }
+ }
+
writer.AddFileContents(g_dump_msg, dump_data, dump_size);
#if defined(ADDRESS_SANITIZER)
// Append a multipart boundary and the contents of the AddressSanitizer log.
@@ -1473,6 +1497,11 @@ void InitCrashReporter() {
// Register the callback for AddressSanitizer error reporting.
__asan_set_error_report_callback(AsanLinuxBreakpadCallback);
#endif
+
+ g_crash_keys = new CrashKeyStorage;
+ crash_keys::RegisterChromeCrashKeys();
+ base::debug::SetCrashKeyReportingFunctions(
+ &SetCrashKeyValue, &ClearCrashKey);
}
#if defined(OS_ANDROID)

Powered by Google App Engine
This is Rietveld 408576698