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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/breakpad/linux/breakpad_googletest_includes.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009, Google Inc. 1 // Copyright (c) 2009, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer 11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the 12 // in the documentation and/or other materials provided with the
13 // distribution. 13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its 14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from 15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission. 16 // this software without specific prior written permission.
17 // 17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 // --- 30 // This code exists to generate minidump files for testing.
31 // Author: Paul Pluzhnikov
32 //
33 // This code logically belongs in stacktrace.cc, but
34 // it is moved into (this) separate file in order to
35 // prevent inlining of routines defined here.
36 //
37 // Inlining causes skip_count to be incorrect, and there
38 // is no portable way to prevent it.
39 //
40 // Eventually LTO (link-time optimization) and/or LLVM
41 // may inline this code anyway. Let's hope they respect
42 // ATTRIBUTE_NOINLINE.
43 31
44 #include <config.h> 32 #include <stdlib.h>
45 #include <gperftools/stacktrace.h>
46 #include "stacktrace_config.h"
47 #include "base/basictypes.h"
48 33
49 #if !defined(STACKTRACE_SKIP_CONTEXT_ROUTINES) 34 #include <unistd.h>
50 ATTRIBUTE_NOINLINE PERFTOOLS_DLL_DECL 35
51 int GetStackFramesWithContext(void** pcs, int* sizes, int max_depth, 36 #include "third_party/breakpad/src/client/linux/handler/exception_handler.h"
52 int skip_count, const void * /* uc */) { 37 #include "third_party/breakpad/src/common/linux/linux_libc_support.h"
53 return GetStackFrames(pcs, sizes, max_depth, skip_count + 1); 38 #include "third_party/lss/linux_syscall_support.h"
39
40 static bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
41 void* context, bool success) {
42 if (!success) {
43 static const char msg[] = "Failed to write minidump\n";
44 sys_write(2, msg, sizeof(msg) - 1);
45 return false;
46 }
47
48 static const char msg[] = "Wrote minidump: ";
49 sys_write(2, msg, sizeof(msg) - 1);
50 sys_write(2, descriptor.path(), strlen(descriptor.path()));
51 sys_write(2, "\n", 1);
52
53 return true;
54 } 54 }
55 55
56 ATTRIBUTE_NOINLINE PERFTOOLS_DLL_DECL 56 static void DoSomethingWhichCrashes() {
57 int GetStackTraceWithContext(void** result, int max_depth, 57 int local_var = 1;
58 int skip_count, const void * /* uc */) { 58 *reinterpret_cast<volatile char*>(NULL) = 1;
59 return GetStackTrace(result, max_depth, skip_count + 1);
60 } 59 }
61 #endif 60
61 int main() {
62 google_breakpad::MinidumpDescriptor minidump(".");
63 google_breakpad::ExceptionHandler breakpad(minidump, NULL, DumpCallback, NULL,
64 true, -1);
65 DoSomethingWhichCrashes();
66 return 0;
67 }
OLDNEW
« 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