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

Unified Diff: chrome/browser/hang_monitor/hang_crash_dump_win.cc

Issue 10253016: Generate crash dumps when a hung PPAPI plugin is force terminated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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/browser/hang_monitor/hang_crash_dump_win.cc
diff --git a/chrome/browser/hang_monitor/hang_crash_dump_win.cc b/chrome/browser/hang_monitor/hang_crash_dump_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..453c9ff87ad5f4b116660e07b2b119cc73e6db51
--- /dev/null
+++ b/chrome/browser/hang_monitor/hang_crash_dump_win.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 2012 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.
+
+#include "chrome/browser/hang_monitor/hang_crash_dump_win.h"
+
+#include "chrome/common/chrome_constants.h"
+#include "content/public/common/result_codes.h"
+
+namespace {
+
+// This function will be called via an injected thread in the hung plugin
+// process. calling DumpProcessWithoutCrash causes breakpad to capture a dump of
+// the process.
+DWORD WINAPI HungPluginDumpAndExit(void*) {
+ typedef void (__cdecl *DumpProcessFunction)();
+ DumpProcessFunction request_dump = reinterpret_cast<DumpProcessFunction>(
+ GetProcAddress(GetModuleHandle(chrome::kBrowserProcessExecutableName),
+ "DumpProcessWithoutCrash"));
+ if (request_dump)
+ request_dump();
+ return 0;
+}
+
+// How long do we wait for the terminated thread or process to die (in ms)
+static const int kTerminateTimeoutMS = 2000;
+
+// How long do we wait for the crash to be generated (in ms).
+static const int kGenerateDumpTimeoutMS = 10000;
+
+} // namespace
+
+void CrashDumpAndTerminateHungChildProcess(HANDLE hprocess) {
+ // Before terminating the process we try collecting a dump. Which
+ // a transient thread in the child process will do for us.
+ HANDLE remote_thread = CreateRemoteThread(hprocess, NULL, 0,
+ &HungPluginDumpAndExit, 0, 0, NULL);
+ if (remote_thread) {
+ WaitForSingleObject(remote_thread, kGenerateDumpTimeoutMS);
+ CloseHandle(remote_thread);
+ }
+
+ TerminateProcess(hprocess, content::RESULT_CODE_HUNG);
+ WaitForSingleObject(hprocess, kTerminateTimeoutMS);
+}
« no previous file with comments | « chrome/browser/hang_monitor/hang_crash_dump_win.h ('k') | chrome/browser/hang_monitor/hung_window_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698