summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorlipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-28 02:57:24 +0000
committerlipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-28 02:57:24 +0000
commit0d64e0b36f68f8e837e1e74f362da6fa3f487995 (patch)
tree131f0f6f83178d663f3316333c7411cccbcdc754 /chrome
parentbe8b30dcb93ba02315d6ca619876cab531f75cd8 (diff)
downloadchromium_src-0d64e0b36f68f8e837e1e74f362da6fa3f487995.zip
chromium_src-0d64e0b36f68f8e837e1e74f362da6fa3f487995.tar.gz
chromium_src-0d64e0b36f68f8e837e1e74f362da6fa3f487995.tar.bz2
This patch achieves it without crashing the process. We create a new exception handler to handle non crash cases. This currently works only on windows.
BUG=100444 TEST=Trybots, manual testing. Review URL: http://codereview.chromium.org/8879061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115862 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/breakpad_win.cc35
-rw-r--r--chrome/browser/sync/syncable/DEPS2
-rw-r--r--chrome/browser/sync/syncable/syncable.cc14
3 files changed, 51 insertions, 0 deletions
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc
index 57f9d6f..56f5e9b9 100644
--- a/chrome/app/breakpad_win.cc
+++ b/chrome/app/breakpad_win.cc
@@ -61,6 +61,7 @@ const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices";
const wchar_t kSystemPrincipalSid[] =L"S-1-5-18";
google_breakpad::ExceptionHandler* g_breakpad = NULL;
+google_breakpad::ExceptionHandler* g_dumphandler_no_crash = NULL;
// A pointer to the custom entries that we send in the event of a crash. We need
// this pointer, along with the offsets into it below, so that we can keep the
@@ -84,6 +85,13 @@ extern "C" void __declspec(dllexport) __cdecl DumpProcess() {
g_breakpad->WriteMinidump();
}
+// Used for dumping a process state when there is no crash.
+extern "C" void __declspec(dllexport) __cdecl DumpProcessWithoutCrash() {
+ if (g_dumphandler_no_crash) {
+ g_dumphandler_no_crash->WriteMinidump();
+ }
+}
+
// Reduces the size of the string |str| to a max of 64 chars. Required because
// breakpad's CustomInfoEntry raises an invalid_parameter error if the string
// we want to set is longer.
@@ -325,6 +333,14 @@ struct CrashReporterInfo {
std::wstring process_type;
};
+// This callback is used when we want to get a dump without crashing the
+// process.
+bool DumpDoneCallbackWhenNoCrash(const wchar_t*, const wchar_t*, void*,
+ EXCEPTION_POINTERS* ex_info,
+ MDRawAssertionInfo*, bool) {
+ return true;
+}
+
// This callback is executed when the browser process has crashed, after
// the crash dump has been created. We need to minimize the amount of work
// done here since we have potentially corrupted process. Our job is to
@@ -362,6 +378,14 @@ bool DumpDoneCallback(const wchar_t*, const wchar_t*, void*,
// flag to indicate that we are already handling an exception.
volatile LONG handling_exception = 0;
+// This callback is used when there is no crash. Note: Unlike the
+// |FilterCallback| below this does not do dupe detection. It is upto the caller
+// to implement it.
+bool FilterCallbackWhenNoCrash(
+ void*, EXCEPTION_POINTERS*, MDRawAssertionInfo*) {
+ return true;
+}
+
// This callback is executed when the Chrome process has crashed and *before*
// the crash dump is created. To prevent duplicate crash reports we
// make every thread calling this method, except the very first one,
@@ -692,6 +716,17 @@ static DWORD __stdcall InitCrashReporterThread(void* param) {
google_breakpad::ExceptionHandler::HANDLER_ALL,
dump_type, pipe_name.c_str(), info->custom_info);
+ // Now initialize the non crash dump handler.
+ g_dumphandler_no_crash = new google_breakpad::ExceptionHandler(temp_dir,
+ &FilterCallbackWhenNoCrash,
+ &DumpDoneCallbackWhenNoCrash,
+ NULL,
+ // Set the handler to none so this handler would not be added to
+ // |handler_stack_| in |ExceptionHandler| which is a list of exception
+ // handlers.
+ google_breakpad::ExceptionHandler::HANDLER_NONE,
+ dump_type, pipe_name.c_str(), info->custom_info);
+
if (!g_breakpad->IsOutOfProcess()) {
// The out-of-process handler is unavailable.
scoped_ptr<base::Environment> env(base::Environment::Create());
diff --git a/chrome/browser/sync/syncable/DEPS b/chrome/browser/sync/syncable/DEPS
index fdf36f2..9946874 100644
--- a/chrome/browser/sync/syncable/DEPS
+++ b/chrome/browser/sync/syncable/DEPS
@@ -20,5 +20,7 @@ include_rules = [
"-chrome/browser/sync/internal_api",
"+chrome/browser/sync/internal_api/includes",
+
+ "+chrome/common/chrome_constants.h",
]
diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc
index 41e7417..ab12057 100644
--- a/chrome/browser/sync/syncable/syncable.cc
+++ b/chrome/browser/sync/syncable/syncable.cc
@@ -13,6 +13,7 @@
#include <set>
#include <string>
+#include "base/basictypes.h"
#include "base/debug/trace_event.h"
#include "base/compiler_specific.h"
#include "base/debug/trace_event.h"
@@ -40,6 +41,7 @@
#include "chrome/browser/sync/syncable/syncable_enum_conversions.h"
#include "chrome/browser/sync/syncable/transaction_observer.h"
#include "chrome/browser/sync/util/logging.h"
+#include "chrome/common/chrome_constants.h"
#include "net/base/escape.h"
namespace {
@@ -1395,6 +1397,18 @@ void BaseTransaction::OnUnrecoverableError(
// Note: We dont call the Directory's OnUnrecoverableError method right
// away. Instead we wait to unwind the stack and in the destructor of the
// transaction we would call the OnUnrecoverableError method.
+
+ // TODO(lipalani): Add this for other platforms as well.
+#if defined(OS_WIN)
+ // Get the breakpad pointer from chrome.exe
+ typedef void (__cdecl *DumpProcessFunction)();
+ DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
+ ::GetProcAddress(::GetModuleHandle(
+ chrome::kBrowserProcessExecutableName),
+ "DumpProcessWithoutCrash"));
+ if (DumpProcess)
+ DumpProcess();
+#endif // OS_WIN
}
bool BaseTransaction::unrecoverable_error_set() const {