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

Side by Side Diff: src/checks.cc

Issue 23497009: Move DumpBacktrace() to checks.cc and cleanup both the code and the necessary platform checks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/platform.h » ('j') | src/platform-macos.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdarg.h> 28 #include "checks.h"
29 29
30 #if V8_LIBC_GLIBC || V8_OS_BSD
Michael Achenbach 2013/09/23 11:12:50 Does that include !defined(__UCLIBC__)?
Benedikt Meurer 2013/09/23 11:26:40 Jep, our V8_LIBC_* are strict. I.e. V8_LIBC_GLIBC
31 # include <cxxabi.h>
32 # include <execinfo.h>
33 #endif // V8_LIBC_GLIBC || V8_OS_BSD
34 #include <stdio.h>
35
36 #include "platform.h"
30 #include "v8.h" 37 #include "v8.h"
31 38
32 #include "platform.h" 39
40 // Attempts to dump a backtrace (if supported).
41 static V8_INLINE void DumpBacktrace() {
42 #if V8_LIBC_GLIBC || V8_OS_BSD
43 void* trace[100];
44 int size = backtrace(trace, ARRAY_SIZE(trace));
45 char** symbols = backtrace_symbols(trace, size);
46 i::OS::PrintError("\n==== C stack trace ===============================\n\n");
47 if (size == 0) {
48 i::OS::PrintError("(empty)\n");
49 } else if (symbols == NULL) {
50 i::OS::PrintError("(no symbols)\n");
51 } else {
52 for (int i = 1; i < size; ++i) {
53 i::OS::PrintError("%2d: ", i);
54 char mangled[201];
55 if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) { // NOLINT
56 int status;
57 size_t length;
58 char* demangled = abi::__cxa_demangle(mangled, NULL, &length, &status);
59 i::OS::PrintError("%s\n", demangled != NULL ? demangled : mangled);
60 free(demangled);
61 } else {
62 i::OS::PrintError("??\n");
63 }
64 }
65 }
66 free(symbols);
67 #endif // V8_LIBC_GLIBC || V8_OS_BSD
68 }
69
33 70
34 // Contains protection against recursive calls (faults while handling faults). 71 // Contains protection against recursive calls (faults while handling faults).
35 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { 72 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) {
36 i::AllowHandleDereference allow_deref; 73 i::AllowHandleDereference allow_deref;
37 i::AllowDeferredHandleDereference allow_deferred_deref; 74 i::AllowDeferredHandleDereference allow_deferred_deref;
38 fflush(stdout); 75 fflush(stdout);
39 fflush(stderr); 76 fflush(stderr);
40 i::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line); 77 i::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line);
41 va_list arguments; 78 va_list arguments;
42 va_start(arguments, format); 79 va_start(arguments, format);
43 i::OS::VPrintError(format, arguments); 80 i::OS::VPrintError(format, arguments);
44 va_end(arguments); 81 va_end(arguments);
45 i::OS::PrintError("\n#\n"); 82 i::OS::PrintError("\n#\n");
46 i::OS::DumpBacktrace(); 83 DumpBacktrace();
84 fflush(stderr);
Michael Achenbach 2013/09/23 11:12:50 Why can that not stay within DumpBacktrace()?
Benedikt Meurer 2013/09/23 11:26:40 Because we should flush stderr on either case.
47 i::OS::Abort(); 85 i::OS::Abort();
48 } 86 }
49 87
50 88
51 void CheckEqualsHelper(const char* file, 89 void CheckEqualsHelper(const char* file,
52 int line, 90 int line,
53 const char* expected_source, 91 const char* expected_source,
54 v8::Handle<v8::Value> expected, 92 v8::Handle<v8::Value> expected,
55 const char* value_source, 93 const char* value_source,
56 v8::Handle<v8::Value> value) { 94 v8::Handle<v8::Value> value) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 128
91 129
92 namespace v8 { namespace internal { 130 namespace v8 { namespace internal {
93 131
94 bool EnableSlowAsserts() { return FLAG_enable_slow_asserts; } 132 bool EnableSlowAsserts() { return FLAG_enable_slow_asserts; }
95 133
96 intptr_t HeapObjectTagMask() { return kHeapObjectTagMask; } 134 intptr_t HeapObjectTagMask() { return kHeapObjectTagMask; }
97 135
98 } } // namespace v8::internal 136 } } // namespace v8::internal
99 137
OLDNEW
« no previous file with comments | « no previous file | src/platform.h » ('j') | src/platform-macos.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698