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

Unified Diff: base/trace_event/heap_profiler_allocation_context_tracker.cc

Issue 1784133002: [tracing] Adding task information to heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use ThreadIdNameManager 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 8a4dbc7d8ca8f22f698ed0de63c4b9a408dd57e1..da00df18d7ea0556404f2eac5f46a6616c7150ec 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker.cc
+++ b/base/trace_event/heap_profiler_allocation_context_tracker.cc
@@ -32,9 +32,11 @@ void DestructAllocationContextTracker(void* alloc_ctx_tracker) {
} // namespace
-AllocationContextTracker::AllocationContextTracker() {
+AllocationContextTracker::AllocationContextTracker()
+ : current_task_file_name_(nullptr) {
pseudo_stack_.reserve(kMaxStackDepth);
}
+
AllocationContextTracker::~AllocationContextTracker() {}
// static
@@ -113,6 +115,22 @@ void AllocationContextTracker::PopPseudoStackFrame(StackFrame frame) {
}
// static
+void AllocationContextTracker::SetThreadName(const char* name) {
+ auto tracker = AllocationContextTracker::GetThreadLocalTracker();
+
+ // The thread name is added as the first entry in the psuedo stack. This is
+ // not removed until the tls is destroyed when thread dies.
+ tracker->pseudo_stack_.insert(tracker->pseudo_stack_.begin(),
+ static_cast<StackFrame>(name));
+}
+
+// static
+void AllocationContextTracker::SetCurrentTaskFileName(const char* file_name) {
+ AllocationContextTracker* tracker = GetThreadLocalTracker();
+ tracker->current_task_file_name_ = file_name;
+}
+
+// static
AllocationContext AllocationContextTracker::GetContextSnapshot() {
AllocationContextTracker* tracker = GetThreadLocalTracker();
AllocationContext ctx;
@@ -133,7 +151,10 @@ AllocationContext AllocationContextTracker::GetContextSnapshot() {
std::fill(dst, dst_end, nullptr);
}
- ctx.type_name = nullptr;
+ // Set the default type name to file name where the task was posted from.
+ // 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 = tracker->current_task_file_name_;
return ctx;
}
« base/debug/task_annotator.h ('K') | « base/trace_event/heap_profiler_allocation_context_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698