summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-10 20:59:48 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-10 20:59:48 +0000
commit200f1ddcfc83ccabcf923530ee4ae65dab97de3c (patch)
treeb5a2761dad08a785f21dea9f26cbec94c8890c47
parentb3609133aeaafa1b57d8a7ca9e90c5f91e982211 (diff)
downloadchromium_src-200f1ddcfc83ccabcf923530ee4ae65dab97de3c.zip
chromium_src-200f1ddcfc83ccabcf923530ee4ae65dab97de3c.tar.gz
chromium_src-200f1ddcfc83ccabcf923530ee4ae65dab97de3c.tar.bz2
Merge 84662 - Add shutdown trace functions
BUG=chromium-os:14737 TEST=None Review URL: http://codereview.chromium.org/6943001 TBR=davemoore@chromium.org Review URL: http://codereview.chromium.org/7001009 git-svn-id: svn://svn.chromium.org/chrome/branches/742/src@84844 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/compiler_specific.h4
-rw-r--r--chrome/browser/browser_main_posix.cc27
2 files changed, 29 insertions, 2 deletions
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index 3060306..43ff21c 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -74,8 +74,10 @@
// int x ALLOW_UNUSED = ...;
#if defined(COMPILER_GCC)
#define ALLOW_UNUSED __attribute__((unused))
+#define NOINLINE __attribute__((noinline))
#else
#define ALLOW_UNUSED
+#define NOINLINE
#endif
// Annotate a virtual method indicating it must be overriding a virtual
diff --git a/chrome/browser/browser_main_posix.cc b/chrome/browser/browser_main_posix.cc
index 9729f64..49fcaf2 100644
--- a/chrome/browser/browser_main_posix.cc
+++ b/chrome/browser/browser_main_posix.cc
@@ -5,8 +5,10 @@
#include "chrome/browser/browser_main_posix.h"
#include <errno.h>
+#include <limits.h>
#include <signal.h>
#include <sys/resource.h>
+#include <unistd.h>
#include <string>
@@ -14,7 +16,6 @@
#include "base/eintr_wrapper.h"
#include "base/logging.h"
#include "base/string_number_conversions.h"
-#include "base/threading/platform_thread.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_switches.h"
@@ -89,6 +90,27 @@ ShutdownDetector::ShutdownDetector(int shutdown_fd)
CHECK_NE(shutdown_fd_, -1);
}
+
+// These functions are used to help us diagnose crash dumps that happen
+// during the shutdown process.
+NOINLINE void ShutdownFDReadError() {
+ // Ensure function isn't optimized away.
+ asm("");
+ sleep(UINT_MAX);
+}
+
+NOINLINE void ShutdownFDClosedError() {
+ // Ensure function isn't optimized away.
+ asm("");
+ sleep(UINT_MAX);
+}
+
+NOINLINE void CloseAllBrowsersAndExitPosted() {
+ // Ensure function isn't optimized away.
+ asm("");
+ sleep(UINT_MAX);
+}
+
void ShutdownDetector::ThreadMain() {
base::PlatformThread::SetName("CrShutdownDetector");
@@ -102,9 +124,11 @@ void ShutdownDetector::ThreadMain() {
sizeof(signal) - bytes_read));
if (ret < 0) {
NOTREACHED() << "Unexpected error: " << strerror(errno);
+ ShutdownFDReadError();
break;
} else if (ret == 0) {
NOTREACHED() << "Unexpected closure of shutdown pipe.";
+ ShutdownFDClosedError();
break;
}
bytes_read += ret;
@@ -134,6 +158,7 @@ void ShutdownDetector::ThreadMain() {
RAW_LOG(WARNING, "Still here, exiting really ungracefully.");
_exit(signal | (1 << 7));
}
+ CloseAllBrowsersAndExitPosted();
}
// Sets the file descriptor soft limit to |max_descriptors| or the OS hard