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

Unified Diff: src/platform-macos.cc

Issue 18431004: Common implementation of OS::DumpBacktrace() and OS::StackWalk(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Templatized POSIX backtrace Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-posix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-macos.cc
diff --git a/src/platform-macos.cc b/src/platform-macos.cc
index e8c25fae93ad0cce3ec54a96a50270fc762c47f8..097691be07b01db92e0d1d4a581ced98be366521 100644
--- a/src/platform-macos.cc
+++ b/src/platform-macos.cc
@@ -53,6 +53,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <cxxabi.h>
#undef MAP_TYPE
@@ -189,7 +190,10 @@ void OS::DebugBreak() {
void OS::DumpBacktrace() {
- // Currently unsupported.
+ // If weak link to execinfo lib has failed, ie because we are on 10.4, abort.
+ if (backtrace == NULL) return;
+
+ POSIXBacktraceHelper<backtrace, backtrace_symbols>::DumpBacktrace();
}
@@ -315,34 +319,9 @@ double OS::LocalTimeOffset() {
int OS::StackWalk(Vector<StackFrame> frames) {
// If weak link to execinfo lib has failed, ie because we are on 10.4, abort.
- if (backtrace == NULL)
- return 0;
-
- int frames_size = frames.length();
- ScopedVector<void*> addresses(frames_size);
-
- int frames_count = backtrace(addresses.start(), frames_size);
-
- char** symbols = backtrace_symbols(addresses.start(), frames_count);
- if (symbols == NULL) {
- return kStackWalkError;
- }
-
- for (int i = 0; i < frames_count; i++) {
- frames[i].address = addresses[i];
- // Format a text representation of the frame based on the information
- // available.
- SNPrintF(MutableCStrVector(frames[i].text,
- kStackWalkMaxTextLen),
- "%s",
- symbols[i]);
- // Make sure line termination is in place.
- frames[i].text[kStackWalkMaxTextLen - 1] = '\0';
- }
-
- free(symbols);
+ if (backtrace == NULL) return 0;
- return frames_count;
+ return POSIXBacktraceHelper<backtrace, backtrace_symbols>::StackWalk(frames);
}
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698