summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-03 03:33:13 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-03 03:33:13 +0000
commitc7b1d2fde3236b8438a326037af08e933eb68905 (patch)
treec9fe615d46a7f7d88397ec26d5af051f4b6ee057
parent09a31602ef7b10148b28b894bdbf7cc359443084 (diff)
downloadchromium_src-c7b1d2fde3236b8438a326037af08e933eb68905.zip
chromium_src-c7b1d2fde3236b8438a326037af08e933eb68905.tar.gz
chromium_src-c7b1d2fde3236b8438a326037af08e933eb68905.tar.bz2
Linux: Fix the uptime in crash reports for renderers and plugins.
BUG=65202 TEST=Start chrome, run it for a few minutes, then open a tab and visit about:crash. Verify the crash report says the renderer has a very low uptime. Review URL: http://codereview.chromium.org/5541003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68146 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/breakpad_linux.cc22
-rw-r--r--chrome/app/breakpad_linux.h5
-rw-r--r--chrome/browser/crash_handler_host_linux.cc12
3 files changed, 25 insertions, 14 deletions
diff --git a/chrome/app/breakpad_linux.cc b/chrome/app/breakpad_linux.cc
index 60c3785..1f55a5d 100644
--- a/chrome/app/breakpad_linux.cc
+++ b/chrome/app/breakpad_linux.cc
@@ -49,7 +49,7 @@ static const char kUploadURL[] =
"https://clients2.google.com/cr/report";
static bool is_crash_reporter_enabled = false;
-static uint64_t uptime = 0;
+static uint64_t process_start_time = 0;
// Writes the value |v| as 16 hex characters to the memory pointed at by
// |output|.
@@ -319,12 +319,12 @@ pid_t HandleCrashDump(const BreakpadInfo& info) {
IGNORE_RET(sys_writev(fd, iov, 29));
- if (uptime >= 0) {
+ if (info.process_start_time > 0) {
struct kernel_timeval tv;
if (!sys_gettimeofday(&tv, NULL)) {
uint64_t time = kernel_timeval_to_ms(&tv);
- if (time > uptime) {
- time -= uptime;
+ if (time > info.process_start_time) {
+ time -= info.process_start_time;
char time_str[21];
const unsigned time_len = my_uint64_len(time);
my_uint64tos(time_str, time, time_len);
@@ -610,6 +610,7 @@ static bool CrashDone(const char* dump_path,
info.distro = base::g_linux_distro;
info.distro_length = my_strlen(base::g_linux_distro);
info.upload = upload;
+ info.process_start_time = process_start_time;
HandleCrashDump(info);
return true;
@@ -678,9 +679,10 @@ NonBrowserCrashHandler(const void* crash_context, size_t crash_context_size,
// The length of the control message:
static const unsigned kControlMsgSize = CMSG_SPACE(2*sizeof(int));
+ const size_t kIovSize = 7;
struct kernel_msghdr msg;
my_memset(&msg, 0, sizeof(struct kernel_msghdr));
- struct kernel_iovec iov[6];
+ struct kernel_iovec iov[kIovSize];
iov[0].iov_base = const_cast<void*>(crash_context);
iov[0].iov_len = crash_context_size;
iov[1].iov_base = guid;
@@ -693,9 +695,11 @@ NonBrowserCrashHandler(const void* crash_context, size_t crash_context_size,
iov[4].iov_len = sizeof(b_addr);
iov[5].iov_base = &fds[0];
iov[5].iov_len = sizeof(fds[0]);
+ iov[6].iov_base = &process_start_time;
+ iov[6].iov_len = sizeof(process_start_time);
msg.msg_iov = iov;
- msg.msg_iovlen = 6;
+ msg.msg_iovlen = kIovSize;
char cmsg[kControlMsgSize];
my_memset(cmsg, 0, kControlMsgSize);
msg.msg_control = cmsg;
@@ -764,12 +768,12 @@ void InitCrashReporter() {
EnableNonBrowserCrashDumping();
}
- // Set the base process uptime value.
+ // Set the base process start time value.
struct timeval tv;
if (!gettimeofday(&tv, NULL))
- uptime = timeval_to_ms(&tv);
+ process_start_time = timeval_to_ms(&tv);
else
- uptime = 0;
+ process_start_time = 0;
}
bool IsCrashReporterEnabled() {
diff --git a/chrome/app/breakpad_linux.h b/chrome/app/breakpad_linux.h
index 05ef6108..435e3b6 100644
--- a/chrome/app/breakpad_linux.h
+++ b/chrome/app/breakpad_linux.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,7 +6,7 @@
#define CHROME_APP_BREAKPAD_LINUX_H_
#pragma once
-#include <stdlib.h>
+#include "base/basictypes.h"
extern void InitCrashReporter();
bool IsCrashReporterEnabled();
@@ -26,6 +26,7 @@ struct BreakpadInfo {
const char* distro;
unsigned distro_length;
bool upload;
+ uint64_t process_start_time;
};
extern int HandleCrashDump(const BreakpadInfo& info);
diff --git a/chrome/browser/crash_handler_host_linux.cc b/chrome/browser/crash_handler_host_linux.cc
index a941cdd..5474a47 100644
--- a/chrome/browser/crash_handler_host_linux.cc
+++ b/chrome/browser/crash_handler_host_linux.cc
@@ -118,20 +118,23 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) {
static const unsigned kCrashContextSize =
sizeof(ExceptionHandler::CrashContext);
+ const size_t kIovSize = 7;
struct msghdr msg = {0};
- struct iovec iov[6];
+ struct iovec iov[kIovSize];
char crash_context[kCrashContextSize];
char* guid = new char[kGuidSize + 1];
char* crash_url = new char[kMaxActiveURLSize + 1];
char* distro = new char[kDistroSize + 1];
char* tid_buf_addr = NULL;
int tid_fd = -1;
+ uint64_t uptime;
char control[kControlMsgSize];
const ssize_t expected_msg_size = sizeof(crash_context) +
kGuidSize + 1 +
kMaxActiveURLSize + 1 +
kDistroSize + 1 +
- sizeof(tid_buf_addr) + sizeof(tid_fd);
+ sizeof(tid_buf_addr) + sizeof(tid_fd) +
+ sizeof(uptime);
iov[0].iov_base = crash_context;
iov[0].iov_len = sizeof(crash_context);
@@ -145,8 +148,10 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) {
iov[4].iov_len = sizeof(tid_buf_addr);
iov[5].iov_base = &tid_fd;
iov[5].iov_len = sizeof(tid_fd);
+ iov[6].iov_base = &uptime;
+ iov[6].iov_len = sizeof(uptime);
msg.msg_iov = iov;
- msg.msg_iovlen = 6;
+ msg.msg_iovlen = kIovSize;
msg.msg_control = control;
msg.msg_controllen = kControlMsgSize;
@@ -328,6 +333,7 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) {
info->distro = distro;
info->upload = upload;
+ info->process_start_time = uptime;
uploader_thread_->message_loop()->PostTask(
FROM_HERE,