OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
(...skipping 10 matching lines...) Expand all Loading... |
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 #ifndef V8_PLATFORM_POSIX_H_ | 28 #ifndef V8_PLATFORM_POSIX_H_ |
29 #define V8_PLATFORM_POSIX_H_ | 29 #define V8_PLATFORM_POSIX_H_ |
30 | 30 |
31 #if !defined(ANDROID) | 31 #include "platform.h" |
| 32 |
| 33 #if !V8_OS_ANDROID |
32 #include <cxxabi.h> | 34 #include <cxxabi.h> |
33 #endif | 35 #endif |
34 #include <stdio.h> | 36 #include <stdio.h> |
35 | 37 |
36 #include "platform.h" | |
37 | |
38 namespace v8 { | 38 namespace v8 { |
39 namespace internal { | 39 namespace internal { |
40 | 40 |
41 // Used by platform implementation files during OS::DumpBacktrace() | 41 // Used by platform implementation files during OS::DumpBacktrace() |
42 // and OS::StackWalk(). | 42 // and OS::StackWalk(). |
43 template<int (*backtrace)(void**, int), | 43 template<int (*backtrace)(void**, int), |
44 char** (*backtrace_symbols)(void* const*, int)> | 44 char** (*backtrace_symbols)(void* const*, int)> |
45 struct POSIXBacktraceHelper { | 45 struct POSIXBacktraceHelper { |
46 static void DumpBacktrace() { | 46 static void DumpBacktrace() { |
47 void* trace[100]; | 47 void* trace[100]; |
48 int size = backtrace(trace, ARRAY_SIZE(trace)); | 48 int size = backtrace(trace, ARRAY_SIZE(trace)); |
49 char** symbols = backtrace_symbols(trace, size); | 49 char** symbols = backtrace_symbols(trace, size); |
50 fprintf(stderr, "\n==== C stack trace ===============================\n\n"); | 50 fprintf(stderr, "\n==== C stack trace ===============================\n\n"); |
51 if (size == 0) { | 51 if (size == 0) { |
52 fprintf(stderr, "(empty)\n"); | 52 fprintf(stderr, "(empty)\n"); |
53 } else if (symbols == NULL) { | 53 } else if (symbols == NULL) { |
54 fprintf(stderr, "(no symbols)\n"); | 54 fprintf(stderr, "(no symbols)\n"); |
55 } else { | 55 } else { |
56 for (int i = 1; i < size; ++i) { | 56 for (int i = 1; i < size; ++i) { |
57 fprintf(stderr, "%2d: ", i); | 57 fprintf(stderr, "%2d: ", i); |
58 char mangled[201]; | 58 char mangled[201]; |
59 if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) {// NOLINT | 59 if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) {// NOLINT |
60 char* demangled = NULL; | 60 char* demangled = NULL; |
61 #if !defined(ANDROID) | 61 #if !V8_OS_ANDROID |
62 int status; | 62 int status; |
63 size_t length; | 63 size_t length; |
64 demangled = abi::__cxa_demangle(mangled, NULL, &length, &status); | 64 demangled = abi::__cxa_demangle(mangled, NULL, &length, &status); |
65 #endif | 65 #endif |
66 fprintf(stderr, "%s\n", demangled != NULL ? demangled : mangled); | 66 fprintf(stderr, "%s\n", demangled != NULL ? demangled : mangled); |
67 free(demangled); | 67 free(demangled); |
68 } else { | 68 } else { |
69 fprintf(stderr, "??\n"); | 69 fprintf(stderr, "??\n"); |
70 } | 70 } |
71 } | 71 } |
(...skipping 25 matching lines...) Expand all Loading... |
97 | 97 |
98 free(symbols); | 98 free(symbols); |
99 | 99 |
100 return frames_count; | 100 return frames_count; |
101 } | 101 } |
102 }; | 102 }; |
103 | 103 |
104 } } // namespace v8::internal | 104 } } // namespace v8::internal |
105 | 105 |
106 #endif // V8_PLATFORM_POSIX_H_ | 106 #endif // V8_PLATFORM_POSIX_H_ |
OLD | NEW |