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

Unified Diff: chrome/browser/browser_main_posix.cc

Issue 6943001: Add shutdown trace functions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed include order Created 9 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
« base/compiler_specific.h ('K') | « base/compiler_specific.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_main_posix.cc
diff --git a/chrome/browser/browser_main_posix.cc b/chrome/browser/browser_main_posix.cc
index 9729f64522e50b5ea8e0c216e5a569504719d140..49fcaf28e01629192624288775a7f7305e7260b6 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
« base/compiler_specific.h ('K') | « base/compiler_specific.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698