Commit 597ab41e authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

[heap profiler] Do not record top 3 frames related to profiler.

That makes the stack traces more clean thus reducing confusion during
stack attribution.
As a bonus less data is collected and sent.

BUG=803276

Change-Id: I8d320a356594d3077feed593fe653db246bc12a6
Reviewed-on: https://chromium-review.googlesource.com/1232413
Commit-Queue: Alexei Filippov <alph@chromium.org>
Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592558}
parent 7184de67
...@@ -792,6 +792,11 @@ void SerializeFramesFromAllocationContext(FrameSerializer* serializer, ...@@ -792,6 +792,11 @@ void SerializeFramesFromAllocationContext(FrameSerializer* serializer,
} }
void SerializeFramesFromBacktrace(FrameSerializer* serializer) { void SerializeFramesFromBacktrace(FrameSerializer* serializer) {
// Skip 3 top frames related to the profiler itself, e.g.:
// base::debug::StackTrace::StackTrace
// heap_profiling::RecordAndSendAlloc
// heap_profiling::`anonymous namespace'::HookAlloc
size_t skip_frames = 3;
#if defined(OS_ANDROID) && BUILDFLAG(CAN_UNWIND_WITH_CFI_TABLE) && \ #if defined(OS_ANDROID) && BUILDFLAG(CAN_UNWIND_WITH_CFI_TABLE) && \
defined(OFFICIAL_BUILD) defined(OFFICIAL_BUILD)
const void* frames[kMaxStackEntries - 1]; const void* frames[kMaxStackEntries - 1];
...@@ -801,8 +806,8 @@ void SerializeFramesFromBacktrace(FrameSerializer* serializer) { ...@@ -801,8 +806,8 @@ void SerializeFramesFromBacktrace(FrameSerializer* serializer) {
#elif BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS) #elif BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS)
const void* frames[kMaxStackEntries - 1]; const void* frames[kMaxStackEntries - 1];
size_t frame_count = base::debug::TraceStackFramePointers( size_t frame_count = base::debug::TraceStackFramePointers(
frames, kMaxStackEntries - 1, frames, kMaxStackEntries - 1, skip_frames);
1); // exclude this function from the trace. skip_frames = 0;
#else #else
// Fall-back to capturing the stack with base::debug::StackTrace, // Fall-back to capturing the stack with base::debug::StackTrace,
// which is likely slower, but more reliable. // which is likely slower, but more reliable.
...@@ -811,7 +816,9 @@ void SerializeFramesFromBacktrace(FrameSerializer* serializer) { ...@@ -811,7 +816,9 @@ void SerializeFramesFromBacktrace(FrameSerializer* serializer) {
const void* const* frames = stack_trace.Addresses(&frame_count); const void* const* frames = stack_trace.Addresses(&frame_count);
#endif #endif
serializer->AddAllInstructionPointers(frame_count, frames); skip_frames = std::min(skip_frames, frame_count);
serializer->AddAllInstructionPointers(frame_count - skip_frames,
frames + skip_frames);
if (g_include_thread_names) { if (g_include_thread_names) {
const char* thread_name = GetOrSetThreadName(); const char* thread_name = GetOrSetThreadName();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment