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

Unified Diff: base/trace_event/heap_profiler_allocation_context_tracker.cc

Issue 2637783002: [tracing] Don't register tracing-related allocations. (Closed)
Patch Set: Fix unittest Created 3 years, 11 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
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 f3a03fe90d08f6039aac99140af228df74a0e11c..31c3fd41b2e7f3349405cf49c25466d07e6f008b 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker.cc
+++ b/base/trace_event/heap_profiler_allocation_context_tracker.cc
@@ -29,7 +29,6 @@ const size_t kMaxStackDepth = 128u;
const size_t kMaxTaskDepth = 16u;
AllocationContextTracker* const kInitializingSentinel =
reinterpret_cast<AllocationContextTracker*>(-1);
-const char kTracingOverhead[] = "tracing_overhead";
ThreadLocalStorage::StaticSlot g_tls_alloc_ctx_tracker = TLS_INITIALIZER;
@@ -157,21 +156,15 @@ void AllocationContextTracker::PopCurrentTaskContext(const char* context) {
}
// static
-AllocationContext AllocationContextTracker::GetContextSnapshot() {
- AllocationContext ctx;
-
- if (ignore_scope_depth_) {
- ctx.backtrace.frames[0] = StackFrame::FromTraceEventName(kTracingOverhead);
- ctx.type_name = kTracingOverhead;
- ctx.backtrace.frame_count = 1;
- return ctx;
- }
+bool AllocationContextTracker::GetContextSnapshot(AllocationContext* ctx) {
+ if (ignore_scope_depth_)
+ return false;
CaptureMode mode = static_cast<CaptureMode>(
subtle::NoBarrier_Load(&capture_mode_));
- auto* backtrace = std::begin(ctx.backtrace.frames);
- auto* backtrace_end = std::end(ctx.backtrace.frames);
+ auto* backtrace = std::begin(ctx->backtrace.frames);
+ auto* backtrace_end = std::end(ctx->backtrace.frames);
if (!thread_name_) {
// Ignore the string allocation made by GetAndLeakThreadName to avoid
@@ -236,19 +229,21 @@ AllocationContext AllocationContextTracker::GetContextSnapshot() {
}
}
- ctx.backtrace.frame_count = backtrace - std::begin(ctx.backtrace.frames);
+ ctx->backtrace.frame_count = backtrace - std::begin(ctx->backtrace.frames);
// TODO(ssid): Fix crbug.com/594803 to add file name as 3rd dimension
// (component name) in the heap profiler and not piggy back on the type name.
if (!task_contexts_.empty()) {
- ctx.type_name = task_contexts_.back();
+ ctx->type_name = task_contexts_.back();
} else if (!pseudo_stack_.empty()) {
// If task context was unavailable, then the category names are taken from
// trace events.
- ctx.type_name = pseudo_stack_.back().trace_event_category;
+ ctx->type_name = pseudo_stack_.back().trace_event_category;
+ } else {
+ ctx->type_name = nullptr;
}
- return ctx;
+ return true;
}
} // namespace trace_event

Powered by Google App Engine
This is Rietveld 408576698