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

Unified Diff: base/trace_event/heap_profiler_allocation_context_tracker.cc

Issue 1851233002: Reland of [tracing] Adding task information to heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove event from sequenced_worker_pool.cc Created 4 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
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 0aa54a84ed380f8ee7e8f669bd78532041943e14..518792c4a5034b448eb364d13c3b223da147a4dd 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker.cc
+++ b/base/trace_event/heap_profiler_allocation_context_tracker.cc
@@ -19,6 +19,7 @@ subtle::Atomic32 AllocationContextTracker::capture_enabled_ = 0;
namespace {
const size_t kMaxStackDepth = 128u;
+const size_t kMaxTaskDepth = 16u;
AllocationContextTracker* const kInitializingSentinel =
reinterpret_cast<AllocationContextTracker*>(-1);
@@ -51,6 +52,7 @@ AllocationContextTracker::GetInstanceForCurrentThread() {
AllocationContextTracker::AllocationContextTracker() : thread_name_(nullptr) {
pseudo_stack_.reserve(kMaxStackDepth);
+ task_contexts_.reserve(kMaxTaskDepth);
}
AllocationContextTracker::~AllocationContextTracker() {}
@@ -99,6 +101,20 @@ void AllocationContextTracker::PopPseudoStackFrame(StackFrame frame) {
pseudo_stack_.pop_back();
}
+void AllocationContextTracker::PushCurrentTaskContext(const char* context) {
+ DCHECK(context);
+ if (task_contexts_.size() < kMaxTaskDepth)
+ task_contexts_.push_back(context);
+ else
+ NOTREACHED();
+}
+
+void AllocationContextTracker::PopCurrentTaskContext(const char* context) {
+ DCHECK_EQ(context, task_contexts_.back())
+ << "Encountered an unmatched context end";
+ task_contexts_.pop_back();
+}
+
// static
AllocationContext AllocationContextTracker::GetContextSnapshot() {
AllocationContext ctx;
@@ -125,7 +141,9 @@ AllocationContext AllocationContextTracker::GetContextSnapshot() {
std::fill(dst, dst_end, nullptr);
}
- ctx.type_name = nullptr;
+ // 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.
+ ctx.type_name = task_contexts_.empty() ? nullptr : task_contexts_.back();
return ctx;
}

Powered by Google App Engine
This is Rietveld 408576698