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

Unified Diff: base/trace_event/heap_profiler_allocation_context_tracker.cc

Issue 2892273003: Produce more useful stack traces for heap profiling. (Closed)
Patch Set: Created 3 years, 7 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/trace_event/heap_profiler_allocation_context.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/heap_profiler_allocation_context_tracker.cc
diff --git a/base/trace_event/heap_profiler_allocation_context_tracker.cc b/base/trace_event/heap_profiler_allocation_context_tracker.cc
index 64a9975baabc1a784f7ebaa1a695b858f6964895..df1b7e582206285b62c4ec96aede0a1cfba82d0f 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker.cc
+++ b/base/trace_event/heap_profiler_allocation_context_tracker.cc
@@ -206,12 +206,12 @@ bool AllocationContextTracker::GetContextSnapshot(AllocationContext* ctx) {
// make sure we reach main(), and then copy bottom portion of them.
#if !defined(OS_NACL) // We don't build base/debug/stack_trace.cc for NaCl.
#if BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS)
- const void* frames[128];
- static_assert(arraysize(frames) >= Backtrace::kMaxFrameCount,
- "not requesting enough frames to fill Backtrace");
- size_t frame_count = debug::TraceStackFramePointers(
- frames, arraysize(frames),
- 1 /* exclude this function from the trace */);
+ const void* frames[Backtrace::kMaxFrameCount];
DmitrySkiba 2017/05/20 00:23:23 Indentation is wrong (same below).
+ static_assert(arraysize(frames) >= Backtrace::kMaxFrameCount,
+ "not requesting enough frames to fill Backtrace");
+ size_t frame_count = debug::TraceStackFramePointers(
+ frames, arraysize(frames),
+ 1 /* exclude this function from the trace */);
#else // BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS)
// Fall-back to capturing the stack with base::debug::StackTrace,
// which is likely slower, but more reliable.
@@ -220,14 +220,14 @@ bool AllocationContextTracker::GetContextSnapshot(AllocationContext* ctx) {
const void* const* frames = stack_trace.Addresses(&frame_count);
#endif // BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS)
- // Copy frames backwards
- size_t backtrace_capacity = backtrace_end - backtrace;
- int32_t top_frame_index = (backtrace_capacity >= frame_count)
- ? 0
- : frame_count - backtrace_capacity;
- for (int32_t i = frame_count - 1; i >= top_frame_index; --i) {
- const void* frame = frames[i];
- *backtrace++ = StackFrame::FromProgramCounter(frame);
+ // If there are too many frames, keep the ones furthest from main().
+ size_t backtrace_capacity = backtrace_end - backtrace;
+ int32_t starting_frame_index = (backtrace_capacity >= frame_count)
+ ? frame_count
+ : backtrace_capacity;
+ for (int32_t i = starting_frame_index - 1; i >= 0; --i) {
+ const void* frame = frames[i];
+ *backtrace++ = StackFrame::FromProgramCounter(frame);
}
#endif // !defined(OS_NACL)
break;
« no previous file with comments | « base/trace_event/heap_profiler_allocation_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698