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

Unified Diff: client/crashpad_client_win.cc

Issue 1095273003: crashpad client for windows (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: typo Created 5 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
« no previous file with comments | « client/crashpad_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/crashpad_client_win.cc
diff --git a/client/crashpad_client_win.cc b/client/crashpad_client_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7eec54fb52adad7a57d125db6f7f2a89119825ed
--- /dev/null
+++ b/client/crashpad_client_win.cc
@@ -0,0 +1,91 @@
+// Copyright 2015 The Crashpad Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "client/crashpad_client.h"
+
+#include <windows.h>
+
+#include "base/logging.h"
+
+namespace {
+// Time to wait for the handler to create a dump. This is tricky to figure out.
+const DWORD kMillisecondsUntilTerminate = 5000;
+
+// This is the exit code that the process will return to the system once the
+// crash has been handled by Crashpad. We don't want to clash with the
+// application-defined exit codes but we don't know them so we use one that is
+// unlikely to be used.
+const UINT kCrashExitCode = 0xffff7001;
+
+// These two handles to events are leaked.
+HANDLE g_signal_exception = nullptr;
+HANDLE g_wait_termination = nullptr;
+
+LONG WINAPI UnhandledExceptionHandler(EXCEPTION_POINTERS* exception_pointers) {
+ // TODO (cpu): Here write |exception_pointers| to g_crashpad_info.
+ DWORD rv = SignalObjectAndWait(g_signal_exception,
+ g_wait_termination,
+ kMillisecondsUntilTerminate,
+ FALSE);
+ if (rv != WAIT_OBJECT_0) {
+ // Something went wrong. It is likely that a dump has not been created.
+ if (rv == WAIT_TIMEOUT) {
+ LOG(WARNING) << "SignalObjectAndWait timed out";
+ } else {
+ PLOG(WARNING) << "SignalObjectAndWait error";
+ }
+ }
+ // We don't want to generate more exceptions, so we take the fast route.
+ TerminateProcess(GetCurrentProcess(), kCrashExitCode);
+ return 0L;
+}
+
+} // namespace
+
+namespace crashpad {
+
+CrashpadClient::CrashpadClient() {
+}
+
+CrashpadClient::~CrashpadClient() {
+}
+
+bool CrashpadClient::StartHandler(
+ const base::FilePath& handler,
+ const base::FilePath& database,
+ const std::string& url,
+ const std::map<std::string, std::string>& annotations,
+ const std::vector<std::string>& arguments) {
+ // TODO(cpu): Provide a reference implementation.
+ return false;
+}
+
+bool SetHandler(const std::string& ipc_port) {
+ // TODO (cpu): Contact the handler and obtain g_signal_exception and
+ // g_wait_termination.
+ return false;
+}
+
+bool CrashpadClient::UseHandler() {
+ if (!g_signal_exception)
+ return false;
+ if (!g_wait_termination)
+ return false;
+ // In theory we could store the previous handler but it is not clear what
+ // use we have for it.
+ SetUnhandledExceptionFilter(&UnhandledExceptionHandler);
+ return true;
+}
+
+} // namespace crashpad
« no previous file with comments | « client/crashpad_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698