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

Side by Side Diff: src/platform-posix.h

Issue 148153010: Synchronize with r15701. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | « src/platform-openbsd.cc ('k') | src/platform-posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)
32 #include <cxxabi.h>
33 #endif
34 #include <stdio.h>
35
36 #include "platform.h"
37
31 namespace v8 { 38 namespace v8 {
32 namespace internal { 39 namespace internal {
33 40
34 // Used by platform implementation files during OS::PostSetUp(). 41 // Used by platform implementation files during OS::PostSetUp().
35 void POSIXPostSetUp(); 42 void POSIXPostSetUp();
36 43
44 // Used by platform implementation files during OS::DumpBacktrace()
45 // and OS::StackWalk().
46 template<int (*backtrace)(void**, int),
47 char** (*backtrace_symbols)(void* const*, int)>
48 struct POSIXBacktraceHelper {
49 static void DumpBacktrace() {
50 void* trace[100];
51 int size = backtrace(trace, ARRAY_SIZE(trace));
52 char** symbols = backtrace_symbols(trace, size);
53 fprintf(stderr, "\n==== C stack trace ===============================\n\n");
54 if (size == 0) {
55 fprintf(stderr, "(empty)\n");
56 } else if (symbols == NULL) {
57 fprintf(stderr, "(no symbols)\n");
58 } else {
59 for (int i = 1; i < size; ++i) {
60 fprintf(stderr, "%2d: ", i);
61 char mangled[201];
62 if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) {// NOLINT
63 char* demangled = NULL;
64 #if !defined(ANDROID)
65 int status;
66 size_t length;
67 demangled = abi::__cxa_demangle(mangled, NULL, &length, &status);
68 #endif
69 fprintf(stderr, "%s\n", demangled != NULL ? demangled : mangled);
70 free(demangled);
71 } else {
72 fprintf(stderr, "??\n");
73 }
74 }
75 }
76 fflush(stderr);
77 free(symbols);
78 }
79
80 static int StackWalk(Vector<OS::StackFrame> frames) {
81 int frames_size = frames.length();
82 ScopedVector<void*> addresses(frames_size);
83
84 int frames_count = backtrace(addresses.start(), frames_size);
85
86 char** symbols = backtrace_symbols(addresses.start(), frames_count);
87 if (symbols == NULL) {
88 return OS::kStackWalkError;
89 }
90
91 for (int i = 0; i < frames_count; i++) {
92 frames[i].address = addresses[i];
93 // Format a text representation of the frame based on the information
94 // available.
95 OS::SNPrintF(MutableCStrVector(frames[i].text, OS::kStackWalkMaxTextLen),
96 "%s", symbols[i]);
97 // Make sure line termination is in place.
98 frames[i].text[OS::kStackWalkMaxTextLen - 1] = '\0';
99 }
100
101 free(symbols);
102
103 return frames_count;
104 }
105 };
106
37 } } // namespace v8::internal 107 } } // namespace v8::internal
38 108
39 #endif // V8_PLATFORM_POSIX_H_ 109 #endif // V8_PLATFORM_POSIX_H_
OLDNEW
« no previous file with comments | « src/platform-openbsd.cc ('k') | src/platform-posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698