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

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

Issue 23890030: Rollback trunk to 3.21.15. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
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 | « src/platform-openbsd.cc ('k') | src/platform-solaris.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 21 matching lines...) Expand all
32 #include <cxxabi.h> 32 #include <cxxabi.h>
33 #endif 33 #endif
34 #include <stdio.h> 34 #include <stdio.h>
35 35
36 #include "platform.h" 36 #include "platform.h"
37 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 template<int (*backtrace)(void**, int), 43 template<int (*backtrace)(void**, int),
43 char** (*backtrace_symbols)(void* const*, int)> 44 char** (*backtrace_symbols)(void* const*, int)>
44 struct POSIXBacktraceHelper { 45 struct POSIXBacktraceHelper {
45 static void DumpBacktrace() { 46 static void DumpBacktrace() {
46 void* trace[100]; 47 void* trace[100];
47 int size = backtrace(trace, ARRAY_SIZE(trace)); 48 int size = backtrace(trace, ARRAY_SIZE(trace));
48 char** symbols = backtrace_symbols(trace, size); 49 char** symbols = backtrace_symbols(trace, size);
49 fprintf(stderr, "\n==== C stack trace ===============================\n\n"); 50 fprintf(stderr, "\n==== C stack trace ===============================\n\n");
50 if (size == 0) { 51 if (size == 0) {
51 fprintf(stderr, "(empty)\n"); 52 fprintf(stderr, "(empty)\n");
(...skipping 13 matching lines...) Expand all
65 fprintf(stderr, "%s\n", demangled != NULL ? demangled : mangled); 66 fprintf(stderr, "%s\n", demangled != NULL ? demangled : mangled);
66 free(demangled); 67 free(demangled);
67 } else { 68 } else {
68 fprintf(stderr, "??\n"); 69 fprintf(stderr, "??\n");
69 } 70 }
70 } 71 }
71 } 72 }
72 fflush(stderr); 73 fflush(stderr);
73 free(symbols); 74 free(symbols);
74 } 75 }
76
77 static int StackWalk(Vector<OS::StackFrame> frames) {
78 int frames_size = frames.length();
79 ScopedVector<void*> addresses(frames_size);
80
81 int frames_count = backtrace(addresses.start(), frames_size);
82
83 char** symbols = backtrace_symbols(addresses.start(), frames_count);
84 if (symbols == NULL) {
85 return OS::kStackWalkError;
86 }
87
88 for (int i = 0; i < frames_count; i++) {
89 frames[i].address = addresses[i];
90 // Format a text representation of the frame based on the information
91 // available.
92 OS::SNPrintF(MutableCStrVector(frames[i].text, OS::kStackWalkMaxTextLen),
93 "%s", symbols[i]);
94 // Make sure line termination is in place.
95 frames[i].text[OS::kStackWalkMaxTextLen - 1] = '\0';
96 }
97
98 free(symbols);
99
100 return frames_count;
101 }
75 }; 102 };
76 103
77 } } // namespace v8::internal 104 } } // namespace v8::internal
78 105
79 #endif // V8_PLATFORM_POSIX_H_ 106 #endif // V8_PLATFORM_POSIX_H_
OLDNEW
« no previous file with comments | « src/platform-openbsd.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698