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

Unified Diff: third_party/breakpad/linux/generate-test-dump.cc

Issue 1604923003: Import the contents of //third_party/breakpad/linux from Chromium. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 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 | « third_party/breakpad/linux/breakpad_googletest_includes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/breakpad/linux/generate-test-dump.cc
diff --git a/third_party/tcmalloc/chromium/src/stacktrace_with_context.cc b/third_party/breakpad/linux/generate-test-dump.cc
similarity index 58%
copy from third_party/tcmalloc/chromium/src/stacktrace_with_context.cc
copy to third_party/breakpad/linux/generate-test-dump.cc
index 036d984f0128d81b9c52a80ac02ec8347edf8484..4e68508a0f096ff0ae3df17618ccbc466980c875 100644
--- a/third_party/tcmalloc/chromium/src/stacktrace_with_context.cc
+++ b/third_party/breakpad/linux/generate-test-dump.cc
@@ -1,10 +1,10 @@
// Copyright (c) 2009, Google Inc.
// All rights reserved.
-//
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
-//
+//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -27,35 +27,41 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// ---
-// Author: Paul Pluzhnikov
-//
-// This code logically belongs in stacktrace.cc, but
-// it is moved into (this) separate file in order to
-// prevent inlining of routines defined here.
-//
-// Inlining causes skip_count to be incorrect, and there
-// is no portable way to prevent it.
-//
-// Eventually LTO (link-time optimization) and/or LLVM
-// may inline this code anyway. Let's hope they respect
-// ATTRIBUTE_NOINLINE.
-
-#include <config.h>
-#include <gperftools/stacktrace.h>
-#include "stacktrace_config.h"
-#include "base/basictypes.h"
-
-#if !defined(STACKTRACE_SKIP_CONTEXT_ROUTINES)
-ATTRIBUTE_NOINLINE PERFTOOLS_DLL_DECL
-int GetStackFramesWithContext(void** pcs, int* sizes, int max_depth,
- int skip_count, const void * /* uc */) {
- return GetStackFrames(pcs, sizes, max_depth, skip_count + 1);
+// This code exists to generate minidump files for testing.
+
+#include <stdlib.h>
+
+#include <unistd.h>
+
+#include "third_party/breakpad/src/client/linux/handler/exception_handler.h"
+#include "third_party/breakpad/src/common/linux/linux_libc_support.h"
+#include "third_party/lss/linux_syscall_support.h"
+
+static bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
+ void* context, bool success) {
+ if (!success) {
+ static const char msg[] = "Failed to write minidump\n";
+ sys_write(2, msg, sizeof(msg) - 1);
+ return false;
+ }
+
+ static const char msg[] = "Wrote minidump: ";
+ sys_write(2, msg, sizeof(msg) - 1);
+ sys_write(2, descriptor.path(), strlen(descriptor.path()));
+ sys_write(2, "\n", 1);
+
+ return true;
+}
+
+static void DoSomethingWhichCrashes() {
+ int local_var = 1;
+ *reinterpret_cast<volatile char*>(NULL) = 1;
}
-ATTRIBUTE_NOINLINE PERFTOOLS_DLL_DECL
-int GetStackTraceWithContext(void** result, int max_depth,
- int skip_count, const void * /* uc */) {
- return GetStackTrace(result, max_depth, skip_count + 1);
+int main() {
+ google_breakpad::MinidumpDescriptor minidump(".");
+ google_breakpad::ExceptionHandler breakpad(minidump, NULL, DumpCallback, NULL,
+ true, -1);
+ DoSomethingWhichCrashes();
+ return 0;
}
-#endif
« no previous file with comments | « third_party/breakpad/linux/breakpad_googletest_includes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698