Index: base/debug/dump_without_crashing.cc |
diff --git a/base/debug/dump_without_crashing.cc b/base/debug/dump_without_crashing.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a9cef3e33509f4dcee40bdddc66456fd3aa366f6 |
--- /dev/null |
+++ b/base/debug/dump_without_crashing.cc |
@@ -0,0 +1,46 @@ |
+// Copyright 2013 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 "base/debug/dump_without_crashing.h" |
+ |
+#include "base/logging.h" |
+ |
+namespace { |
+ |
+// Pointer to the function that's called by DumpWithoutCrashing() to dump the |
+// process's memory. |
+#if defined(OS_POSIX) |
+void (*dump_without_crashing_function_)() = NULL; |
+#elif defined(OS_WIN) |
+void (__cdecl *dump_without_crashing_function_)() = NULL; |
Mark Mentovai
2013/12/17 20:12:09
All of these #ifdefs just for __cdecl. It’d read m
|
+#endif |
+ |
+} // namespace |
+ |
+namespace base { |
+ |
+namespace debug { |
+ |
+void DumpWithoutCrashing() { |
+#if defined(OS_WIN) || defined(OS_POSIX) |
+ if (dump_without_crashing_function_) |
+ (*dump_without_crashing_function_)(); |
+#else |
+ NOTIMPLEMENTED(); |
+#endif |
+} |
+ |
+#if defined(OS_POSIX) |
+void SetDumpWithoutCrashingFunction(void (*function)()) { |
+ dump_without_crashing_function_ = function; |
+} |
+#elif defined(OS_WIN) |
+void SetDumpWithoutCrashingFunction(void (__cdecl *function)()) { |
+ dump_without_crashing_function_ = function; |
+} |
+#endif |
+ |
+} // namespace debug |
+ |
+} // namespace base |