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

Unified Diff: base/debug/stack_trace.cc

Issue 2707223002: Make --enable-heap-profiling=native "work" on Windows. (Closed)
Patch Set: Fix typos Created 3 years, 9 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 | « base/debug/stack_trace.h ('k') | base/debug/stack_trace_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/stack_trace.cc
diff --git a/base/debug/stack_trace.cc b/base/debug/stack_trace.cc
index af4a6efc3ed2f60f3b7a04b2f592e9e886726dfc..43a23d95ac10ba0ca270a654cf1525a59b55ab58 100644
--- a/base/debug/stack_trace.cc
+++ b/base/debug/stack_trace.cc
@@ -35,7 +35,7 @@ namespace debug {
namespace {
-#if HAVE_TRACE_STACK_FRAME_POINTERS
+#if HAVE_TRACE_STACK_FRAME_POINTERS && !defined(OS_WIN)
#if defined(__arm__) && defined(__GNUC__) && !defined(__clang__)
// GCC and LLVM generate slightly different frames on ARM, see
@@ -142,7 +142,7 @@ void* LinkStackFrames(void* fpp, void* parent_fp) {
return prev_parent_fp;
}
-#endif // HAVE_TRACE_STACK_FRAME_POINTERS
+#endif // HAVE_TRACE_STACK_FRAME_POINTERS && !defined(OS_WIN)
} // namespace
@@ -225,6 +225,18 @@ std::string StackTrace::ToString() const {
size_t TraceStackFramePointers(const void** out_trace,
size_t max_depth,
size_t skip_initial) {
+// TODO(699863): Merge the frame-pointer based stack unwinder into the
+// base::debug::StackTrace platform-specific implementation files.
+#if defined(OS_WIN)
+ StackTrace stack(max_depth);
+ size_t count = 0;
+ const void* const* frames = stack.Addresses(&count);
+ if (count < skip_initial)
+ return 0u;
+ count -= skip_initial;
+ memcpy(out_trace, frames + skip_initial, count * sizeof(void*));
+ return count;
+#elif defined(OS_POSIX)
// Usage of __builtin_frame_address() enables frame pointers in this
// function even if they are not enabled globally. So 'fp' will always
// be valid.
@@ -258,8 +270,10 @@ size_t TraceStackFramePointers(const void** out_trace,
}
return depth;
+#endif
}
+#if !defined(OS_WIN)
ScopedStackFrameLinker::ScopedStackFrameLinker(void* fp, void* parent_fp)
: fp_(fp),
parent_fp_(parent_fp),
@@ -270,6 +284,7 @@ ScopedStackFrameLinker::~ScopedStackFrameLinker() {
CHECK_EQ(parent_fp_, previous_parent_fp)
<< "Stack frame's parent pointer has changed!";
}
+#endif // !defined(OS_WIN)
#endif // HAVE_TRACE_STACK_FRAME_POINTERS
« no previous file with comments | « base/debug/stack_trace.h ('k') | base/debug/stack_trace_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698